You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by st...@apache.org on 2009/09/06 02:26:48 UTC

svn commit: r811731 - in /maven/plugins/trunk/maven-shade-plugin/src: it/finalNameBuild-attached/ it/finalNameBuild-attached/src/ it/finalNameBuild-attached/src/main/ it/finalNameBuild-attached/src/main/resources/ it/finalNameBuild-attached/src/main/re...

Author: struberg
Date: Sun Sep  6 00:26:47 2009
New Revision: 811731

URL: http://svn.apache.org/viewvc?rev=811731&view=rev
Log:
MSHADE-54 fix usage of finalName in <build> and plugin <configuration> sections.
Additionally add integration tests for most of the use cases

TODO: the ITs should also check for the deployed artifacts in the local-repo

Added:
    maven/plugins/trunk/maven-shade-plugin/src/it/finalNameBuild/
    maven/plugins/trunk/maven-shade-plugin/src/it/finalNameBuild-attached/
    maven/plugins/trunk/maven-shade-plugin/src/it/finalNameBuild-attached/invoker.properties
    maven/plugins/trunk/maven-shade-plugin/src/it/finalNameBuild-attached/pom.xml
    maven/plugins/trunk/maven-shade-plugin/src/it/finalNameBuild-attached/src/
    maven/plugins/trunk/maven-shade-plugin/src/it/finalNameBuild-attached/src/main/
    maven/plugins/trunk/maven-shade-plugin/src/it/finalNameBuild-attached/src/main/resources/
    maven/plugins/trunk/maven-shade-plugin/src/it/finalNameBuild-attached/src/main/resources/META-INF/
    maven/plugins/trunk/maven-shade-plugin/src/it/finalNameBuild-attached/src/main/resources/META-INF/ejb-jar.xml
    maven/plugins/trunk/maven-shade-plugin/src/it/finalNameBuild-attached/verify.bsh
    maven/plugins/trunk/maven-shade-plugin/src/it/finalNameBuild/invoker.properties
    maven/plugins/trunk/maven-shade-plugin/src/it/finalNameBuild/pom.xml
    maven/plugins/trunk/maven-shade-plugin/src/it/finalNameBuild/src/
    maven/plugins/trunk/maven-shade-plugin/src/it/finalNameBuild/src/main/
    maven/plugins/trunk/maven-shade-plugin/src/it/finalNameBuild/src/main/resources/
    maven/plugins/trunk/maven-shade-plugin/src/it/finalNameBuild/src/main/resources/META-INF/
    maven/plugins/trunk/maven-shade-plugin/src/it/finalNameBuild/src/main/resources/META-INF/ejb-jar.xml
    maven/plugins/trunk/maven-shade-plugin/src/it/finalNameBuild/verify.bsh
    maven/plugins/trunk/maven-shade-plugin/src/it/finalNameShade/
    maven/plugins/trunk/maven-shade-plugin/src/it/finalNameShade-attached/
    maven/plugins/trunk/maven-shade-plugin/src/it/finalNameShade-attached/invoker.properties
    maven/plugins/trunk/maven-shade-plugin/src/it/finalNameShade-attached/pom.xml
    maven/plugins/trunk/maven-shade-plugin/src/it/finalNameShade-attached/src/
    maven/plugins/trunk/maven-shade-plugin/src/it/finalNameShade-attached/src/main/
    maven/plugins/trunk/maven-shade-plugin/src/it/finalNameShade-attached/src/main/resources/
    maven/plugins/trunk/maven-shade-plugin/src/it/finalNameShade-attached/src/main/resources/META-INF/
    maven/plugins/trunk/maven-shade-plugin/src/it/finalNameShade-attached/src/main/resources/META-INF/ejb-jar.xml
    maven/plugins/trunk/maven-shade-plugin/src/it/finalNameShade-attached/verify.bsh
    maven/plugins/trunk/maven-shade-plugin/src/it/finalNameShade/invoker.properties
    maven/plugins/trunk/maven-shade-plugin/src/it/finalNameShade/pom.xml
    maven/plugins/trunk/maven-shade-plugin/src/it/finalNameShade/src/
    maven/plugins/trunk/maven-shade-plugin/src/it/finalNameShade/src/main/
    maven/plugins/trunk/maven-shade-plugin/src/it/finalNameShade/src/main/resources/
    maven/plugins/trunk/maven-shade-plugin/src/it/finalNameShade/src/main/resources/META-INF/
    maven/plugins/trunk/maven-shade-plugin/src/it/finalNameShade/src/main/resources/META-INF/ejb-jar.xml
    maven/plugins/trunk/maven-shade-plugin/src/it/finalNameShade/verify.bsh
