Author: rfscholte
Date: Wed Jan 18 18:50:18 2017
New Revision: 1779371

URL: http://svn.apache.org/viewvc?rev=1779371&view=rev
Log:
[MSHADE-239] Shaded Source JAR not following finalName pattern
Contributed by Diego Rivera, verified and adjusted by Robert Scholte

Added:
    
maven/plugins/trunk/maven-shade-plugin/src/it/MSHADE-239_finalName-attachments/
    
maven/plugins/trunk/maven-shade-plugin/src/it/MSHADE-239_finalName-attachments/pom.xml
    
maven/plugins/trunk/maven-shade-plugin/src/it/MSHADE-239_finalName-attachments/verify.groovy
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/MSHADE-239_finalName-attachments/pom.xml
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-shade-plugin/src/it/MSHADE-239_finalName-attachments/pom.xml?rev=1779371&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-shade-plugin/src/it/MSHADE-239_finalName-attachments/pom.xml
 (added)
+++ 
maven/plugins/trunk/maven-shade-plugin/src/it/MSHADE-239_finalName-attachments/pom.xml
 Wed Jan 18 18:50:18 2017
@@ -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.fns</groupId>
+  <artifactId>artifactId</artifactId>
+  <version>version</version>
+
+  <url>https://issues.apache.org/jira/browse/MSHADE-239</url>
+  
+  <properties>
+    <some-other-crap>crapola</some-other-crap>
+  </properties>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-shade-plugin</artifactId>
+        <version>@project.version@</version>
+        <executions>
+          <execution>
+            <goals>
+              <goal>shade</goal>
+            </goals>
+            <configuration>
+              
<finalName>${project.artifactId}-${project.version}-${some-other-crap}-exe</finalName>
+              <createSourcesJar>true</createSourcesJar>
+              <shadedSourcesContent>true</shadedSourcesContent>
+              <shadedArtifactAttached>true</shadedArtifactAttached>
+              <shadedClassifierName>exe</shadedClassifierName>
+              <shadeTestJar>true</shadeTestJar>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>

Added: 
maven/plugins/trunk/maven-shade-plugin/src/it/MSHADE-239_finalName-attachments/verify.groovy
URL: 
http://svn.apache.org/viewvc/maven/plugins/trunk/maven-shade-plugin/src/it/MSHADE-239_finalName-attachments/verify.groovy?rev=1779371&view=auto
==============================================================================
--- 
maven/plugins/trunk/maven-shade-plugin/src/it/MSHADE-239_finalName-attachments/verify.groovy
 (added)
+++ 
maven/plugins/trunk/maven-shade-plugin/src/it/MSHADE-239_finalName-attachments/verify.groovy
 Wed Jan 18 18:50:18 2017
@@ -0,0 +1,22 @@
+/*
+ * 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.
+ */
+
+assert new File( basedir, 'target/artifactId-version-crapola-exe.jar' 
).exists() : "target/artifactId-version-crapola-exe.jar doesn't exist"
+assert new File( basedir, 'target/artifactId-version-crapola-exe-sources.jar' 
).exists() : "target/artifactId-version-crapola-exe-sources.jar doesn't exist"
+assert new File( basedir, 'target/artifactId-version-crapola-exe-tests.jar' 
).exists() : "target/artifactId-version-crapola-exe-tests.jar doesn't exist"

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=1779371&r1=1779370&r2=1779371&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
 Wed Jan 18 18:50:18 2017
@@ -473,6 +473,24 @@ public class ShadeMojo
                     replaceFile( finalFile, outputJar );
                     outputJar = finalFile;
 
+                    // Also support the sources JAR
+                    if ( createSourcesJar )
+                    {
+                        finalFileName = finalName + "-sources.jar";
+                        finalFile = new File( outputDirectory, finalFileName );
+                        replaceFile( finalFile, sourcesJar );
+                        sourcesJar = finalFile;
+                    }
+
+                    // Also support the test JAR
+                    if ( shadeTestJar )
+                    {
+                        finalFileName = finalName + "-tests.jar";
+                        finalFile = new File( outputDirectory, finalFileName );
+                        replaceFile( finalFile, testJar );
+                        testJar = finalFile;
+                    }
+                    
                     renamed = true;
                 }
 


Reply via email to