Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Combined site/deploy goal for Maven

Tags:

maven-2

When running a Maven build on the CI server, I generate the site to publish the documentation and reports, and also deploy the artifact to the snapshot repository for use by other projects. To do this I run the following goals:

mvn clean site deploy

This means the unit tests are run twice, once for the site lifecycle and once for the deploy lifecycle. If I configure the site goal to be bound to the standard lifecycle the tests are still run twice, running the site goal always causes the tests to be run because of the @requiresDependencyResolution test annotation. This is fine if you're only creating the site, but in the context of a deploy it greatly increases the build time for no benefit.

I have a workaround that involves copying the SiteMojo (and the required parents) to a new plugin and removing the @requiresDependencyResolution test annotation from the copy.

This modified mojo will generate the reports without forcing the tests to be run again but I'd prefer a solution that doesn't involve any hacking of the site plugin. Is there a way to suppress the requiresDependencyResolution annotation?

like image 973
Rich Seller Avatar asked Oct 14 '22 14:10

Rich Seller


1 Answers

I'm surprised this works - the @requiresDependencyResolution test tag doesn't actually trigger the tests being built - that should be one of the reports that you've included. Normally, I recommend running the site and the build in separate Maven executions in CI so you can get fast feedback on your build and publish the latest site only when that succeeds.

Another alternative is to run it as mvn clean deploy site, and choose the report-only mojo for surefire-report-maven-plugin (this is usually the report that is running the tests again). This will use the previous test results. Of course, another alternative is disabling that report altogether, since you likely get those results from another source such as your CI server anyway.

like image 122
Brett Porter Avatar answered Oct 21 '22 03:10

Brett Porter