build - Overriding 'clean' lifecycle in Maven -


i going through book explain how override 'default' lifecycle of maven.

it says: define new lifecycle packaging type, you'll need configure lifecyclemapping component in plexus. in plugin project, create meta-inf/plexus/components.xml under src/main/resources. in components.xml add content shown below, , you're done. below configuration, i'm able customize default lifecycle 'jar' packaging type. if exeute
$ mvn package
straigh away executes 'package' phase skipping other phases of default lifecycle , executes 'echo' goal of 'maven-zip-plugin'.

<component-set>     <components>         <component>             <role>org.apache.maven.lifecycle.mapping.lifecyclemapping</role>             <role-hint>zip</role-hint>             <implementation>                 org.apache.maven.lifecycle.mapping.defaultlifecyclemapping             </implementation>             <configuration>                 <phases>                     <package>org.sonatype.mavenbook.plugins:maven-zip-plugin:echo                     </package>                 </phases>             </configuration>         </component>     </components> </component-set> 

my question is: how can customize 'clean' lifecycle. example, assume when 1 types
$ mvn clean
instead of running clean:clean execute 'clean' goal of 'maven-clean-plugin' plugin, wanted execute 'customclean' goal of 'customplugin'.

for describe, simpler prevent maven-clean-plugin running during clean phase, , attach customplugin clean phase instead. simpler short-circuiting whole lifecycle, , keeps maven config in pom.

1 prevent maven-clean-plugin

<plugin>     <artifactid>maven-clean-plugin</artifactid>     <version>2.4.1</version>     <configuration>         <skip>true</skip>     </configuration> </plugin> 

2 attach own plugin clean phase

<plugin>     <artifactid>maven-customplugin-plugin</artifactid>     <version>customplugin-version</version>     <executions>         <execution>             <id>customised-clean</id>             <goals>                 <goal>customclean</goal>             </goals>             <phase>clean</phase>         </execution>     </executions> </plugin> 

Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

android - layout with fragment and framelayout replaced by another fragment and framelayout -