Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven release plugin executes tests twice

Tags:

junit

maven

When release:clean release:prepare release:perform is executed , the tests are executed twice

Once at release:prepare , stage run-preparation-goals , task clean verify

And another time on release:perform ,stage run-perform-goals , task deploy

Is there any configuration option to make tests run only on first one and not being executed on perform?

like image 231
Yulian Oifa Avatar asked Oct 17 '25 11:10

Yulian Oifa


2 Answers

That's because 2 full builds are run as part of the commands you issue.

The release:prepare section performs lots of checks on the code & repository, and does a full build to ensure all tests pass.

The release:perform section tags the repo, then pulls that tag. It performs a build based on that tag and the releases that build to your artefact store of choice (Nexus/Artifactory/wherever).

These steps are designed this way to ensure you don't pollute your repo with a tag on code that doesn't build, and tests are an integral part of your build. Once maven is happy your code is good to go, it creates the tag, and pulls it so it knows for sure that the code being released is the code referenced by the tag, and nothing else. Building that tag for release requires a full build, including the tests.

You can skip the tests on one or other of the steps, or on both, but you're missing the point of tests, and of the release plugin, if you do that.

like image 67
TrueDub Avatar answered Oct 21 '25 05:10

TrueDub


You can override the goals parameter and add -DskipTests=true.

This parameter will skip the tests only on the perform part.

like image 37
J Fabian Meier Avatar answered Oct 21 '25 04:10

J Fabian Meier



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!