Forcing Maven deploy multi module maven project to maven
artifact repository only after successful unit tests
We have a maven multi module project, ( or better to say a multi
multi module maven project) with several maven project modules. We
want to deploy them to artifact repository (mvn deploy) only if
they all pass a full mvn install (which includes
the tests). As Maven is not atomic when it executes the
build life-cycle. So a broken set of artifacts may end up in a
We have the following three requirements:
- Execute the maven deploy goal to deploy all multi module maven
artifacts to a remote repository.
- Only deploy if ALL unit tests across all projects pass.
- Do not repeat any processing.
Maven deploy plugin version 2.8 has a solution for this. This
version of mvn deploy plugin has a property named
deployAtEnd that determines whether every project should be
deployed during its own deploy-phase or at the end of the
multi-module build. If set to true and the build fails, none
of the reactor projects is deployed to artifact repository. The
default value is for this property is false.
How to config the new maven deploy plugin in maven
How does Maven resolve plugin versions?
Every version of maven binaries has certain versions of plugin
versions hard coded. That's to make a somewhat reproducible build
in the cases when user doesn't provide his own version information.
Which you are encouraged to do and once you populate
<pluginManagement> section with the plugin versions of your
choice, the build will start using it.
Maven Configuration for new maven deploy plugin
So we need to add these dependency to a parent POM (if we have
one) or somewhere in a default profile in our Settings.xml in
After these configuration and adding -DdeployAtEnd we ran our
build and everything seems OK.
we checked the logs and found out that on deploying maven said
"deploy at end" but at the end nothing has been deployed to maven
repository nexus at all!
Maven deployAtEnd not work (DeployAtEnd not deploy at all)
First we had doubt on some plugins that skip deploy but after
checking the logs we found out that one module of project in the
build had been used the old 2.7 plugin and that was the source of
When all poms in a multi module (or multi multi modul) project
uses the same version (2.8.1) everything even skiping deploy in
some modules in maven works fine and a lot of uploading at the end
of maven log shows that modules uploaded to the nexus maven