Disable phases in the Maven life cycle

How to disable unnecessary phases in the default life cycle of Maven 3?

Disable, I mean completely, completely cut the phase out of the life cycle, so that it is not even called.

I might need a custom life cycle, but I could not find an easy way to define it directly in my pom.xml . It seems I need to write a plugin to list the phases that I want.

For example, I would like the phases default-testResources , default-testCompile and default-test never happen and not include my build log from this:

 [INFO] ------------------------------------------------------------------------ [INFO] Building HelpDesk Webapp 0.0.1-SNAPSHOT [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ helpdesk --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] skip non existing resourceDirectory d:\proj\HelpDesk\repo\src\main\resources [INFO] [INFO] --- maven-compiler-plugin:3.0:compile (default-compile) @ helpdesk --- [INFO] No sources to compile [INFO] [INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ helpdesk --- [INFO] Not copying test resources [INFO] [INFO] --- maven-compiler-plugin:3.0:testCompile (default-testCompile) @ helpdesk --- [INFO] Not compiling test sources [INFO] [INFO] --- maven-surefire-plugin:2.10:test (default-test) @ helpdesk --- [INFO] Tests are skipped. [INFO] [INFO] --- maven-war-plugin:2.3:war (default-war) @ helpdesk --- [INFO] Packaging webapp [INFO] Assembling webapp [helpdesk] in [d:\proj\HelpDesk\repo\target\helpdesk] [INFO] Processing war project [INFO] Copying webapp resources [d:\proj\HelpDesk\repo\src\main\webapp] [INFO] Webapp assembled in [40 msecs] [INFO] Building war: d:\proj\HelpDesk\repo\target\helpdesk.war [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ 

in it:

 [INFO] ------------------------------------------------------------------------ [INFO] Building HelpDesk Webapp 0.0.1-SNAPSHOT [INFO] ------------------------------------------------------------------------ [INFO] [INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ helpdesk --- [INFO] Using 'UTF-8' encoding to copy filtered resources. [INFO] skip non existing resourceDirectory d:\proj\HelpDesk\repo\src\main\resources [INFO] [INFO] --- maven-compiler-plugin:3.0:compile (default-compile) @ helpdesk --- [INFO] No sources to compile [INFO] [INFO] --- maven-war-plugin:2.3:war (default-war) @ helpdesk --- [INFO] Packaging webapp [INFO] Assembling webapp [helpdesk] in [d:\proj\HelpDesk\repo\target\helpdesk] [INFO] Processing war project [INFO] Copying webapp resources [d:\proj\HelpDesk\repo\src\main\webapp] [INFO] Webapp assembled in [40 msecs] [INFO] Building war: d:\proj\HelpDesk\repo\target\helpdesk.war [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESS [INFO] ------------------------------------------------------------------------ 
+6
maven maven-3
Mar 06 '13 at 14:02
source share
1 answer

If you want to continue using the predefined packaging (jar, war, etc.), you cannot completely remove them. You can leave the package as pom and define your own life cycle by linking the goals you want to the desired stages, or you can fully define your life cycle. You can also bind the default target to the none phase to prevent any real work from happening as shown.

 <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-resources-plugin</artifactId> <executions> <execution> <id>default-testResources</id> <phase>none</phase> </execution> </executions> </plugin> 

All that was said - the Khmarbaiza question is good. This is generally not the best practice for modifying existing pre-built life cycles.

+10
Mar 06 '13 at 14:49
source share



All Articles