You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by br...@apache.org on 2006/05/14 22:33:32 UTC

svn commit: r406419 - in /maven/plugins/trunk/maven-war-plugin: ./ src/main/java/org/apache/maven/plugin/war/ src/main/resources/ src/test/java/org/apache/maven/plugin/war/ src/test/java/org/apache/maven/plugin/war/stub/ src/test/resources/unit/sample_...

Author: brett
Date: Sun May 14 13:33:32 2006
New Revision: 406419

URL: http://svn.apache.org/viewcvs?rev=406419&view=rev
Log:
[MWAR-38] fix filenames of included ejbs, etc

Added:
    maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/stub/EJBClientArtifactStub.java
      - copied, changed from r406177, maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/stub/EJBArtifactStub.java
    maven/plugins/trunk/maven-war-plugin/src/test/resources/unit/sample_wars/ejbclient.jar
Removed:
    maven/plugins/trunk/maven-war-plugin/src/main/resources/
Modified:
    maven/plugins/trunk/maven-war-plugin/pom.xml
    maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/AbstractWarMojo.java
    maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/WarExplodedMojoTest.java
    maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/stub/AbstractArtifactStub.java
    maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/stub/EJBArtifactStub.java

Modified: maven/plugins/trunk/maven-war-plugin/pom.xml
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-war-plugin/pom.xml?rev=406419&r1=406418&r2=406419&view=diff
==============================================================================
--- maven/plugins/trunk/maven-war-plugin/pom.xml (original)
+++ maven/plugins/trunk/maven-war-plugin/pom.xml Sun May 14 13:33:32 2006
@@ -8,7 +8,7 @@
   <artifactId>maven-war-plugin</artifactId>
   <packaging>maven-plugin</packaging>
   <name>Maven War Plugin</name>
-  <version>2.1-SNAPSHOT</version>
+  <version>2.0.1-SNAPSHOT</version>
   <dependencies>
     <dependency>
       <groupId>org.apache.maven</groupId>

Modified: maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/AbstractWarMojo.java
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/AbstractWarMojo.java?rev=406419&r1=406418&r2=406419&view=diff
==============================================================================
--- maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/AbstractWarMojo.java (original)
+++ maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/AbstractWarMojo.java Sun May 14 13:33:32 2006
@@ -809,7 +809,7 @@
         {
             // fix for MWAR-36, ensures that the parent dir are created first
             to.getParentFile().mkdirs();
-            
+
             if ( encoding == null || encoding.length() < 1 )
             {
                 fileReader = new BufferedReader( new FileReader( from ) );
@@ -941,7 +941,8 @@
      */
     private String getDefaultFinalName( Artifact artifact )
     {
-        return artifact.getArtifactId() + "-" + artifact.getVersion() + "." + artifact.getType();
+        return artifact.getArtifactId() + "-" + artifact.getVersion() + "." +
+            artifact.getArtifactHandler().getExtension();
     }
 
 }

Modified: maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/WarExplodedMojoTest.java
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/WarExplodedMojoTest.java?rev=406419&r1=406418&r2=406419&view=diff
==============================================================================
--- maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/WarExplodedMojoTest.java (original)
+++ maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/WarExplodedMojoTest.java Sun May 14 13:33:32 2006
@@ -16,13 +16,8 @@
  * limitations under the License.
  */
 
-import java.io.File;
-import java.io.FileReader;
-import java.io.FileWriter;
-import java.util.LinkedList;
-import java.util.StringTokenizer;
-
 import org.apache.maven.plugin.war.stub.EJBArtifactStub;
+import org.apache.maven.plugin.war.stub.EJBClientArtifactStub;
 import org.apache.maven.plugin.war.stub.IncludeExcludeWarArtifactStub;
 import org.apache.maven.plugin.war.stub.MavenProjectArtifactsStub;
 import org.apache.maven.plugin.war.stub.MavenProjectBasicStub;
@@ -31,11 +26,17 @@
 import org.apache.maven.plugin.war.stub.SimpleWarArtifactStub;
 import org.apache.maven.plugin.war.stub.TLDArtifactStub;
 
+import java.io.File;
+import java.io.FileReader;
+import java.io.FileWriter;
+import java.util.LinkedList;
+import java.util.StringTokenizer;
+
 public class WarExplodedMojoTest
     extends AbstractWarMojoTest
 {
-    protected static final String pomFilePath = getBasedir()
-        + "/target/test-classes/unit/warexplodedmojo/plugin-config.xml";
+    protected static final String pomFilePath =
+        getBasedir() + "/target/test-classes/unit/warexplodedmojo/plugin-config.xml";
 
     private WarExplodedMojo mojo;
 
@@ -61,7 +62,6 @@
     }
 
     /**
-     * 
      * @throws Exception
      */
     public void testSimpleExplodedWar()
@@ -75,7 +75,7 @@
         File webAppResource = new File( getTestDirectory(), "resources" );
         File webAppDirectory = new File( getTestDirectory(), testId );
         File sampleResource = new File( webAppResource, "pix/panis_na.jpg" );
-        ResourceStub[] resources = new ResourceStub[] { new ResourceStub() };
+        ResourceStub[] resources = new ResourceStub[]{new ResourceStub()};
 
         createFile( sampleResource );
 
@@ -100,7 +100,6 @@
     }
 
     /**
-     * 
      * @throws Exception
      */
     public void testExplodedWar_WithCustomWebXML()
