Commit 01257555 authored by Emmanuel Bourg's avatar Emmanuel Bourg

New upstream version 3.0.0

parent 51a2551e
......@@ -18,9 +18,9 @@ specific language governing permissions and limitations
under the License.
-->
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
<assembly xmlns="http://maven.apache.org/ASSEMBLY/2.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
xsi:schemaLocation="http://maven.apache.org/ASSEMBLY/2.0.0 http://maven.apache.org/xsd/assembly-2.0.0.xsd">
<id>bin</id>
<formats>
<format>dir</format>
......
This diff is collapsed.
......@@ -35,6 +35,7 @@ import org.apache.maven.plugin.testing.stubs.MavenProjectStub;
import org.codehaus.plexus.archiver.Archiver;
import org.codehaus.plexus.archiver.ArchiverException;
import org.codehaus.plexus.archiver.UnArchiver;
import org.codehaus.plexus.archiver.diags.NoOpArchiver;
import org.codehaus.plexus.archiver.manager.ArchiverManager;
import org.codehaus.plexus.archiver.manager.NoSuchArchiverException;
import org.codehaus.plexus.util.DirectoryScanner;
......@@ -184,7 +185,7 @@ public class BasicAbstractAssemblyMojoFeaturesTest
}
public static final class FileLoggingArchiverStub
implements Archiver
extends NoOpArchiver
{
private Set files = new LinkedHashSet();
......@@ -264,67 +265,6 @@ public class BasicAbstractAssemblyMojoFeaturesTest
throw new ArchiverException( "Error scanning for file names.", e );
}
}
public void createArchive() throws ArchiverException, IOException
{
// TODO Auto-generated method stub
}
public int getDefaultDirectoryMode()
{
// TODO Auto-generated method stub
return 0;
}
public int getDefaultFileMode()
{
// TODO Auto-generated method stub
return 0;
}
public File getDestFile()
{
// TODO Auto-generated method stub
return null;
}
public Map getFiles()
{
// TODO Auto-generated method stub
return null;
}
public boolean getIncludeEmptyDirs()
{
// TODO Auto-generated method stub
return false;
}
public void setDefaultDirectoryMode( int arg0 )
{
// TODO Auto-generated method stub
}
public void setDefaultFileMode( int arg0 )
{
// TODO Auto-generated method stub
}
public void setDestFile( File arg0 )
{
// TODO Auto-generated method stub
}
public void setIncludeEmptyDirs( boolean arg0 )
{
// TODO Auto-generated method stub
}
}
public static final class TwoDependencyReactorProjectStub
......
package org.apache.maven.plugin.assembly;
import org.apache.maven.plugin.assembly.mojos.DirectoryInlineMojo;
import org.apache.maven.plugin.assembly.stubs.ArchiverManagerStub;
import org.apache.maven.plugin.testing.AbstractMojoTestCase;
import org.apache.maven.project.MavenProject;
import org.apache.maven.artifact.Artifact;
import java.io.File;
import java.util.Map;
import java.util.Set;
import java.util.Iterator;
/*
* Copyright 2001-2006 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.
*/
public class DirectoryInlineMojoTest
extends AbstractMojoTestCase
{
public void testAssemblyDirectory()
throws Exception
{
File testPom = new File( getBasedir(),
"src/test/plugin-configs/directory-inline/min-plugin-config.xml" );
DirectoryInlineMojo mojo = ( DirectoryInlineMojo ) lookupMojo( "directory-inline", testPom );
assertNotNull( mojo );
mojo.execute();
Map filesArchived = ArchiverManagerStub.archiverStub.getFiles();
Set files = filesArchived.keySet();
assertEquals( 1, files.size() );
}
public void testDependencySet()
throws Exception
{
File testPom = new File( getBasedir(),
"src/test/plugin-configs/directory-inline/dependency-set-plugin-config.xml" );
DirectoryInlineMojo mojo = ( DirectoryInlineMojo ) lookupMojo( "directory-inline", testPom );
assertNotNull( mojo );
MavenProject project = ( MavenProject ) getVariableValueFromObject( mojo, "project" );
Set artifacts = project.getArtifacts();
mojo.execute();
Map filesArchived = ArchiverManagerStub.archiverStub.getFiles();
Set files = filesArchived.keySet();
for( Iterator iter = artifacts.iterator(); iter.hasNext(); )
{
Artifact artifact = ( Artifact ) iter.next();
assertTrue( files.contains( artifact.getFile() ) );
assertTrue( artifact.getFile().getName().endsWith( ".jar" ) );
}
assertTrue( "Test project is in archive", files.contains( project.getArtifact().getFile() ) );
}
}
package org.apache.maven.plugin.assembly;
/*
* Copyright 2001-2005 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 org.apache.maven.plugin.assembly.mojos.DirectoryMojo;
import org.apache.maven.plugin.assembly.stubs.ArchiverManagerStub;
import org.apache.maven.plugin.testing.AbstractMojoTestCase;
import org.apache.maven.project.MavenProject;
import org.apache.maven.artifact.Artifact;
import java.io.File;
import java.util.Map;
import java.util.Set;
import java.util.Iterator;
/**
* @author Allan Q. Ramirez
*/
public class DirectoryMojoTest
extends AbstractMojoTestCase
{
public void testEnvironment()
throws Exception
{
File testPom = new File( getBasedir(),
"src/test/plugin-configs/directory/min-plugin-config.xml" );
DirectoryMojo mojo = ( DirectoryMojo ) lookupMojo( "directory", testPom );
assertNotNull( mojo );
}
public void testAssemblyDirectory()
throws Exception
{
File testPom = new File( getBasedir(),
"src/test/plugin-configs/directory/min-plugin-config.xml" );
DirectoryMojo mojo = ( DirectoryMojo ) lookupMojo( "directory", testPom );
assertNotNull( mojo );
AssemblyMojoTest.generateTestFileSets(getBasedir(), "\n");
mojo.execute();
Map filesArchived = ArchiverManagerStub.archiverStub.getFiles();
Set files = filesArchived.keySet();
assertEquals( 1, files.size() );
}
public void testAssemblyDirectoryWithAppendAssemblyIdAsFalse()
throws Exception
{
File testPom = new File( getBasedir(),
"src/test/plugin-configs/directory/appendAssemblyId-false-plugin-config.xml" );
DirectoryMojo mojo = ( DirectoryMojo ) lookupMojo( "directory", testPom );
assertNotNull( mojo );
String classifier = ( String ) getVariableValueFromObject( mojo, "classifier" );
String finalName = ( String ) getVariableValueFromObject( mojo, "finalName" );
File outputDir = ( File ) getVariableValueFromObject( mojo, "outputDirectory" );
MavenProject project = ( MavenProject ) getVariableValueFromObject( mojo, "executedProject" );
Set artifacts = project.getArtifacts();
mojo.execute();
File dir = new File( outputDir, finalName + "-" + classifier );
assertTrue( dir.exists() );
Map filesArchived = ArchiverManagerStub.archiverStub.getFiles();
Set files = filesArchived.keySet();
for( Iterator iter = artifacts.iterator(); iter.hasNext(); )
{
Artifact artifact = ( Artifact ) iter.next();
assertTrue( files.contains( artifact.getFile() ) );
assertTrue( artifact.getFile().getName().endsWith( ".jar" ) );
}
assertTrue( "Test project is in archive", files.contains( project.getArtifact().getFile() ) );
}
public void testAssemblyDirectoryWithDependencySet()
throws Exception
{
File testPom = new File( getBasedir(),
"src/test/plugin-configs/directory/dependency-set-plugin-config.xml" );
DirectoryMojo mojo = ( DirectoryMojo ) lookupMojo( "directory", testPom );
assertNotNull( mojo );
MavenProject project = ( MavenProject ) getVariableValueFromObject( mojo, "executedProject" );
Set artifacts = project.getArtifacts();
mojo.execute();
Map filesArchived = ArchiverManagerStub.archiverStub.getFiles();
Set files = filesArchived.keySet();
for( Iterator iter = artifacts.iterator(); iter.hasNext(); )
{
Artifact artifact = ( Artifact ) iter.next();
assertTrue( files.contains( artifact.getFile() ) );
assertTrue( artifact.getFile().getName().endsWith( ".jar" ) );
}
assertTrue( "Test project is in archive", files.contains( project.getArtifact().getFile() ) );
}
public void testAssemblyDirectoryToThrowNoSuchArchiverException()
throws Exception
{
File testPom = new File( getBasedir(),
"src/test/plugin-configs/directory/min-plugin-config-with-exceptions.xml" );
DirectoryMojo mojo = ( DirectoryMojo ) lookupMojo( "directory", testPom );
assertNotNull( mojo );
try
{
mojo.execute();
fail( "Failure Expected" );
}
catch( Exception e )
{
//expected
}
}
}
package org.apache.maven.plugin.assembly;
/*
* Copyright 2001-2006 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 org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.assembly.mojos.UnpackMojo;
import org.apache.maven.plugin.assembly.stubs.ArchiverManagerStub;
import org.apache.maven.plugin.assembly.stubs.UnArchiverWithException;
import org.apache.maven.plugin.testing.AbstractMojoTestCase;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.PlexusTestCase;
import org.codehaus.plexus.archiver.manager.NoSuchArchiverException;
import java.io.File;
/**
* @author Edwin Punzalan
*/
public class UnpackMojoTest
extends AbstractMojoTestCase
{
public void testMinConfiguration()
throws Exception
{
executeMojo( "min-plugin-config.xml" );
}
public void testMinConfigurationAgainWithoutClean()
throws Exception
{
executeMojo( "min-plugin-config.xml" );
}
public void testMinConfigurationWithReactorProjects()
throws Exception
{
executeMojo( "with-reactor-projects-plugin-config.xml" );
}
public void testArchiverManagerException()
throws Exception
{
try
{
UnpackMojo mojo = getMojo( "archiver-manager-exception-plugin-config.xml" );
mojo.execute();
MavenProject project = (MavenProject) getVariableValueFromObject( mojo, "project" );
String filename = project.getArtifact().getFile().getName();
String dir = filename.substring( 0, filename.lastIndexOf( '.' ) );
File workDir = (File) getVariableValueFromObject( mojo, "workDirectory" );
File unpackDir = new File( workDir, dir );
File unpacked = new File( unpackDir, filename + ".extracted" );
assertFalse( "Test extracted project artifact", unpacked.exists() );
}
catch ( NoSuchArchiverException e )
{
fail( "Expected exception in ArchiverManager should not fail the build" );
}
}
public void testUnpackException()
throws Exception
{
try
{
UnpackMojo mojo = getMojo( "unpack-exception-plugin-config.xml" );
ArchiverManagerStub archiverManager = (ArchiverManagerStub) getVariableValueFromObject( mojo, "archiverManager" );
archiverManager.setUnArchiver( new UnArchiverWithException() );
mojo.execute();
fail( "Expected exception not thrown" );
}
catch ( MojoExecutionException e )
{
//expected
}
}
public UnpackMojo getMojo( String pluginXml )
throws Exception
{
return (UnpackMojo) lookupMojo( "unpack", PlexusTestCase.getBasedir() +
"/src/test/plugin-configs/unpack/" + pluginXml );
}
public void executeMojo( String pluginXml )
throws Exception
{
UnpackMojo mojo = getMojo( pluginXml );
mojo.execute();
MavenProject project = (MavenProject) getVariableValueFromObject( mojo, "project" );
String filename = project.getArtifact().getFile().getName();
String dir = filename.substring( 0, filename.lastIndexOf( '.' ) );
File workDir = (File) getVariableValueFromObject( mojo, "workDirectory" );
File unpackDir = new File( workDir, dir );
File unpacked = new File( unpackDir, filename + ".extracted" );
assertTrue( "Test extracted project artifact", unpacked.exists() );
}
}
......@@ -20,7 +20,11 @@ package org.apache.maven.plugin.assembly.interpolation;
*/
import junit.framework.TestCase;
import org.apache.maven.model.Model;
import org.apache.maven.plugins.assembly.interpolation.AssemblyInterpolationException;
import org.apache.maven.plugins.assembly.interpolation.AssemblyInterpolator;
import org.apache.maven.plugins.assembly.io.DefaultAssemblyReader;
import org.apache.maven.plugins.assembly.model.Assembly;
import org.apache.maven.plugins.assembly.model.DependencySet;
......@@ -28,9 +32,7 @@ import java.io.IOException;
import java.util.Collections;
import java.util.List;
import junit.framework.TestCase;
public class AssemblyInterpolatorTest
public class AssemblyInterpolator2Test
extends TestCase
{
......@@ -51,7 +53,8 @@ public class AssemblyInterpolatorTest
assembly.addDependencySet( set );
Assembly outputAssembly = interpolator.interpolate( assembly, model, Collections.EMPTY_MAP );
Assembly outputAssembly = interpolator.interpolate( assembly, model, Collections.EMPTY_MAP,
DefaultAssemblyReader.create(model));
List outputDependencySets = outputAssembly.getDependencySets();
assertEquals( 1, outputDependencySets.size() );
......
......@@ -15,4 +15,4 @@
# specific language governing permissions and limitations
# under the License.
invoker.goals=package org.apache.maven.plugins:maven-assembly-plugin:${testVersion}:directory
invoker.goals=install