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
This commit is contained in:
Benjamin Bentmann 2009-01-13 21:44:07 +00:00
parent 2c44c15783
commit 75462f07cd
4 changed files with 22 additions and 40 deletions

View File

@ -27,7 +27,7 @@
<dependencies> <dependencies>
<dependency> <dependency>
<!-- This has a broken POM, yet it's dependencies should contribute to this build --> <!-- This has a broken POM, yet its dependencies should contribute to this build -->
<groupId>org.apache.maven.its.mng3680</groupId> <groupId>org.apache.maven.its.mng3680</groupId>
<artifactId>direct</artifactId> <artifactId>direct</artifactId>
<version>0.1</version> <version>0.1</version>

View File

@ -32,28 +32,20 @@ under the License.
<packaging>maven-plugin</packaging> <packaging>maven-plugin</packaging>
<name>Maven Integration Test Plugin :: Packaging</name> <name>Maven Integration Test Plugin :: Packaging</name>
<description>
A test plugin that defines a custom aritfact handler ("it-artifact") and a new packaging type ("it-packaging").
</description>
<inceptionYear>2006</inceptionYear> <inceptionYear>2006</inceptionYear>
<properties>
<maven.test.skip>true</maven.test.skip>
</properties>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>org.apache.maven</groupId> <groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId> <artifactId>maven-plugin-api</artifactId>
<version>2.0</version> <version>2.0</version>
</dependency> </dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-project</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-artifact</artifactId>
<version>2.0</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-archiver</artifactId>
<version>2.0</version>
</dependency>
</dependencies> </dependencies>
</project> </project>

View File

@ -19,16 +19,15 @@ package org.apache.maven.plugin.coreit;
* under the License. * 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.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException; 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.File;
import java.io.IOException;
/** /**
* Creates an empty file to prove this goal was executed.
*
* @author <a href="brett@apache.org">Brett Porter</a> * @author <a href="brett@apache.org">Brett Porter</a>
* @version $Id$ * @version $Id$
* @goal package * @goal package
@ -36,12 +35,6 @@ import java.io.File;
public class PackagingMojo public class PackagingMojo
extends AbstractMojo extends AbstractMojo
{ {
/**
* @parameter expression="${project}"
* @required
*/
private MavenProject project;
/** /**
* @parameter expression="${project.build.finalName}" * @parameter expression="${project.build.finalName}"
@ -54,31 +47,29 @@ public class PackagingMojo
* @required * @required
* @readonly * @readonly
*/ */
private String outputDirectory; private File outputDirectory;
public void execute() public void execute()
throws MojoExecutionException throws MojoExecutionException
{ {
File jarFile = new File( outputDirectory, finalName + "-it.jar" ); File jarFile = new File( outputDirectory, finalName + "-it.jar" );
MavenArchiver archiver = new MavenArchiver(); getLog().info( "[MAVEN-CORE-IT-LOG] Creating artifact file: " + jarFile );
archiver.setArchiver( new JarArchiver() );
archiver.setOutputFile( jarFile );
try 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 ); 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.
*/
} }
} }

View File

@ -6,9 +6,8 @@
<implementation>org.apache.maven.lifecycle.mapping.DefaultLifecycleMapping</implementation> <implementation>org.apache.maven.lifecycle.mapping.DefaultLifecycleMapping</implementation>
<configuration> <configuration>
<phases> <phases>
<!-- NOTE: This is intentionally a very minimalistic lifecycle -->
<package>org.apache.maven.its.plugins:maven-it-plugin-packaging:package</package> <package>org.apache.maven.its.plugins:maven-it-plugin-packaging:package</package>
<install>org.apache.maven.plugins:maven-install-plugin:install</install>
<deploy>org.apache.maven.plugins:maven-deploy-plugin:deploy</deploy>
</phases> </phases>
</configuration> </configuration>
</component> </component>