Can we start the maven build from the point where it failed

JavaMaven 2

Java Problem Overview


Suppose, I am doing a full build on my large project which has 7 modules and on the 6th module, the build failed because a test failed. Is there any way by which I can start the build from the point it failed?

Java Solutions


Solution 1 - Java

You can resume the build from the 6th module using -rf or --resume-from:

> -rf, --resume-from
>           Resume reactor from specified project

See the Advanced Reactor Options for details.

Solution 2 - Java

Here is the example

mvn clean install -rf :your-module

Solution 3 - Java

you can resume the build from any module you want by using the -rf command. For example, if your build failed in myproject-proxy, you can use the following command:

mvn -rf myproject-proxy clean install

Solution 4 - Java

look at the maven summary and you will see the executed modules and where maven is stopped. then try this:

mvn clean install-Dmaven.test.skip=true -rf :yourModule

Solution 5 - Java

According to "What's New in Maven 4" (Nov. 2020) from Maarten Mulders, you will soon be able to, with the upcoming Maven 4.0.0 (Q1 2021)

Consider this example project structure:

https://maarten.mulders.it/2020/11/whats-new-in-maven-4/example-project_hu981f14f09d98e6139a671549a98c2057_118421_1037x555_resize_box_2.png

> ## Use --also-make together with --resume-from

> The first improvement in the Reactor is a bug fix.
Previously, if your project build failed on the client module, you would get a hint to resume the build with --resume-from :client. But if you did that, the build would break again: this time because Maven couldn’t find the common module.
You might think that adding --also-make (or -am) would address this, but it wouldn’t. This long-standing bug is no longer there. > > If you combine --resume-from :client with --also-make, the Reactor will find all modules in your project and continue the build as you requested.

> ## Automatically resume from the last point of failure > >But chances are you will not notice. The thing with --resume-from :client is that it makes you think more than necessary. > > With Maven 4, you can make your life even easier and use --resume, or -r for short. It will automatically resume the build from the module that last failed. > >But there’s more! Maybe you are using parallel builds. One sequence of modules was successfully built, while the build of another sequence of modules broke.
In that scenario, using -r will skip the modules that were successful in the previous build. > >The combination of these two features may well improve the time you need to build your large, enterprise software project!

Solution 6 - Java

Syntax: mvn -rf modulename mavengoal or mvn --resume-from modulename mavengoal

Ex: mvn -rf admin-module clean install or mvn --resume-from admin-module clean install

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionShekharView Question on Stackoverflow
Solution 1 - JavaPascal ThiventView Answer on Stackoverflow
Solution 2 - JavaM SachView Answer on Stackoverflow
Solution 3 - Javauser3401235View Answer on Stackoverflow
Solution 4 - JavaAntonio MartinView Answer on Stackoverflow
Solution 5 - JavaVonCView Answer on Stackoverflow
Solution 6 - Javascott_dennisView Answer on Stackoverflow