@@ -111,7 +110,7 @@
         MavenProjectBasicStub project = new MavenProjectBasicStub();
         File webAppSource = createWebAppSource( testId );
         File classesDir = createClassesDir( testId, true );
-        File xmlSource = createXMLConfigDir( testId, new String[] { "web.xml" } );
+        File xmlSource = createXMLConfigDir( testId, new String[]{"web.xml"} );
         File webAppDirectory = new File( getTestDirectory(), testId );
 
         // configure mojo
@@ -132,7 +131,6 @@
     }
 
     /**
-     * 
      * @throws Exception
      */
     public void testExplodedWar_WithContainerConfigXML()
@@ -143,7 +141,7 @@
         MavenProjectBasicStub project = new MavenProjectBasicStub();
         File classesDir = createClassesDir( testId, true );
         File webAppSource = createWebAppSource( testId );
-        File xmlSource = createXMLConfigDir( testId, new String[] { "config.xml" } );
+        File xmlSource = createXMLConfigDir( testId, new String[]{"config.xml"} );
         File webAppDirectory = new File( getTestDirectory(), testId );
 
         // configure mojo
@@ -165,7 +163,6 @@
     }
 
     /**
-     * 
      * @throws Exception
      */
     public void testExplodedWar_WithSimpleExternalWARFile()
@@ -208,7 +205,6 @@
     }
 
     /**
-     * 
      * @throws Exception
      */
     public void testExplodedWar_WithEJB()
@@ -234,7 +230,40 @@
         File expectedWebSourceFile = new File( webAppDirectory, "pansit.jsp" );
         File expectedWebSource2File = new File( webAppDirectory, "org/web/app/last-exile.jsp" );
         // final name form is <artifactId>-<version>.<type>