Modified:
    maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java

Added: maven/plugins/trunk/maven-shade-plugin/src/it/finalNameBuild-attached/invoker.properties
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-shade-plugin/src/it/finalNameBuild-attached/invoker.properties?rev=811731&view=auto
==============================================================================
--- maven/plugins/trunk/maven-shade-plugin/src/it/finalNameBuild-attached/invoker.properties (added)
+++ maven/plugins/trunk/maven-shade-plugin/src/it/finalNameBuild-attached/invoker.properties Sun Sep  6 00:26:47 2009
@@ -0,0 +1,2 @@
+# NOTE: Running only up to "package" is crucial, we want to check proper resolution from the reactor
+invoker.goals = clean package

Added: maven/plugins/trunk/maven-shade-plugin/src/it/finalNameBuild-attached/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-shade-plugin/src/it/finalNameBuild-attached/pom.xml?rev=811731&view=auto
==============================================================================
--- maven/plugins/trunk/maven-shade-plugin/src/it/finalNameBuild-attached/pom.xml (added)
+++ maven/plugins/trunk/maven-shade-plugin/src/it/finalNameBuild-attached/pom.xml Sun Sep  6 00:26:47 2009
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you 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.
+-->
+
+<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>org.apache.maven.its.shade.aat</groupId>
+  <artifactId>finalNameBuildAttached</artifactId>
+  <version>1.0</version>
+
+
+  <name>MSHADE-54 :: Shaded Artifact Producer</name>
+  <description>
+    Test that attached artifact has the correct finalName if
+    the finalName is set in the build section and
+    artifact attaching is activated.
+  </description>
+
+  <build>
+    <finalName>MyFinalName</finalName>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-shade-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>attach-shaded-artifact</id>
+            <phase>package</phase>
+            <goals>
+              <goal>shade</goal>
+            </goals>
+            <configuration>
+              <shadedArtifactAttached>true</shadedArtifactAttached>
+              <shadedClassifierName>shaded</shadedClassifierName>
+              <createDependencyReducedPom>false</createDependencyReducedPom>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>

Added: maven/plugins/trunk/maven-shade-plugin/src/it/finalNameBuild-attached/src/main/resources/META-INF/ejb-jar.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-shade-plugin/src/it/finalNameBuild-attached/src/main/resources/META-INF/ejb-jar.xml?rev=811731&view=auto
==============================================================================
--- maven/plugins/trunk/maven-shade-plugin/src/it/finalNameBuild-attached/src/main/resources/META-INF/ejb-jar.xml (added)
+++ maven/plugins/trunk/maven-shade-plugin/src/it/finalNameBuild-attached/src/main/resources/META-INF/ejb-jar.xml Sun Sep  6 00:26:47 2009
@@ -0,0 +1 @@
+<?xml version="1.0" encoding="UTF-8"?>

Added: maven/plugins/trunk/maven-shade-plugin/src/it/finalNameBuild-attached/verify.bsh
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-shade-plugin/src/it/finalNameBuild-attached/verify.bsh?rev=811731&view=auto
==============================================================================
--- maven/plugins/trunk/maven-shade-plugin/src/it/finalNameBuild-attached/verify.bsh (added)
+++ maven/plugins/trunk/maven-shade-plugin/src/it/finalNameBuild-attached/verify.bsh Sun Sep  6 00:26:47 2009
@@ -0,0 +1,31 @@
+import java.io.*;
+import java.util.*;
+import java.util.regex.*;
+
+try
+{
+    // check for primary artifact, which is the unshaded one!
+    File file = new File( basedir, "target/MyFinalName.jar" );
+    System.out.println( "file with finalName : " + file );
+    if ( !file.exists() )
+    {
+        System.out.println( "file with finalName does not exist: " + file );
+        return false;
+    }
+
+    // check for the shaded jar
+    File shaded = new File( basedir, "target/finalNameBuildAttached-1.0-shaded.jar" );
+    System.out.println( "shaded file with name : " + shaded );
+    if ( !shaded.exists() )
+    {
+        System.out.println( "shaded file does not exist: " + shaded );
+        return false;
+    }
+}
+catch( Throwable t )
+{
+    t.printStackTrace();
+    return false;
+}
+
+return true;

