Maven has a release plugin that can be used to produce and publish release artifacts. When you have a maven based project, simply running;
mvn release:prepare release:perform
Will present a series of questions that would then end up producing and publishing release artifiacts for your project(s). Leaving the details out of the 'prepare' and 'perform' phases out of this write-up (as it is sufficiently documented), this post will dwell on running tests during these releases.
When one runs the above, maven would run all tests by default. This is because both phases runs golas that executes tests. 'perform' by default executes 'clean verify' goals while 'perform' by default executes 'deploy'. This means if you have 100s of tests, they will run twice.
While this seems completely normal, it can be argued that once a preparation has been done, i.e. All source code compiled, tests passed, scm tags created, it really isn't necessary to run the same tests again. While there are compelling reasons as to why you still want to run tests, this was one of the things that was bugging us when we run maven releases. Specially when you run preparation and perform together, it seems reasonable to be able to avoid the tests for the second time. When a project has 100s of integration/functional tests that gets executed as part of a release, this means a lot of time spent in running tests that we already know that passed.
And it so happens the release plugin does provide the capability to avoid tests running during the perform phase if one wants to do so. It's all down to the plugin configuration.
maven-release-plugin 2.1 deploy -Dmaven.test.skip=true
The above configuration would make sure that tests don't run as part of the 'perform' phase of your maven release, and there by saving you as many minutes it takes to run the tests. While this might not be a preferred choice (not running tests in the perform phase), the plugin is configurable for us to make it play how we want it to play in case the second test run is seen as avoidable.
1 comment:
Thanks, I found this really helpful!
One thing I will point is that using the -Dmaven.test.skip=true flag will prevent test-jars from being built and this can break the release goal. Using the -DskipTests flag will build test-jars but skip the actual running of the tests.
More information can be found in this JIRA: http://jira.codehaus.org/browse/MJAR-138
Post a Comment