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 2019/12/17 19:37:19 UTC

[maven-shade-plugin] branch master updated: - Shaded test JARs are always empty

This is an automated email from the ASF dual-hosted git repository.

struberg pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-shade-plugin.git


The following commit(s) were added to refs/heads/master by this push:
     new 3771270  - Shaded test JARs are always empty
3771270 is described below

commit 3771270e16d44eda600ebc81d6e7a1849bd8ac6a
Author: Peter De Maeyer <pe...@gmail.com>
AuthorDate: Fri Nov 1 21:58:33 2019 +0100

    - Shaded test JARs are always empty
    
    Signed-off-by: Mark Struberg <st...@apache.org>
---
 src/it/MSHADE-284_shadeTestJar/api/pom.xml         | 32 +++++++++
 .../api/src/main/java/Api.java                     | 22 +++++++
 .../api/src/main/resources/api-resource.txt        | 16 +++++
 .../api/src/test/java/ApiTest.java                 | 25 +++++++
 .../api/src/test/resources/api-test-resource.txt   | 16 +++++
 src/it/MSHADE-284_shadeTestJar/impl/pom.xml        | 43 ++++++++++++
 .../impl/src/main/java/Impl.java                   | 22 +++++++
 .../impl/src/main/resources/impl-resource.txt      | 16 +++++
 .../impl/src/test/java/ImplTest.java               | 25 +++++++
 .../impl/src/test/resources/impl-test-resource.txt | 16 +++++
 src/it/MSHADE-284_shadeTestJar/pom.xml             | 77 ++++++++++++++++++++++
 src/it/MSHADE-284_shadeTestJar/uber/pom.xml        | 70 ++++++++++++++++++++
 src/it/MSHADE-284_shadeTestJar/verify.groovy       | 52 +++++++++++++++
 .../apache/maven/plugins/shade/mojo/ShadeMojo.java | 49 ++++++++++----
 14 files changed, 470 insertions(+), 11 deletions(-)

