MNG-2831: Cannot add custom artifact handler and custom lifecycle as a build extension

* Added an IT test to show the problem.

git-svn-id: https://svn.apache.org/repos/asf/maven/core-integration-testing/trunk@508792 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Vincent Massol 2007-02-17 18:51:17 +00:00
parent 33b2b603e7
commit a759fb24e3
5 changed files with 181 additions and 0 deletions

View File

@ -0,0 +1,35 @@
<?xml version="1.0" encoding="UTF-8"?>
<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.its.it0115</groupId>
<artifactId>test-extension</artifactId>
<name>Test Extension</name>
<version>1.0-SNAPSHOT</version>
<inceptionYear>2007</inceptionYear>
<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-archiver</artifactId>
<version>2.2</version>
</dependency>
<dependency>
<groupId>org.codehaus.plexus</groupId>
<artifactId>plexus-utils</artifactId>
<version>1.4</version>
</dependency>
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-artifact</artifactId>
<version>2.0</version>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,80 @@
package org.apache.maven.its.it0115;
/*
* Copyright 2007 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import java.io.File;
import java.io.IOException;
import org.apache.maven.plugin.AbstractMojo;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.archiver.ArchiverException;
import org.codehaus.plexus.archiver.zip.ZipArchiver;
/**
* Gather all resources in a XAR file (which is actually a ZIP file)
*
* @version $Id: $
* @goal xar
* @phase package
*/
public class XarMojo extends AbstractMojo
{
/**
* The maven project.
*
* @parameter expression="${project}"
* @required
* @readonly
*/
private MavenProject project;
/**
* @see org.apache.maven.plugin.Mojo#execute()
*/
public void execute() throws MojoExecutionException, MojoFailureException
{
if (this.project.getResources().size() < 1)
{
this.getLog().warn("No XAR created as no resources were found");
return;
}
try
{
performArchive();
}
catch (Exception e)
{
throw new MojoExecutionException("Error while creating XAR file", e );
}
}
private void performArchive() throws ArchiverException, IOException
{
File xarFile = new File(this.project.getBuild().getDirectory(),
this.project.getArtifactId() + ".xar" );
ZipArchiver archiver = new ZipArchiver();
archiver.setDestFile(xarFile);
archiver.setIncludeEmptyDirs(false);
archiver.setCompress(true);
archiver.addDirectory(new File(this.project.getBuild().getOutputDirectory()));
archiver.createArchive();
this.project.getArtifact().setFile(xarFile);
}
}

View File

@ -0,0 +1,27 @@
<component-set>
<components>
<component>
<role>org.apache.maven.lifecycle.mapping.LifecycleMapping</role>
<role-hint>xar</role-hint>
<implementation>org.apache.maven.lifecycle.mapping.DefaultLifecycleMapping</implementation>
<configuration>
<phases>
<process-resources>org.apache.maven.plugins:maven-resources-plugin:resources</process-resources>
<package>org.apache.maven.its.it0115:test-extension:xar</package>
<install>org.apache.maven.plugins:maven-install-plugin:install</install>
<deploy>org.apache.maven.plugins:maven-deploy-plugin:deploy</deploy>
</phases>
</configuration>
</component>
<component>
<role>org.apache.maven.artifact.handler.ArtifactHandler</role>
<role-hint>xar</role-hint>
<implementation>org.apache.maven.artifact.handler.DefaultArtifactHandler</implementation>
<configuration>
<type>xar</type>
<extension>xar</extension>
<packaging>xar</packaging>
</configuration>
</component>
</components>
</component-set>

View File

@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8"?>
<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.its.it0115</groupId>
<artifactId>test-project</artifactId>
<name>Test Project</name>
<version>1.0-SNAPSHOT</version>
<inceptionYear>2007</inceptionYear>
<packaging>xar</packaging>
<build>
<extensions>
<extension>
<groupId>org.apache.maven.its.it0115</groupId>
<artifactId>test-extension</artifactId>
<version>1.0-SNAPSHOT</version>
</extension>
</extensions>
</build>
</project>

View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="ISO-8859-1"?>
<package>
<infos>
<name>Backup</name>
<description>on Fri Jan 26 09:55:02 CET 2007 by XWiki.Admin</description>
<licence></licence>
<author>XWiki.Admin</author>
<version></version>
<backupPack>true</backupPack>
</infos>
<files/>
</package>