Added: maven/plugins/trunk/maven-shade-plugin/src/it/finalNameBuild/invoker.properties
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-shade-plugin/src/it/finalNameBuild/invoker.properties?rev=811731&view=auto
==============================================================================
--- maven/plugins/trunk/maven-shade-plugin/src/it/finalNameBuild/invoker.properties (added)
+++ maven/plugins/trunk/maven-shade-plugin/src/it/finalNameBuild/invoker.properties Sun Sep  6 00:26:47 2009
@@ -0,0 +1,2 @@
+# NOTE: Running only up to "package" is crucial, we want to check proper resolution from the reactor
+invoker.goals = clean package

Added: maven/plugins/trunk/maven-shade-plugin/src/it/finalNameBuild/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-shade-plugin/src/it/finalNameBuild/pom.xml?rev=811731&view=auto
==============================================================================
--- maven/plugins/trunk/maven-shade-plugin/src/it/finalNameBuild/pom.xml (added)
+++ maven/plugins/trunk/maven-shade-plugin/src/it/finalNameBuild/pom.xml Sun Sep  6 00:26:47 2009
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you 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.
+-->
+
+<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>org.apache.maven.its.shade.aat</groupId>
+  <artifactId>finalNameBuild</artifactId>
+  <version>1.0</version>
+
+
+  <name>MSHADE-54 :: Shaded Artifact Producer</name>
+  <description>
+    Test that attached artifact has the correct finalName if
+    the finalName is set in the build section and
+    artifact attaching is NOT activated.
+  </description>
+
+  <build>
+    <finalName>MyFinalName</finalName>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-shade-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>create-shaded-artifact</id>
+            <phase>package</phase>
+            <goals>
+              <goal>shade</goal>
+            </goals>
+            <configuration>
+              <shadedClassifierName>shaded</shadedClassifierName>
+              <createDependencyReducedPom>false</createDependencyReducedPom>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>

Added: maven/plugins/trunk/maven-shade-plugin/src/it/finalNameBuild/src/main/resources/META-INF/ejb-jar.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-shade-plugin/src/it/finalNameBuild/src/main/resources/META-INF/ejb-jar.xml?rev=811731&view=auto
==============================================================================
--- maven/plugins/trunk/maven-shade-plugin/src/it/finalNameBuild/src/main/resources/META-INF/ejb-jar.xml (added)
+++ maven/plugins/trunk/maven-shade-plugin/src/it/finalNameBuild/src/main/resources/META-INF/ejb-jar.xml Sun Sep  6 00:26:47 2009
@@ -0,0 +1 @@
+<?xml version="1.0" encoding="UTF-8"?>

Added: maven/plugins/trunk/maven-shade-plugin/src/it/finalNameBuild/verify.bsh
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-shade-plugin/src/it/finalNameBuild/verify.bsh?rev=811731&view=auto
==============================================================================
--- maven/plugins/trunk/maven-shade-plugin/src/it/finalNameBuild/verify.bsh (added)
+++ maven/plugins/trunk/maven-shade-plugin/src/it/finalNameBuild/verify.bsh Sun Sep  6 00:26:47 2009
@@ -0,0 +1,42 @@
+import java.io.*;
+import java.util.*;
+import java.util.regex.*;
+
+try
+{
+    // check for primary artifact, which is actually the shaded one!
+    File file = new File( basedir, "target/MyFinalName.jar" );
+    System.out.println( "file with finalName : " + file );
+    if ( !file.exists() )
+    {
+        System.out.println( "file with finalName does not exist: " + file );
+        return false;
+    }
+
+    // check for original unshaded jar
+    File original = new File( basedir, "target/original-MyFinalName.jar" );
+    System.out.println( "'orifinal' file with name : " + original );
+    if ( !original.exists() )
+    {
+        System.out.println( "'original' file does not exist: " + original );
+        return false;
+    }
+
+/* TODO: enable after we switched form package to install target for the ITS!
+    // check for the artifact in the repo
+    File rfile = new File( new File( basedir, "target/local-repo" ), 
+                         "org/apache/maven/its/shade/aat/finalNameBuild/1.0/finalNameBuild-1.0.jar" );
+    System.out.println( "Checking for existence in repo: " + rfile );
+    if ( !rfile.isFile() )
+    {
+        throw new FileNotFoundException( "Missing: " + rfile.getAbsolutePath() );
+    }
+*/
+}
+catch( Throwable t )
+{
+    t.printStackTrace();
+    return false;
+}
+
+return true;

