You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ep...@apache.org on 2006/03/24 07:49:11 UTC

svn commit: r388412 - /maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/AbstractWarMojo.java

Author: epunzalan
Date: Thu Mar 23 22:49:10 2006
New Revision: 388412

URL: http://svn.apache.org/viewcvs?rev=388412&view=rev
Log:
PR: MWAR-7
Submitted by: Maria Odea Ching

Fixed the bug by adjusting the artifact filename references in case there is an artifact that's named after <finalName>.

Modified:
    maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/AbstractWarMojo.java

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=388412&r1=388411&r2=388412&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 Thu Mar 23 22:49:10 2006
@@ -377,7 +377,7 @@
         for ( Iterator iter = artifacts.iterator(); iter.hasNext(); )
         {
             Artifact artifact = (Artifact) iter.next();
-            String targetFileName = artifact.getFile().getName();
+            String targetFileName = getM2Filename( artifact );
 
             getLog().debug( "Processing: " + targetFileName );
 
@@ -445,7 +445,7 @@
         for ( Iterator iter = artifacts.iterator(); iter.hasNext(); )
         {
             Artifact artifact = (Artifact) iter.next();
-            String candidate = artifact.getFile().getName();
+            String candidate = getM2Filename( artifact );
             if ( identifiers.contains( candidate ) )
             {
                 duplicates.add( candidate );
@@ -729,6 +729,27 @@
                throw new IOException( "Unknown file type: " + file.getAbsolutePath() );
            }
        }
+    }
+
+    /**
+     * Converts the filename of an artifact to artifactId-version.type format.
+     *
+     * @param artifact
+     * @return converted filename of the artifact
+     */
+    private String getM2Filename( Artifact artifact )
+    {
+        String filename;
+        if ( !artifact.getFile().getName().equals(
+            artifact.getArtifactId() + "-" + artifact.getVersion() + "." + artifact.getType() ) )
+        {
+            filename = artifact.getArtifactId() + "-" + artifact.getVersion() + "." + artifact.getType();
+        }
+        else
+        {
+            filename = artifact.getFile().getName();
+        }
+        return filename;
     }
 
 }



Re: svn commit: r388412 - /maven/plugins/trunk/maven-war-plugin/src/main/java/org/apache/maven/plugin/war/AbstractWarMojo.java

Posted by Brett Porter <br...@apache.org>.
epunzalan@apache.org wrote:
> Author: epunzalan
> Date: Thu Mar 23 22:49:10 2006
> New Revision: 388412
> 
> URL: http://svn.apache.org/viewcvs?rev=388412&view=rev
> Log:
> PR: MWAR-7
> Submitted by: Maria Odea Ching
> 
> Fixed the bug by adjusting the artifact filename references in case there is an artifact that's named after <finalName>.

It would be good to use finalName instead, but I don't think we have
that capability just yet. Next version :)

> +    /**
> +     * Converts the filename of an artifact to artifactId-version.type format.
> +     *
> +     * @param artifact
> +     * @return converted filename of the artifact
> +     */
> +    private String getM2Filename( Artifact artifact )
> +    {
> +        String filename;
> +        if ( !artifact.getFile().getName().equals(
> +            artifact.getArtifactId() + "-" + artifact.getVersion() + "." + artifact.getType() ) )
> +        {
> +            filename = artifact.getArtifactId() + "-" + artifact.getVersion() + "." + artifact.getType();
> +        }
> +        else
> +        {
> +            filename = artifact.getFile().getName();
> +        }
> +        return filename;
>      }

This is equivalent to 'artifact.getArtifactId() + "-" +
artifact.getVersion() + "." + artifact.getType();' in every case, so
I'll simplify it.

- Brett

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@maven.apache.org
For additional commands, e-mail: dev-help@maven.apache.org