diff --git a/src/it/MSHADE-284_shadeTestJar/api/pom.xml b/src/it/MSHADE-284_shadeTestJar/api/pom.xml
new file mode 100644
index 0000000..f7e5c96
--- /dev/null
+++ b/src/it/MSHADE-284_shadeTestJar/api/pom.xml
@@ -0,0 +1,32 @@
+<?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/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.maven.its.shade.stj</groupId>
+        <artifactId>mshade-284-parent</artifactId>
+        <version>1.0</version>
+    </parent>
+    <artifactId>mshade-284-api</artifactId>
+</project>
diff --git a/src/it/MSHADE-284_shadeTestJar/api/src/main/java/Api.java b/src/it/MSHADE-284_shadeTestJar/api/src/main/java/Api.java
new file mode 100644
index 0000000..b1a0ba7
--- /dev/null
+++ b/src/it/MSHADE-284_shadeTestJar/api/src/main/java/Api.java
@@ -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.
+ */
+
+public class Api
+{
+}
diff --git a/src/it/MSHADE-284_shadeTestJar/api/src/main/resources/api-resource.txt b/src/it/MSHADE-284_shadeTestJar/api/src/main/resources/api-resource.txt
new file mode 100644
index 0000000..13a8339
--- /dev/null
+++ b/src/it/MSHADE-284_shadeTestJar/api/src/main/resources/api-resource.txt
@@ -0,0 +1,16 @@
+# 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.
diff --git a/src/it/MSHADE-284_shadeTestJar/api/src/test/java/ApiTest.java b/src/it/MSHADE-284_shadeTestJar/api/src/test/java/ApiTest.java
new file mode 100644
index 0000000..2e2eaab
--- /dev/null
+++ b/src/it/MSHADE-284_shadeTestJar/api/src/test/java/ApiTest.java
@@ -0,0 +1,25 @@
+/*
+ * 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.
+ */
+
+public class ApiTest
+{
+    public static void main(String[] args) {
+        new Api();
+    }
+}
diff --git a/src/it/MSHADE-284_shadeTestJar/api/src/test/resources/api-test-resource.txt b/src/it/MSHADE-284_shadeTestJar/api/src/test/resources/api-test-resource.txt
new file mode 100644
index 0000000..13a8339
--- /dev/null
+++ b/src/it/MSHADE-284_shadeTestJar/api/src/test/resources/api-test-resource.txt
@@ -0,0 +1,16 @@
+# 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.
diff --git a/src/it/MSHADE-284_shadeTestJar/impl/pom.xml b/src/it/MSHADE-284_shadeTestJar/impl/pom.xml
new file mode 100644
index 0000000..a89d6f5
--- /dev/null
+++ b/src/it/MSHADE-284_shadeTestJar/impl/pom.xml
@@ -0,0 +1,43 @@
+<?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/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.maven.its.shade.stj</groupId>
+        <artifactId>mshade-284-parent</artifactId>
+        <version>1.0</version>
+    </parent>
+    <artifactId>mshade-284-impl</artifactId>
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.maven.its.shade.stj</groupId>
+            <artifactId>mshade-284-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.maven.its.shade.stj</groupId>
+            <artifactId>mshade-284-api</artifactId>
+            <type>test-jar</type>
+        </dependency>
+    </dependencies>
+</project>
diff --git a/src/it/MSHADE-284_shadeTestJar/impl/src/main/java/Impl.java b/src/it/MSHADE-284_shadeTestJar/impl/src/main/java/Impl.java
new file mode 100644
index 0000000..737fb97
--- /dev/null
+++ b/src/it/MSHADE-284_shadeTestJar/impl/src/main/java/Impl.java
@@ -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.
+ */
+
+public class Impl extends Api
+{
+}
diff --git a/src/it/MSHADE-284_shadeTestJar/impl/src/main/resources/impl-resource.txt b/src/it/MSHADE-284_shadeTestJar/impl/src/main/resources/impl-resource.txt
new file mode 100644
index 0000000..13a8339
--- /dev/null
+++ b/src/it/MSHADE-284_shadeTestJar/impl/src/main/resources/impl-resource.txt
@@ -0,0 +1,16 @@
+# 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.
diff --git a/src/it/MSHADE-284_shadeTestJar/impl/src/test/java/ImplTest.java b/src/it/MSHADE-284_shadeTestJar/impl/src/test/java/ImplTest.java
new file mode 100644
index 0000000..f335ad5
--- /dev/null
+++ b/src/it/MSHADE-284_shadeTestJar/impl/src/test/java/ImplTest.java
@@ -0,0 +1,25 @@
+/*
+ * 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.
+ */
+
+public class ImplTest extends ApiTest
+{
+    public static void main(String[] args) {
+        new Impl();
+    }
+}
diff --git a/src/it/MSHADE-284_shadeTestJar/impl/src/test/resources/impl-test-resource.txt b/src/it/MSHADE-284_shadeTestJar/impl/src/test/resources/impl-test-resource.txt
new file mode 100644
index 0000000..13a8339
--- /dev/null
+++ b/src/it/MSHADE-284_shadeTestJar/impl/src/test/resources/impl-test-resource.txt
@@ -0,0 +1,16 @@
+# 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.
diff --git a/src/it/MSHADE-284_shadeTestJar/pom.xml b/src/it/MSHADE-284_shadeTestJar/pom.xml
new file mode 100644
index 0000000..a76202b
--- /dev/null
+++ b/src/it/MSHADE-284_shadeTestJar/pom.xml
@@ -0,0 +1,77 @@
+<?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/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <groupId>org.apache.maven.its.shade.stj</groupId>
+    <artifactId>mshade-284-parent</artifactId>
+    <packaging>pom</packaging>
+    <version>1.0</version>
+    <modules>
+        <module>api</module>
+        <module>impl</module>
+        <module>uber</module>
+    </modules>
+    <dependencyManagement>
+        <dependencies>
+            <dependency>
+                <groupId>org.apache.maven.its.shade.stj</groupId>
+                <artifactId>mshade-284-api</artifactId>
+                <version>1.0</version>
+            </dependency>
+            <dependency>
+                <groupId>org.apache.maven.its.shade.stj</groupId>
+                <artifactId>mshade-284-api</artifactId>
+                <version>1.0</version>
+                <type>test-jar</type>
+                <scope>test</scope>
+            </dependency>
+            <dependency>
+                <groupId>org.apache.maven.its.shade.stj</groupId>
+                <artifactId>mshade-284-impl</artifactId>
+                <version>1.0</version>
+            </dependency>
+            <dependency>
+                <groupId>org.apache.maven.its.shade.stj</groupId>
+                <artifactId>mshade-284-impl</artifactId>
+                <version>1.0</version>
+                <type>test-jar</type>
+                <scope>test</scope>
+            </dependency>
+        </dependencies>
+    </dependencyManagement>
+    <build>
+        <plugins>
+            <plugin>
+                <artifactId>maven-jar-plugin</artifactId>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>test-jar</goal>
+                        </goals>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+</project>
diff --git a/src/it/MSHADE-284_shadeTestJar/uber/pom.xml b/src/it/MSHADE-284_shadeTestJar/uber/pom.xml
new file mode 100644
index 0000000..e04b4b4
--- /dev/null
+++ b/src/it/MSHADE-284_shadeTestJar/uber/pom.xml
@@ -0,0 +1,70 @@
+<?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/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+    <parent>
+        <groupId>org.apache.maven.its.shade.stj</groupId>
+        <artifactId>mshade-284-parent</artifactId>
+        <version>1.0</version>
+    </parent>
+    <artifactId>mshade-284-uber</artifactId>
+    <dependencies>
+        <dependency>
+            <groupId>org.apache.maven.its.shade.stj</groupId>
+            <artifactId>mshade-284-api</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.maven.its.shade.stj</groupId>
+            <artifactId>mshade-284-api</artifactId>
+            <type>test-jar</type>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.maven.its.shade.stj</groupId>
+            <artifactId>mshade-284-impl</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.apache.maven.its.shade.stj</groupId>
+            <artifactId>mshade-284-impl</artifactId>
+            <type>test-jar</type>
+        </dependency>
+    </dependencies>
+    <build>
+        <plugins>
+            <plugin>
+                <artifactId>maven-shade-plugin</artifactId>
+                <version>@project.version@</version>
+                <executions>
+                    <execution>
+                        <goals>
+                            <goal>shade</goal>
+                        </goals>
+                        <configuration>
+                            <shadeTestJar>true</shadeTestJar>
+                        </configuration>
+                    </execution>
+                </executions>
+            </plugin>
+        </plugins>
+    </build>
+</project>
diff --git a/src/it/MSHADE-284_shadeTestJar/verify.groovy b/src/it/MSHADE-284_shadeTestJar/verify.groovy
new file mode 100644
index 0000000..7e48ef3
--- /dev/null
+++ b/src/it/MSHADE-284_shadeTestJar/verify.groovy
@@ -0,0 +1,52 @@
+/*
+ * 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.
+ */
+
+def jarFile = new java.util.jar.JarFile( new File( basedir, "uber/target/mshade-284-uber-1.0.jar" ) )
+try
+{
+    assert null != jarFile.getJarEntry( "Api.class" )
+    assert null != jarFile.getJarEntry( "api-resource.txt" )
+    assert null != jarFile.getJarEntry( "Impl.class" )
+    assert null != jarFile.getJarEntry( "impl-resource.txt" )
+    assert null == jarFile.getJarEntry( "ApiTest.class" )
+    assert null == jarFile.getJarEntry( "api-test-resource.txt" )
+    assert null == jarFile.getJarEntry( "ImplTest.class" )
+    assert null == jarFile.getJarEntry( "impl-test-resource.txt" )
+}
+finally
+{
+    jarFile.close()
+}
+
+def testJarFile = new java.util.jar.JarFile( new File( basedir, "uber/target/mshade-284-uber-1.0-tests.jar" ) )
+try
+{
+    assert null == testJarFile.getJarEntry( "Api.class" )
+    assert null == testJarFile.getJarEntry( "api-resource.txt" )
+    assert null == testJarFile.getJarEntry( "Impl.class" )
+    assert null == testJarFile.getJarEntry( "impl-resource.txt" )
+    assert null != testJarFile.getJarEntry( "ApiTest.class" )
+    assert null != testJarFile.getJarEntry( "api-test-resource.txt" )
+    assert null != testJarFile.getJarEntry( "ImplTest.class" )
+    assert null != testJarFile.getJarEntry( "impl-test-resource.txt" )
+}
+finally
+{
+    testJarFile.close()
+}
diff --git a/src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java b/src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java
index 30d1b6e..0dd7668 100644
--- a/src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java
+++ b/src/main/java/org/apache/maven/plugins/shade/mojo/ShadeMojo.java
@@ -361,6 +361,9 @@ public class ShadeMojo
     @Parameter( defaultValue = "false" )
     private boolean useBaseVersion;
 