Added: maven/plugins/trunk/maven-shade-plugin/src/it/finalNameShade-attached/invoker.properties
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-shade-plugin/src/it/finalNameShade-attached/invoker.properties?rev=811731&view=auto
==============================================================================
--- maven/plugins/trunk/maven-shade-plugin/src/it/finalNameShade-attached/invoker.properties (added)
+++ maven/plugins/trunk/maven-shade-plugin/src/it/finalNameShade-attached/invoker.properties Sun Sep  6 00:26:47 2009
@@ -0,0 +1,2 @@
+# NOTE: Running only up to "package" is crucial, we want to check proper resolution from the reactor
+invoker.goals = clean package

Added: maven/plugins/trunk/maven-shade-plugin/src/it/finalNameShade-attached/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-shade-plugin/src/it/finalNameShade-attached/pom.xml?rev=811731&view=auto
==============================================================================
--- maven/plugins/trunk/maven-shade-plugin/src/it/finalNameShade-attached/pom.xml (added)
+++ maven/plugins/trunk/maven-shade-plugin/src/it/finalNameShade-attached/pom.xml Sun Sep  6 00:26:47 2009
@@ -0,0 +1,60 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you 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.
+-->
+
+<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>org.apache.maven.its.shade.aat</groupId>
+  <artifactId>finalNameShadeAttached</artifactId>
+  <version>1.0</version>
+
+
+  <name>MSHADE-54 :: Shaded Artifact Producer</name>
+  <description>
+    Test that attached artifact has the correct finalName if
+    the finalName is set in the shade plugin section and
+    artifact attaching is activated.
+  </description>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-shade-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>attach-shaded-artifact</id>
+            <phase>package</phase>
+            <goals>
+              <goal>shade</goal>
+            </goals>
+            <configuration>
+              <finalName>MyFinalShadeName</finalName>
+              <shadedArtifactAttached>true</shadedArtifactAttached>
+              <shadedClassifierName>shaded</shadedClassifierName>
+              <createDependencyReducedPom>false</createDependencyReducedPom>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>

Added: maven/plugins/trunk/maven-shade-plugin/src/it/finalNameShade-attached/src/main/resources/META-INF/ejb-jar.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-shade-plugin/src/it/finalNameShade-attached/src/main/resources/META-INF/ejb-jar.xml?rev=811731&view=auto
==============================================================================
--- maven/plugins/trunk/maven-shade-plugin/src/it/finalNameShade-attached/src/main/resources/META-INF/ejb-jar.xml (added)
+++ maven/plugins/trunk/maven-shade-plugin/src/it/finalNameShade-attached/src/main/resources/META-INF/ejb-jar.xml Sun Sep  6 00:26:47 2009
@@ -0,0 +1 @@
+<?xml version="1.0" encoding="UTF-8"?>

