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>
<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>
<artifactId>direct</artifactId>
<version>0.1</version>

View File

@ -32,28 +32,20 @@ under the License.
<packaging>maven-plugin</packaging>
<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>
<properties>
<maven.test.skip>true</maven.test.skip>
</properties>
<dependencies>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-plugin-api</artifactId>
<version>2.0</version>
</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>
</project>

View File

@ -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 <a href="brett@apache.org">Brett Porter</a>
* @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.
*/
}
}

View File

@ -6,9 +6,8 @@
<implementation>org.apache.maven.lifecycle.mapping.DefaultLifecycleMapping</implementation>
<configuration>
<phases>
<!-- NOTE: This is intentionally a very minimalistic lifecycle -->
<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>
</configuration>
</component>