+    /**
+     * When true, creates a shaded test-jar artifact as well.
+     */
     @Parameter( defaultValue = "false" )
     private boolean shadeTestJar;
 
@@ -422,7 +425,7 @@ public class ShadeMojo
             }
         }
 
-        processArtifactSelectors( artifacts, artifactIds, sourceArtifacts, artifactSelector );
+        processArtifactSelectors( artifacts, artifactIds, sourceArtifacts, testArtifacts, artifactSelector );
 
         File outputJar = ( outputFile != null ) ? outputFile : shadedArtifactFileWithClassifier();
         File sourcesJar = shadedSourceArtifactFileWithClassifier();
@@ -451,11 +454,10 @@ public class ShadeMojo
 
             if ( shadeTestJar )
             {
+                ShadeRequest shadeTestRequest =
+                    shadeRequest( testArtifacts, testJar, filters, relocators, resourceTransformers );
 
-                ShadeRequest shadeSourcesRequest =
-                    createShadeSourcesRequest( testArtifacts, testJar, filters, relocators, resourceTransformers );
-
-                shader.shade( shadeSourcesRequest );
+                shader.shade( shadeTestRequest );
             }
 
             if ( outputFile == null )
@@ -600,7 +602,7 @@ public class ShadeMojo
     }
 
     private void processArtifactSelectors( Set<File> artifacts, Set<String> artifactIds, Set<File> sourceArtifacts,
-                                           ArtifactSelector artifactSelector )
+                                           Set<File> testArtifacts, ArtifactSelector artifactSelector )
     {
         for ( Artifact artifact : project.getArtifacts() )
         {
@@ -624,7 +626,7 @@ public class ShadeMojo
 
             if ( createSourcesJar )
             {
-                File file = resolveArtifactSources( artifact );
+                File file = resolveArtifactForClassifier( artifact, "sources" );
                 if ( file != null )
                 {
                     if ( file.length() > 0 )
@@ -637,6 +639,22 @@ public class ShadeMojo
                     }
                 }
             }
+
+            if ( shadeTestJar )
+            {
+                File file = resolveArtifactForClassifier( artifact, "tests" );
+                if ( file != null )
+                {
+                    if ( file.length() > 0 )
+                    {
+                        testArtifacts.add( file );
+                    }
+                    else
+                    {
+                        getLog().warn( "Skipping empty test jar " + artifact.getId() + "." );
+                    }
+                }
+            }
         }
     }
 