Added: maven/plugins/trunk/maven-shade-plugin/src/it/finalNameShade-attached/verify.bsh
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-shade-plugin/src/it/finalNameShade-attached/verify.bsh?rev=811731&view=auto
==============================================================================
--- maven/plugins/trunk/maven-shade-plugin/src/it/finalNameShade-attached/verify.bsh (added)
+++ maven/plugins/trunk/maven-shade-plugin/src/it/finalNameShade-attached/verify.bsh Sun Sep  6 00:26:47 2009
@@ -0,0 +1,31 @@
+import java.io.*;
+import java.util.*;
+import java.util.regex.*;
+
+try
+{
+    // check for primary artifact, which is the unshaded one!
+    File file = new File( basedir, "target/finalNameShadeAttached-1.0.jar" );
+    System.out.println( "file with finalName : " + file );
+    if ( !file.exists() )
+    {
+        System.out.println( "file with finalName does not exist: " + file );
+        return false;
+    }
+
+    // check for the shaded jar
+    File shaded = new File( basedir, "target/MyFinalShadeName.jar" );
+    System.out.println( "shaded file with name : " + shaded );
+    if ( !shaded.exists() )
+    {
+        System.out.println( "shaded file does not exist: " + shaded );
+        return false;
+    }
+}
+catch( Throwable t )
+{
+    t.printStackTrace();
+    return false;
+}
+
+return true;

Added: maven/plugins/trunk/maven-shade-plugin/src/it/finalNameShade/invoker.properties
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-shade-plugin/src/it/finalNameShade/invoker.properties?rev=811731&view=auto
==============================================================================
--- maven/plugins/trunk/maven-shade-plugin/src/it/finalNameShade/invoker.properties (added)
+++ maven/plugins/trunk/maven-shade-plugin/src/it/finalNameShade/invoker.properties Sun Sep  6 00:26:47 2009
@@ -0,0 +1,2 @@
+# NOTE: Running only up to "package" is crucial, we want to check proper resolution from the reactor
+invoker.goals = clean package

Added: maven/plugins/trunk/maven-shade-plugin/src/it/finalNameShade/pom.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-shade-plugin/src/it/finalNameShade/pom.xml?rev=811731&view=auto
==============================================================================
--- maven/plugins/trunk/maven-shade-plugin/src/it/finalNameShade/pom.xml (added)
+++ maven/plugins/trunk/maven-shade-plugin/src/it/finalNameShade/pom.xml Sun Sep  6 00:26:47 2009
@@ -0,0 +1,59 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you 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.
+-->
+
+<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>org.apache.maven.its.shade.aat</groupId>
+  <artifactId>finalNameShade</artifactId>
+  <version>1.0</version>
+
+
+  <name>MSHADE-54 :: Shaded Artifact Producer</name>
+  <description>
+    Test that attached artifact has the correct finalName if
+    the finalName is set in the shade plugin section and
+    artifact attaching is NOT activated.
+  </description>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-shade-plugin</artifactId>
+        <executions>
+          <execution>
+            <id>attach-shaded-artifact</id>
+            <phase>package</phase>
+            <goals>
+              <goal>shade</goal>
+            </goals>
+            <configuration>
+              <finalName>MyFinalShadeName</finalName>
+              <shadedClassifierName>shaded</shadedClassifierName>
+              <createDependencyReducedPom>false</createDependencyReducedPom>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>

Added: maven/plugins/trunk/maven-shade-plugin/src/it/finalNameShade/src/main/resources/META-INF/ejb-jar.xml
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-shade-plugin/src/it/finalNameShade/src/main/resources/META-INF/ejb-jar.xml?rev=811731&view=auto
==============================================================================
--- maven/plugins/trunk/maven-shade-plugin/src/it/finalNameShade/src/main/resources/META-INF/ejb-jar.xml (added)
+++ maven/plugins/trunk/maven-shade-plugin/src/it/finalNameShade/src/main/resources/META-INF/ejb-jar.xml Sun Sep  6 00:26:47 2009
@@ -0,0 +1 @@
+<?xml version="1.0" encoding="UTF-8"?>

