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/11 06:25:59 UTC

svn commit: r462692 - in /maven/plugins/trunk/maven-ear-plugin/src: main/java/org/apache/maven/plugin/ear/ test/java/org/apache/maven/plugin/ear/ test/resources/m2repo/eartest/ejb-sample-one/1.0/ test/resources/projects/project-03/

Author: snicoll
Date: Tue Oct 10 21:25:58 2006
New Revision: 462692

URL: http://svn.apache.org/viewvc?view=rev&rev=462692
Log:
MEAR-44: Added test case for the classifier attribute of a dependency.

Added:
    maven/plugins/trunk/maven-ear-plugin/src/test/resources/m2repo/eartest/ejb-sample-one/1.0/ejb-sample-one-1.0-classified.jar
    maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-03/
    maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-03/pom.xml   (with props)
Modified:
    maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/AbstractEarModule.java
    maven/plugins/trunk/maven-ear-plugin/src/test/java/org/apache/maven/plugin/ear/EarMojoTest.java

Modified: maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/AbstractEarModule.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/AbstractEarModule.java?view=diff&rev=462692&r1=462691&r2=462692
==============================================================================
--- maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/AbstractEarModule.java (original)
+++ maven/plugins/trunk/maven-ear-plugin/src/main/java/org/apache/maven/plugin/ear/AbstractEarModule.java Tue Oct 10 21:25:58 2006
@@ -76,8 +76,10 @@
     public void resolveArtifact( Set artifacts )
         throws EarPluginException, MojoFailureException
     {
+        // If the artifact is already set no need to resolve it
         if ( artifact == null )
         {
+            // Make sure that at least the groupId and the artifactId are specified
             if ( groupId == null || artifactId == null )
             {
                 throw new MojoFailureException(
@@ -88,6 +90,9 @@
             while ( i.hasNext() )
             {
                 Artifact a = (Artifact) i.next();
+
+                // If the groupId, the artifactId, the classifier matches and if the
+                // artifact's type is known, then we have found it.
                 if ( a.getGroupId().equals( groupId ) && a.getArtifactId().equals( artifactId ) &&
                     ArtifactTypeMappingService.getInstance().isMappedToType( getType(), a.getType() ) )
                 {
@@ -95,10 +100,8 @@
                     return;
                 }
             }
-
             // Artifact has not been found
-            throw new MojoFailureException( "Artifact[" + groupId + ":" + artifactId + ":" + getType() + "] " +
-                "is not a dependency of the project." );
+            throw new MojoFailureException( "Artifact[" + this + "] " + "is not a dependency of the project." );
         }
         else
         {

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=462692&r1=462691&r2=462692
==============================================================================
--- 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 Tue Oct 10 21:25:58 2006
@@ -11,7 +11,8 @@
  * @author $Author: sni $ (last edit)
  * @version $Revision: 1.5 $
  */
-public class EarMojoTest extends AbstractEarPluginTestCase
+public class EarMojoTest
+    extends AbstractEarPluginTestCase
 {
 
     /**
@@ -20,7 +21,7 @@
     public void testProject01()
         throws Exception
     {
-         doTestProject( "project-01", new String[]{"ejb-sample-one-1.0.jar"});
+        doTestProject( "project-01", new String[]{"ejb-sample-one-1.0.jar"} );
     }
 
     public void testProject02()
@@ -30,15 +31,23 @@
         //doTestProject( "project-02", new String[]{"APP-INF/lib/ejb-sample-one-1.0.jar, ejb-sample-two.jar"});
     }
 
-    protected void doTestProject(final String projectName, final String[] expectedArtifacts)
+    /**
+     * Test the classifier functionnality
+     */
+    public void testProject03()
         throws Exception
     {
-        final File baseDir = executeMojo(projectName, new Properties());
+        doTestProject( "project-03", new String[]{"ejb-sample-one-1.0-classified.jar"} );
+    }
 
-        assertArchiveContent(baseDir, projectName,expectedArtifacts);
+    protected void doTestProject( final String projectName, final String[] expectedArtifacts )
+        throws Exception
+    {
+        final File baseDir = executeMojo( projectName, new Properties() );
 
-    }
+        assertArchiveContent( baseDir, projectName, expectedArtifacts );
 
+    }
 
 
 }

Added: maven/plugins/trunk/maven-ear-plugin/src/test/resources/m2repo/eartest/ejb-sample-one/1.0/ejb-sample-one-1.0-classified.jar
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/test/resources/m2repo/eartest/ejb-sample-one/1.0/ejb-sample-one-1.0-classified.jar?view=auto&rev=462692
==============================================================================
--- maven/plugins/trunk/maven-ear-plugin/src/test/resources/m2repo/eartest/ejb-sample-one/1.0/ejb-sample-one-1.0-classified.jar (added)
+++ maven/plugins/trunk/maven-ear-plugin/src/test/resources/m2repo/eartest/ejb-sample-one/1.0/ejb-sample-one-1.0-classified.jar Tue Oct 10 21:25:58 2006
@@ -0,0 +1,2 @@
+-testfile-not a valid jar-
+-testfile-not a valid jar-

Added: maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-03/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-03/pom.xml?view=auto&rev=462692
==============================================================================
--- maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-03/pom.xml (added)
+++ maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-03/pom.xml Tue Oct 10 21:25:58 2006
@@ -0,0 +1,30 @@
+<?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-03</artifactId>
+  <version>99.0</version>
+  <name>Maven</name>
+  <packaging>ear</packaging>
+  <dependencies>
+    <dependency>
+      <groupId>eartest</groupId>
+      <artifactId>ejb-sample-one</artifactId>
+      <classifier>classified</classifier>
+      <version>1.0</version>
+      <type>ejb</type>
+    </dependency>
+  </dependencies>
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-ear-plugin</artifactId>        
+        <configuration>
+          <displayName>Sample Ear Application</displayName>         
+        </configuration>
+      </plugin>
+    </plugins>
+  </build>
+</project>

Propchange: maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-03/pom.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: maven/plugins/trunk/maven-ear-plugin/src/test/resources/projects/project-03/pom.xml
------------------------------------------------------------------------------
    svn:keywords = Author Date Id Revision