@@ -704,14 +722,14 @@ public class ShadeMojo
         }
     }
 
-    private File resolveArtifactSources( Artifact artifact )
+    private File resolveArtifactForClassifier( Artifact artifact, String classifier )
     {
         DefaultArtifactCoordinate coordinate = new DefaultArtifactCoordinate();
         coordinate.setGroupId( artifact.getGroupId() );
         coordinate.setArtifactId( artifact.getArtifactId() );
         coordinate.setVersion( artifact.getVersion() );
         coordinate.setExtension( "jar" );
-        coordinate.setClassifier( "sources" );
+        coordinate.setClassifier( classifier );
 
         Artifact resolvedArtifact;
         try
@@ -721,7 +739,7 @@ public class ShadeMojo
         }
         catch ( ArtifactResolverException e )
         {
-            getLog().warn( "Could not get sources for " + artifact );
+            getLog().warn( "Could not get " + classifier + " for " + artifact );
             return null;
         }
 
@@ -793,7 +811,16 @@ public class ShadeMojo
 
                         if ( createSourcesJar )
                         {
-                            File file = resolveArtifactSources( artifact );
+                            File file = resolveArtifactForClassifier( artifact, "sources" );
+                            if ( file != null )
+                            {
+                                jars.add( file );
+                            }
+                        }
+
+                        if ( shadeTestJar )
+                        {
+                            File file = resolveArtifactForClassifier( artifact, "tests" );
                             if ( file != null )
                             {
                                 jars.add( file );