Added: maven/plugins/trunk/maven-shade-plugin/src/it/finalNameShade/verify.bsh
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-shade-plugin/src/it/finalNameShade/verify.bsh?rev=811731&view=auto
==============================================================================
--- maven/plugins/trunk/maven-shade-plugin/src/it/finalNameShade/verify.bsh (added)
+++ maven/plugins/trunk/maven-shade-plugin/src/it/finalNameShade/verify.bsh Sun Sep  6 00:26:47 2009
@@ -0,0 +1,31 @@
+import java.io.*;
+import java.util.*;
+import java.util.regex.*;
+
+try
+{
+    // check for primary artifact, which is the unshaded one!
+    File file = new File( basedir, "target/finalNameShade-1.0.jar" );
+    System.out.println( "file with finalName : " + file );
+    if ( !file.exists() )
+    {
+        System.out.println( "file with finalName does not exist: " + file );
+        return false;
+    }
+
+    // check for the shaded jar
+    File shaded = new File( basedir, "target/MyFinalShadeName.jar" );
+    System.out.println( "shaded file with name : " + shaded );
+    if ( !shaded.exists() )
+    {
+        System.out.println( "shaded file does not exist: " + shaded );
+        return false;
+    }
+}
+catch( Throwable t )
+{
+    t.printStackTrace();
+    return false;
+}
+
+return true;

Modified: maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java
URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java?rev=811731&r1=811730&r2=811731&view=diff
==============================================================================
--- maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java (original)
+++ maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java Sun Sep  6 00:26:47 2009
@@ -211,7 +211,11 @@
     private File outputDirectory;
 
     /**
-     * The name of the shaded artifactId
+     * The name of the shaded artifactId.
+     * 
+     * If you like to change the name of the native artifact, you may use the <build><finalName> setting.
+     * If this is set to something different than <build><finalName>, no file replacement
+     * will be performed, even if shadedArtifactAttached is being used.
      *
      * @parameter expression="${finalName}"
      */
@@ -365,6 +369,22 @@
                 shader.shade( sourceArtifacts, sourcesJar, filters, relocators, resourceTransformers );
             }
 
+            boolean renamed=false;
+            
+            // rename the output file if a specific finalName is set
+            // but don't rename if the finalName is the <build><finalName>
+            // because this will be handled implicitely later
+            if ( finalName != null && finalName.length() > 0 && 
+                 !finalName.equals( project.getBuild().getFinalName() ) )
+            {
+                String finalFileName = finalName + "." + project.getArtifact().getArtifactHandler().getExtension(); 
+                File finalFile = new File( outputDirectory, finalFileName );
+                replaceFile( finalFile, outputJar );                
+                outputJar = finalFile;
+                
+                renamed=true;
+            }
+
             if ( shadedArtifactAttached )
             {
                 getLog().info( "Attaching shaded artifact." );
@@ -374,21 +394,20 @@
                     projectHelper.attachArtifact( project, "jar", shadedClassifierName + "-sources", sourcesJar );
                 }
             }
-
-            else
+            else if ( !renamed )
             {
                 getLog().info( "Replacing original artifact with shaded artifact." );
-                File file = shadedArtifactFile();
-                replaceFile( file, outputJar );
+                File originalArtifact = project.getArtifact().getFile();;
+                replaceFile( originalArtifact, outputJar );
 
                 if ( createSourcesJar )
                 {
-                    file = shadedSourcesArtifactFile();
+                    File shadedSources = shadedSourcesArtifactFile();
 
-                    replaceFile( file, sourcesJar );
+                    replaceFile( shadedSources, sourcesJar );
 
                     projectHelper.attachArtifact( project, "jar",
-                                                  "sources", file );
+                                                  "sources", shadedSources );
                 }
 
                 if ( createDependencyReducedPom )
@@ -631,34 +650,15 @@
         return new File( outputDirectory, shadedName );
     }
 
-    private File shadedArtifactFile()
-    {
-        Artifact artifact = project.getArtifact();
-
-        String shadedName;
-
-        if ( finalName != null )
-        {
-            shadedName = finalName + "." + artifact.getArtifactHandler().getExtension();
-        }
-        else
-        {
-            shadedName = shadedArtifactId + "-" + artifact.getVersion() + "."
-                + artifact.getArtifactHandler().getExtension();
-        }
-
-        return new File( outputDirectory, shadedName );
-    }
-
     private File shadedSourcesArtifactFile()
     {
         Artifact artifact = project.getArtifact();
 
         String shadedName;
 
-        if ( finalName != null )
+        if ( project.getBuild().getFinalName() != null )
         {
-            shadedName = finalName + "-sources." + artifact.getArtifactHandler().getExtension();
+            shadedName = project.getBuild().getFinalName() + "-sources." + artifact.getArtifactHandler().getExtension();
         }
         else
         {