I try to add some additional phases to the maven lifecycle. Mainly to add some additional test levels:
<phases>
<phase>initialize</phase>
<phase>process-resources</phase>
<phase>compile</phase>
<phase>process-test-resources</phase>
<phase>test-compile</phase>
<phase>test</phase>
<phase>prepare-package</phase>
<phase>package</phase>
<phase>pre-integration-test</phase>
<phase>integration-test</phase>
<phase>post-integration-test</phase>
<phase>pre-application-test</phase>
<phase>application-test</phase>
<phase>post-application-test</phase>
<phase>pre-system-test</phase>
<phase>system-test</phase>
<phase>post-system-test</phase>
<phase>finalize-tests</phase>
<phase>install</phase>
<phase>deploy</phase>
</phases>
Above contains new application-test and system-test phase (including pre- and post-).
I've started a test plugin at: codezoo-lifecycle-maven-plugin The pom I use for testing is in the src/it folder.
It seems the new phases or somewhat picked up but there are some weird things going on:
mvn post-application-test
This works. Also the echo plugin that I added for testing is executed. But there are some warnings (using maven 3.3.9).
mvn install
Executes the default lifecycle skipping the new phases.
If I change the id of the lifecycle fomr "test-levels" to "default" the phases are executed twice.
The warnings issued are:
[WARNING] Duplicated lifecycle phase package. Defined in default but also in test-levels
[WARNING] Duplicated lifecycle phase pre-integration-test. Defined in default but also in test-levels
[WARNING] Duplicated lifecycle phase integration-test. Defined in default but also in test-levels
....
The source code that issues this warning indicates the lifecycle is not properly namespaced. But I cannot figure out how that is done.
I found some hints on the web: create-a-new-phase (Stackoverflow) or in other plugins like the maven-scm-publish-plugin or the docker-maven-plugin. But those are either creating a complete new lifecycle or just change the plugin mapping from the default maven lifecycle.
All other stuff on the web regarding this topic seems to be at least 4 years old...
So:
The current state of the test plugin is on github.
Thanks!
build
lifecycle with 24 phases
custom plugin
if you don't find it on maven repo and bind it to any phase
which is most suitable.Surely you can make your project as complex as you want but generally it is considered bad practice to add lifecycle and phases until you don't have very big thing to manage in the context of build lifecycle.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With