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?
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.
Here is the example
mvn clean install -rf :your-module
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
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
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:
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!
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
精彩评论