-        File expectedEJBArtifact = new File( webAppDirectory, "WEB-INF/lib/ejbartifact-0.0-Test.ejb" );
+        File expectedEJBArtifact = new File( webAppDirectory, "WEB-INF/lib/ejbartifact-0.0-Test.jar" );
+
+        assertTrue( "source files not found: " + expectedWebSourceFile.toString(), expectedWebSourceFile.exists() );
+        assertTrue( "source files not found: " + expectedWebSource2File.toString(), expectedWebSource2File.exists() );
+        assertTrue( "ejb artifact not found: " + expectedEJBArtifact.toString(), expectedEJBArtifact.exists() );
+    }
+
+    /**
+     * @throws Exception
+     */
+    public void testExplodedWar_WithEJBClient()
+        throws Exception
+    {
+        // setup test data
+        String testId = "ExplodedWar_WithEJB";
+        MavenProjectArtifactsStub project = new MavenProjectArtifactsStub();
+        File webAppDirectory = new File( getTestDirectory(), testId );
+        File webAppSource = createWebAppSource( testId );
+        File classesDir = createClassesDir( testId, true );
+        EJBClientArtifactStub ejbArtifact = new EJBClientArtifactStub( getBasedir() );
+        File ejbFile = ejbArtifact.getFile();
+
+        assertTrue( "ejb jar not found: " + ejbFile.toString(), ejbFile.exists() );
+
+        // configure mojo
+        project.addArtifact( ejbArtifact );
+        this.configureMojo( mojo, new LinkedList(), classesDir, webAppSource, webAppDirectory, project );
+        mojo.execute();
+
+        // validate operation
+        File expectedWebSourceFile = new File( webAppDirectory, "pansit.jsp" );
+        File expectedWebSource2File = new File( webAppDirectory, "org/web/app/last-exile.jsp" );
+        // final name form is <artifactId>-<version>.<type>
+        File expectedEJBArtifact = new File( webAppDirectory, "WEB-INF/lib/ejbclientartifact-0.0-Test.jar" );
 
         assertTrue( "source files not found: " + expectedWebSourceFile.toString(), expectedWebSourceFile.exists() );
         assertTrue( "source files not found: " + expectedWebSource2File.toString(), expectedWebSource2File.exists() );
@@ -242,7 +271,6 @@
     }
 
     /**
-     * 
      * @throws Exception
      */
     public void testExplodedWar_WithTLD()
@@ -276,7 +304,6 @@
     }
 
     /**
-     * 
      * @throws Exception
      */
     public void testExplodedWar_WithPAR()
@@ -310,7 +337,6 @@
     }
 
     /**
-     * 
      * @throws Exception
      */
     public void testExplodedWar_WithDuplicateDependencies()
@@ -341,17 +367,17 @@
         File expectedWebSourceFile = new File( webAppDirectory, "pansit.jsp" );
         File expectedWebSource2File = new File( webAppDirectory, "org/web/app/last-exile.jsp" );
         // final name form is <artifactId>-<version>.<type>
-        File expectedEJBArtifact = new File( webAppDirectory, "WEB-INF/lib/org.sample.ejb-ejbartifact-0.0-Test.ejb" );
-        File expectedEJBDupArtifact = new File( webAppDirectory, "WEB-INF/lib/org.dup.ejb-ejbartifact-0.0-Test.ejb" );
+        File expectedEJBArtifact = new File( webAppDirectory, "WEB-INF/lib/org.sample.ejb-ejbartifact-0.0-Test.jar" );
+        File expectedEJBDupArtifact = new File( webAppDirectory, "WEB-INF/lib/org.dup.ejb-ejbartifact-0.0-Test.jar" );
 
         assertTrue( "source files not found: " + expectedWebSourceFile.toString(), expectedWebSourceFile.exists() );
         assertTrue( "source files not found: " + expectedWebSource2File.toString(), expectedWebSource2File.exists() );
         assertTrue( "ejb artifact not found: " + expectedEJBArtifact.toString(), expectedEJBArtifact.exists() );
-        assertTrue( "ejb dup artifact not found: " + expectedEJBDupArtifact.toString(), expectedEJBDupArtifact.exists() );
+        assertTrue( "ejb dup artifact not found: " + expectedEJBDupArtifact.toString(),
+                    expectedEJBDupArtifact.exists() );
     }
 
     /**
-     * 
      * @throws Exception
      */
     public void testExplodedWar_WithClasses()
@@ -380,7 +406,6 @@
     }
 
     /**
-     * 
      * @throws Exception
      */
     public void testExplodedWar_WithResourceFiltering()
@@ -397,7 +422,7 @@
         File sampleResourceWDir = new File( webAppResource, "custom-config/custom-setting.cfg" );
         File filterFile = new File( getTestDirectory(), testId + "-test-data/filters/filter.properties" );
         LinkedList filterList = new LinkedList();
