From 75462f07cd66fb04b0efeab7f11f4be8081cf39c Mon Sep 17 00:00:00 2001 From: Benjamin Bentmann Date: Tue, 13 Jan 2009 21:44:07 +0000 Subject: [PATCH] o Decoupled maven-it-plugin-packaging from APIs that are irrelevant for its purpose git-svn-id: https://svn.apache.org/repos/asf/maven/core-integration-testing/trunk@734246 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/test/resources/mng-3680/pom.xml | 2 +- .../maven-it-plugin-packaging/pom.xml | 22 ++++-------- .../maven/plugin/coreit/PackagingMojo.java | 35 +++++++------------ .../resources/META-INF/plexus/components.xml | 3 +- 4 files changed, 22 insertions(+), 40 deletions(-) diff --git a/its/core-it-suite/src/test/resources/mng-3680/pom.xml b/its/core-it-suite/src/test/resources/mng-3680/pom.xml index 3eeacc3262..94ff959534 100644 --- a/its/core-it-suite/src/test/resources/mng-3680/pom.xml +++ b/its/core-it-suite/src/test/resources/mng-3680/pom.xml @@ -27,7 +27,7 @@ - + org.apache.maven.its.mng3680 direct 0.1 diff --git a/its/core-it-support/core-it-plugins/maven-it-plugin-packaging/pom.xml b/its/core-it-support/core-it-plugins/maven-it-plugin-packaging/pom.xml index 8f2bf73c51..3abd4fe31c 100644 --- a/its/core-it-support/core-it-plugins/maven-it-plugin-packaging/pom.xml +++ b/its/core-it-support/core-it-plugins/maven-it-plugin-packaging/pom.xml @@ -32,28 +32,20 @@ under the License. maven-plugin Maven Integration Test Plugin :: Packaging + + A test plugin that defines a custom aritfact handler ("it-artifact") and a new packaging type ("it-packaging"). + 2006 + + true + + org.apache.maven maven-plugin-api 2.0 - - org.apache.maven - maven-project - 2.0 - - - org.apache.maven - maven-artifact - 2.0 - - - org.apache.maven - maven-archiver - 2.0 - diff --git a/its/core-it-support/core-it-plugins/maven-it-plugin-packaging/src/main/java/org/apache/maven/plugin/coreit/PackagingMojo.java b/its/core-it-support/core-it-plugins/maven-it-plugin-packaging/src/main/java/org/apache/maven/plugin/coreit/PackagingMojo.java index 8dbd824061..56f09ea04b 100644 --- a/its/core-it-support/core-it-plugins/maven-it-plugin-packaging/src/main/java/org/apache/maven/plugin/coreit/PackagingMojo.java +++ b/its/core-it-support/core-it-plugins/maven-it-plugin-packaging/src/main/java/org/apache/maven/plugin/coreit/PackagingMojo.java @@ -19,16 +19,15 @@ package org.apache.maven.plugin.coreit; * under the License. */ -import org.apache.maven.archiver.MavenArchiver; -import org.apache.maven.archiver.MavenArchiveConfiguration; import org.apache.maven.plugin.AbstractMojo; import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.project.MavenProject; -import org.codehaus.plexus.archiver.jar.JarArchiver; import java.io.File; +import java.io.IOException; /** + * Creates an empty file to prove this goal was executed. + * * @author Brett Porter * @version $Id$ * @goal package @@ -36,12 +35,6 @@ import java.io.File; public class PackagingMojo extends AbstractMojo { - - /** - * @parameter expression="${project}" - * @required - */ - private MavenProject project; /** * @parameter expression="${project.build.finalName}" @@ -54,31 +47,29 @@ public class PackagingMojo * @required * @readonly */ - private String outputDirectory; + private File outputDirectory; public void execute() throws MojoExecutionException { File jarFile = new File( outputDirectory, finalName + "-it.jar" ); - MavenArchiver archiver = new MavenArchiver(); - - archiver.setArchiver( new JarArchiver() ); - - archiver.setOutputFile( jarFile ); + getLog().info( "[MAVEN-CORE-IT-LOG] Creating artifact file: " + jarFile ); try { - archiver.createArchive( project, new MavenArchiveConfiguration() ); + jarFile.getParentFile().mkdirs(); + jarFile.createNewFile(); } - catch ( Exception e ) + catch ( IOException e ) { - // TODO: improve error handling throw new MojoExecutionException( "Error assembling JAR", e ); } - - project.getArtifact().setFile( jarFile ); + + /* + * NOTE: Normal packaging plugins would set the main artifact's file path now but that's beyond the purpose of + * this test plugin. Hence there's no need to introduce further coupling with the Maven Artifact API. + */ } } - diff --git a/its/core-it-support/core-it-plugins/maven-it-plugin-packaging/src/main/resources/META-INF/plexus/components.xml b/its/core-it-support/core-it-plugins/maven-it-plugin-packaging/src/main/resources/META-INF/plexus/components.xml index a89159d4c5..69a17af86e 100644 --- a/its/core-it-support/core-it-plugins/maven-it-plugin-packaging/src/main/resources/META-INF/plexus/components.xml +++ b/its/core-it-support/core-it-plugins/maven-it-plugin-packaging/src/main/resources/META-INF/plexus/components.xml @@ -6,9 +6,8 @@ org.apache.maven.lifecycle.mapping.DefaultLifecycleMapping + org.apache.maven.its.plugins:maven-it-plugin-packaging:package - org.apache.maven.plugins:maven-install-plugin:install - org.apache.maven.plugins:maven-deploy-plugin:deploy