Ok so here is my initial attempt at overriding (or creating) a lifecycle. My goal is to override the package phase (specifically the war:war with war:explode). I followed the example here: http://www.sonatype.com/books/mvnref-book/reference/writing-plugins-sect-override-default-lifecycle.html
and here: http://www.sonatype.com/books/mvnref-book/reference/writing-plugins-sect-custom-lifecycle.html Here is the code: lifecycles.xml: <lifecycles> <lifecycle> <id>zipcycle</id> <phases> <phase> <id>package</id> <executions> <execution> <goals> <goal>explode</goal> </goals> </execution> </executions> </phase> </phases> </lifecycle> </lifecycles> components.xml: <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> <process-resources> org.apache.maven.plugins:maven-resources-plugin:resources </process-resources> <compile> org.apache.maven.plugins:maven-compiler-plugin:compile </compile> <package>org.apache.maven.plugins:maven-zip-plugin:zip</package> </phases> </configuration> </component> </components> </component-set> POM for my archetype generated via 'mvn archetype:generate': 64: remote -> maven-archetype-webapp (An archetype which contains a sample Maven Webapp project.): <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.intuit</groupId> <artifactId>testapp</artifactId> <packaging>war</packaging> <version>1.0-SNAPSHOT</version> <name>Maven Webapp Archetype</name> <url>http://maven.apache.org</url> <dependencies> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> </dependencies> <build> <finalName>testapp</finalName> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-zip-plugin</artifactId> <version>1.0-SNAPSHOT</version> <extensions>true</extensions> <executions> <execution> <id>ZipForkMojo</id> <phase>package</phase> <goals> <goal>touch</goal> </goals> </execution> </executions> </plugin> </plugins> </build> </project> ZipForkMojo: import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; /** * @goal touch * @phase package */ public class ZipForkMojo extends AbstractMojo { public void execute() throws MojoExecutionException { getLog().info( "doing nothing here" ); } } maven-zip-plugin POM: <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-zip-plugin</artifactId> <packaging>maven-plugin</packaging> <version>1.0-SNAPSHOT</version> <name>maven-zip-plugin Maven Mojo</name> <url>http://maven.apache.org</url> <dependencies> <dependency> <groupId>org.apache.maven</groupId> <artifactId>maven-plugin-api</artifactId> <version>2.0</version> </dependency> <dependency> <groupId>junit</groupId> <artifactId>junit</artifactId> <version>3.8.1</version> <scope>test</scope> </dependency> </dependencies> </project> result of issuing 'mvn clean install' cmd: C:\Documents and Settings\asookazian\My Documents\ubuntu_projects.tar\projects\t estapp>mvn clean install [INFO] Scanning for projects... [INFO] ------------------------------------------------------------------------ [INFO] Building Maven Webapp Archetype [INFO] task-segment: [clean, install] [INFO] ------------------------------------------------------------------------ [INFO] [clean:clean] [INFO] Deleting directory C:\Documents and Settings\asookazian\My Documents\ubun tu_projects.tar\projects\testapp\target [INFO] Ignoring available plugin update: 2.5 as it requires Maven version 2.0.9 [INFO] [resources:resources] [WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent! [INFO] Copying 0 resource [INFO] [compiler:compile] [INFO] No sources to compile [INFO] [resources:testResources] [WARNING] Using platform encoding (Cp1252 actually) to copy filtered resources, i.e. build is platform dependent! [INFO] skip non existing resourceDirectory C:\Documents and Settings\asookazian\ My Documents\ubuntu_projects.tar\projects\testapp\src\test\resources [INFO] [compiler:testCompile] [INFO] No sources to compile [INFO] [surefire:test] [INFO] No tests to run. [INFO] [war:war] [INFO] Packaging webapp [INFO] Assembling webapp[testapp] in [C:\Documents and Settings\asookazian\My Do cuments\ubuntu_projects.tar\projects\testapp\target\testapp] [INFO] Processing war project [INFO] Copying webapp resources[C:\Documents and Settings\asookazian\My Document s\ubuntu_projects.tar\projects\testapp\src\main\webapp] [INFO] Webapp assembled in [47 msecs] [INFO] Building war: C:\Documents and Settings\asookazian\My Documents\ubuntu_pr ojects.tar\projects\testapp\target\testapp.war [INFO] [zip:touch {execution: ZipForkMojo}] [INFO] doing nothing here [INFO] [install:install] [INFO] Installing C:\Documents and Settings\asookazian\My Documents\ubuntu_proje cts.tar\projects\testapp\target\testapp.war to C:\Documents and Settings\asookaz ian\.m2\repo2\com\intuit\testapp\1.0-SNAPSHOT\testapp-1.0-SNAPSHOT.war [INFO] ------------------------------------------------------------------------ [INFO] BUILD SUCCESSFUL [INFO] ------------------------------------------------------------------------ [INFO] Total time: 2 seconds [INFO] Finished at: Wed Jul 07 11:06:57 PDT 2010 [INFO] Final Memory: 9M/17M [INFO] ------------------------------------------------------------------------ So the war:war goal is still being exec'd but at least my plugin's execute method is invoked as well. Any ideas how to fix this so the override actually works? thx. -- View this message in context: http://maven.40175.n5.nabble.com/Creating-a-Custom-Lifecycle-tp1044781p1044808.html Sent from the Maven - Users mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