-        ResourceStub[] resources = new ResourceStub[] { new ResourceStub() };
+        ResourceStub[] resources = new ResourceStub[]{new ResourceStub()};
 
         createFile( sampleResource );
         createFile( sampleResourceWDir );
@@ -455,8 +480,8 @@
         assertTrue( "error in filtering using filter files", token.equals( "resource_key=this_is_filtered" ) );
 
         token = tokenizer.nextToken();
-        assertTrue( "error in filtering using System properties", token.equals( "system_key="
-            + System.getProperty( "user.dir" ) ) );
+        assertTrue( "error in filtering using System properties",
+                    token.equals( "system_key=" + System.getProperty( "user.dir" ) ) );
 
         token = tokenizer.nextToken();
         assertTrue( "error in filtering using project properties", token.equals( "project_key=i_think_so" ) );
@@ -533,30 +558,30 @@
     }
 
     public void testExplodedWarWithSourceModificationCheck()
-    throws Exception
-{
-    // setup test data
-    String testId = "ExplodedWarWithSourceModificationCheck";
-    MavenProjectBasicStub project = new MavenProjectBasicStub();
-    File webAppSource = createWebAppSource( testId );
-    File classesDir = createClassesDir( testId, false );
-    File webAppDirectory = new File( getTestDirectory(), testId );
-
-    // configure mojo
-    this.configureMojo( mojo, new LinkedList(), classesDir, webAppSource, webAppDirectory, project );
-    mojo.execute();
-
-    // validate operation
-    File expectedWebSourceFile = new File( webAppDirectory, "pansit.jsp" );
-    File expectedWebSource2File = new File( webAppDirectory, "org/web/app/last-exile.jsp" );
-    File expectedWEBINFDir = new File( webAppDirectory, "WEB-INF" );
-    File expectedMETAINFDir = new File( webAppDirectory, "META-INF" );
-
-    assertTrue( "source files not found: " + expectedWebSourceFile.toString(), expectedWebSourceFile.exists() );
-    assertTrue( "source files not found: " + expectedWebSource2File.toString(), expectedWebSource2File.exists() );
-    assertTrue( "WEB-INF not found", expectedWEBINFDir.exists() );
-    assertTrue( "META-INF not found", expectedMETAINFDir.exists() );
-}
-    
-    
+        throws Exception
+    {
+        // setup test data
+        String testId = "ExplodedWarWithSourceModificationCheck";
+        MavenProjectBasicStub project = new MavenProjectBasicStub();
+        File webAppSource = createWebAppSource( testId );
+        File classesDir = createClassesDir( testId, false );
+        File webAppDirectory = new File( getTestDirectory(), testId );
+
+        // configure mojo
+        this.configureMojo( mojo, new LinkedList(), classesDir, webAppSource, webAppDirectory, project );
+        mojo.execute();
+
+        // validate operation
+        File expectedWebSourceFile = new File( webAppDirectory, "pansit.jsp" );
+        File expectedWebSource2File = new File( webAppDirectory, "org/web/app/last-exile.jsp" );
+        File expectedWEBINFDir = new File( webAppDirectory, "WEB-INF" );
+        File expectedMETAINFDir = new File( webAppDirectory, "META-INF" );
+
+        assertTrue( "source files not found: " + expectedWebSourceFile.toString(), expectedWebSourceFile.exists() );
+        assertTrue( "source files not found: " + expectedWebSource2File.toString(), expectedWebSource2File.exists() );
+        assertTrue( "WEB-INF not found", expectedWEBINFDir.exists() );
+        assertTrue( "META-INF not found", expectedMETAINFDir.exists() );
+    }
+
+
 }

Modified: maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/stub/AbstractArtifactStub.java
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/stub/AbstractArtifactStub.java?rev=406419&r1=406418&r2=406419&view=diff
==============================================================================
--- maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/stub/AbstractArtifactStub.java (original)
+++ maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/stub/AbstractArtifactStub.java Sun May 14 13:33:32 2006
@@ -16,6 +16,9 @@
  * limitations under the License.
  */
 
