You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by sn...@apache.org on 2006/10/15 21:25:40 UTC
svn commit: r464259 - in /maven/plugins/trunk/maven-ear-plugin: ./
src/main/java/org/apache/maven/plugin/ear/
src/test/java/org/apache/maven/plugin/ear/
src/test/resources/m2repo/eartest/sar-sample-one/
src/test/resources/m2repo/eartest/sar-sample-one/...
Author: snicoll
Date: Sun Oct 15 12:25:39 2006
New Revision: 464259
URL: http://svn.apache.org/viewvc?view=rev&rev=464259
Log:
MEAR-33: fixed broken unpacking with non standard types (sar mainly)
Added:
maven/plugins/trunk/maven-ear-plugin/src/test/resources/m2repo/eartest/sar-sample-one/
maven/plugins/trunk/maven-ear-plugin/src/test/resources/m2repo/eartest/sar-sample-one/1.0/
maven/plugins/trunk/maven-ear-plugin/src/test/resources/m2repo/eartest/sar-sample-one/1.0/sar-sample-one-1.0.pom (with props)
maven/plugins/trunk/maven-ear-plugin/src/test/resources/m2repo/eartest/sar-sample-one/1.0/sar-sample-one-1.0.sar (with props)
maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-04/
maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-04/pom.xml (with props)
Modified:
maven/plugins/trunk/maven-ear-plugin/pom.xml
maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/EarMojo.java
maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugin/ear/AbstractEarPluginTestCase.java
maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugin/ear/EarMojoTest.java
Modified: maven/plugins/trunk/maven-ear-plugin/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/pom.xml?view=diff&rev=464259&r1=464258&r2=464259
==============================================================================
--- maven/plugins/trunk/maven-ear-plugin/pom.xml (original)
+++ maven/plugins/trunk/maven-ear-plugin/pom.xml Sun Oct 15 12:25:39 2006
@@ -2,7 +2,7 @@
<parent>
<artifactId>maven-plugins</artifactId>
<groupId>org.apache.maven.plugins</groupId>
- <version>2-SNAPSHOT</version>
+ <version>4-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>maven-ear-plugin</artifactId>
Modified: maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/EarMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/EarMojo.java?view=diff&rev=464259&r1=464258&r2=464259
==============================================================================
--- maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/EarMojo.java (original)
+++ maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/EarMojo.java Sun Oct 15 12:25:39 2006
@@ -22,6 +22,7 @@
import org.apache.maven.plugin.MojoFailureException;
import org.codehaus.plexus.archiver.ArchiverException;
import org.codehaus.plexus.archiver.UnArchiver;
+import org.codehaus.plexus.archiver.Archiver;
import org.codehaus.plexus.archiver.jar.JarArchiver;
import org.codehaus.plexus.archiver.manager.ArchiverManager;
import org.codehaus.plexus.archiver.manager.NoSuchArchiverException;
@@ -379,7 +380,7 @@
public void unpack( File source, File destDir )
throws NoSuchArchiverException, IOException, ArchiverException
{
- UnArchiver unArchiver = archiverManager.getUnArchiver( source );
+ UnArchiver unArchiver = archiverManager.getUnArchiver( "zip" );
unArchiver.setSourceFile( source );
unArchiver.setDestDirectory( destDir );
Modified: maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugin/ear/AbstractEarPluginTestCase.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugin/ear/AbstractEarPluginTestCase.java?view=diff&rev=464259&r1=464258&r2=464259
==============================================================================
--- maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugin/ear/AbstractEarPluginTestCase.java (original)
+++ maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugin/ear/AbstractEarPluginTestCase.java Sun Oct 15 12:25:39 2006
@@ -94,6 +94,39 @@
return basedir;
}
+
+ /**
+ * Executes the specified projects and asserts the given artifacts.
+ *
+ * @param projectName the project to test
+ * @param expectedArtifacts the list of artifacts to be found in the EAR archive
+ * @param artifactsDirectory whether the artifact is an exploded artifactsDirectory or not
+ * @throws Exception
+ */
+ protected void doTestProject( final String projectName, final String[] expectedArtifacts,
+ final boolean[] artifactsDirectory )
+ throws Exception
+ {
+ final File baseDir = executeMojo( projectName, new Properties() );
+
+ assertArchiveContent( baseDir, projectName, expectedArtifacts, artifactsDirectory );
+
+ }
+
+ /**
+ * Executes the specified projects and asserts the given artifacts as
+ * artifacts (non directory)
+ *
+ * @param projectName the project to test
+ * @param expectedArtifacts the list of artifacts to be found in the EAR archive
+ * @throws Exception
+ */
+ protected void doTestProject( final String projectName, final String[] expectedArtifacts )
+ throws Exception
+ {
+ doTestProject( projectName, expectedArtifacts, new boolean[expectedArtifacts.length] );
+ }
+
protected void assertEarArchive( final File baseDir, final String projectName )
{
assertTrue( "EAR archive does not exist", getEarArchive( baseDir, projectName ).exists() );
@@ -124,16 +157,27 @@
return FINAL_NAME_PREFIX + projectName + FINAL_NAME_SUFFIX;
}
- protected void assertArchiveContent( final File baseDir, final String projectName, final String[] artifactNames )
+ protected void assertArchiveContent( final File baseDir, final String projectName, final String[] artifactNames,
+ final boolean[] artifactsDirectory )
{
+ // sanity check
+ assertEquals( "Wrong parameter, artifacts mist match directory flag", artifactNames.length,
+ artifactsDirectory.length );
+
File dir = getEarDirectory( baseDir, projectName );
final List actualFiles = buildFiles( dir );
assertEquals( "Artifacts mismatch " + actualFiles, artifactNames.length, actualFiles.size() );
for ( int i = 0; i < artifactNames.length; i++ )
{
String artifactName = artifactNames[i];
- File expectedFile = new File(dir, artifactName);
- assertTrue("Artifact["+artifactName+"] not found in ear archive", actualFiles.contains( expectedFile));
+ final boolean isDirectory = artifactsDirectory[i];
+ File expectedFile = new File( dir, artifactName );
+
+ assertEquals( "Artifact[" + artifactName + "] not in the right form (exploded/archive", isDirectory,
+ expectedFile.isDirectory() );
+ assertTrue( "Artifact[" + artifactName + "] not found in ear archive",
+ actualFiles.contains( expectedFile ) );
+
}
}
@@ -166,14 +210,11 @@
for ( int i = 0; i < result.length; i++ )
{
File file = result[i];
- if ( file.isFile() )
- {
- files.add( file );
- }
- else
- {
- addFiles( file, files );
- }
+ files.add( file );
+ /*
+ Here's we can introduce a more complex
+ file filtering if necessary
+ */
}
}
}
Modified: maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugin/ear/EarMojoTest.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugin/ear/EarMojoTest.java?view=diff&rev=464259&r1=464258&r2=464259
==============================================================================
--- maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugin/ear/EarMojoTest.java (original)
+++ maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugin/ear/EarMojoTest.java Sun Oct 15 12:25:39 2006
@@ -40,14 +40,16 @@
doTestProject( "project-03", new String[]{"ejb-sample-one-1.0-classified.jar"} );
}
- protected void doTestProject( final String projectName, final String[] expectedArtifacts )
+ /**
+ * Test the classifier functionnality
+ */
+ public void testProject04()
throws Exception
{
- final File baseDir = executeMojo( projectName, new Properties() );
+ doTestProject( "project-04", new String[]{"ejb-sample-one-1.0.jar","sar-sample-one-1.0.sar"}, new boolean[]{false, true});
+ }
- assertArchiveContent( baseDir, projectName, expectedArtifacts );
- }
}
Added: maven/plugins/trunk/maven-ear-plugin/src/test/resources/m2repo/eartest/sar-sample-one/1.0/sar-sample-one-1.0.pom
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/test/resources/m2repo/eartest/sar-sample-one/1.0/sar-sample-one-1.0.pom?view=auto&rev=464259
==============================================================================
--- maven/plugins/trunk/maven-ear-plugin/src/test/resources/m2repo/eartest/sar-sample-one/1.0/sar-sample-one-1.0.pom (added)
+++ maven/plugins/trunk/maven-ear-plugin/src/test/resources/m2repo/eartest/sar-sample-one/1.0/sar-sample-one-1.0.pom Sun Oct 15 12:25:39 2006
@@ -0,0 +1,10 @@
+<project>
+ <modelVersion>4.0.0</modelVersion>
+ <groupId>eartest</groupId>
+ <artifactId>sar-sample-one</artifactId>
+ <packaging>sar</packaging>
+ <version>1.0</version>
+ <distributionManagement>
+ <status>verified</status>
+ </distributionManagement>
+</project>
Propchange: maven/plugins/trunk/maven-ear-plugin/src/test/resources/m2repo/eartest/sar-sample-one/1.0/sar-sample-one-1.0.pom
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/plugins/trunk/maven-ear-plugin/src/test/resources/m2repo/eartest/sar-sample-one/1.0/sar-sample-one-1.0.pom
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision
Added: maven/plugins/trunk/maven-ear-plugin/src/test/resources/m2repo/eartest/sar-sample-one/1.0/sar-sample-one-1.0.sar
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/test/resources/m2repo/eartest/sar-sample-one/1.0/sar-sample-one-1.0.sar?view=auto&rev=464259
==============================================================================
Binary file - no diff available.
Propchange: maven/plugins/trunk/maven-ear-plugin/src/test/resources/m2repo/eartest/sar-sample-one/1.0/sar-sample-one-1.0.sar
------------------------------------------------------------------------------
svn:mime-type = application/octet-stream
Added: maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-04/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-04/pom.xml?view=auto&rev=464259
==============================================================================
--- maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-04/pom.xml (added)
+++ maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-04/pom.xml Sun Oct 15 12:25:39 2006
@@ -0,0 +1,36 @@
+<?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>ear</groupId>
+ <artifactId>maven-ear-plugin-test-project-04</artifactId>
+ <version>99.0</version>
+ <name>Maven</name>
+ <packaging>ear</packaging>
+ <dependencies>
+ <dependency>
+ <groupId>eartest</groupId>
+ <artifactId>ejb-sample-one</artifactId>
+ <version>1.0</version>
+ <type>ejb</type>
+ </dependency>
+ <dependency>
+ <groupId>eartest</groupId>
+ <artifactId>sar-sample-one</artifactId>
+ <version>1.0</version>
+ <type>sar</type>
+ </dependency>
+ </dependencies>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-ear-plugin</artifactId>
+ <configuration>
+ <displayName>Sample Ear Application</displayName>
+ <unpackTypes>sar</unpackTypes>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+</project>
Propchange: maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-04/pom.xml
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-04/pom.xml
------------------------------------------------------------------------------
svn:keywords = Author Date Id Revision