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:
- how can I add additional phases to the maven default lifecycle (If I have to repeat the default plugin mappings: I can live with that)
- how can I namespace the new lifecycle? It seems I create my own packaging (which is referenced as role-hint in the configuration). But still maven has some fallback to the default lifecycle.
- can the default maven phases not be re-used?
The current state of the test plugin is on github.
Thanks!