+import org.apache.maven.artifact.Artifact;
+import org.apache.maven.artifact.handler.ArtifactHandler;
+import org.apache.maven.artifact.handler.DefaultArtifactHandler;
 import org.apache.maven.plugin.testing.stubs.ArtifactStub;
 
 public abstract class AbstractArtifactStub
@@ -35,11 +38,16 @@
 
     public String getScope()
     {
-        return ArtifactStub.SCOPE_RUNTIME;
+        return Artifact.SCOPE_RUNTIME;
     }
 
     public boolean isOptional()
     {
         return false;
+    }
+
+    public ArtifactHandler getArtifactHandler()
+    {
+        return new DefaultArtifactHandler( getType() );
     }
 }

Modified: maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/stub/EJBArtifactStub.java
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/stub/EJBArtifactStub.java?rev=406419&r1=406418&r2=406419&view=diff
==============================================================================
--- maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/stub/EJBArtifactStub.java (original)
+++ maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/stub/EJBArtifactStub.java Sun May 14 13:33:32 2006
@@ -16,6 +16,9 @@
  * limitations under the License.
  */
 
+import org.apache.maven.artifact.handler.ArtifactHandler;
+import org.apache.maven.artifact.handler.DefaultArtifactHandler;
+
 import java.io.File;
 
 public class EJBArtifactStub
@@ -58,5 +61,16 @@
     public File getFile()
     {
         return new File( basedir, "/target/test-classes/unit/sample_wars/ejb.jar" );
+    }
+
+    public ArtifactHandler getArtifactHandler()
+    {
+        return new DefaultArtifactHandler()
+        {
+            public String getExtension()
+            {
+                return "jar";
+            }
+        };
     }
 }

Copied: maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/stub/EJBClientArtifactStub.java (from r406177, maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/stub/EJBArtifactStub.java)
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/stub/EJBClientArtifactStub.java?p2=maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/stub/EJBClientArtifactStub.java&p1=maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/stub/EJBArtifactStub.java&r1=406177&r2=406419&rev=406419&view=diff
==============================================================================
--- maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/stub/EJBArtifactStub.java (original)
+++ maven/plugins/trunk/maven-war-plugin/src/test/java/org/apache/maven/plugin/war/stub/EJBClientArtifactStub.java Sun May 14 13:33:32 2006
@@ -16,14 +16,17 @@
  * limitations under the License.
  */
 
+import org.apache.maven.artifact.handler.ArtifactHandler;
+import org.apache.maven.artifact.handler.DefaultArtifactHandler;
+
 import java.io.File;
 
-public class EJBArtifactStub
+public class EJBClientArtifactStub
     extends AbstractArtifactStub
 {
     protected String groupId;
 
-    public EJBArtifactStub( String _basedir )
+    public EJBClientArtifactStub( String _basedir )
     {
         super( _basedir );
     }
@@ -47,16 +50,27 @@
 
     public String getType()
     {
-        return "ejb";
+        return "ejb-client";
     }
 
     public String getArtifactId()
     {
-        return "ejbartifact";
+        return "ejbclientartifact";
     }
 
     public File getFile()
     {
-        return new File( basedir, "/target/test-classes/unit/sample_wars/ejb.jar" );
+        return new File( basedir, "/target/test-classes/unit/sample_wars/ejbclient.jar" );
+    }
+
+    public ArtifactHandler getArtifactHandler()
+    {
+        return new DefaultArtifactHandler()
+        {
+            public String getExtension()
+            {
+                return "jar";
+            }
+        };
     }
 }

Added: maven/plugins/trunk/maven-war-plugin/src/test/resources/unit/sample_wars/ejbclient.jar
URL: http://svn.apache.org/viewcvs/maven/plugins/trunk/maven-war-plugin/src/test/resources/unit/sample_wars/ejbclient.jar?rev=406419&view=auto
==============================================================================
Binary files /tmp/tmpMR1z1- and /tmp/tmp-VWPRR differ