Merge remote-tracking branch 'remotes/origin/MSHADE-349'
diff --git a/src/it/mrm/repository/dep-reduced-pom-exclusions/a-0.1.pom b/src/it/mrm/repository/dep-reduced-pom-exclusions/a-0.1.pom
new file mode 100644
index 0000000..87e14f6
--- /dev/null
+++ b/src/it/mrm/repository/dep-reduced-pom-exclusions/a-0.1.pom
@@ -0,0 +1,50 @@
+<?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>

+  <modelVersion>4.0.0</modelVersion>

+

+  <groupId>org.apache.maven.its.shade.drpe</groupId>

+  <artifactId>a</artifactId>

+  <version>0.1</version>

+  <packaging>jar</packaging>

+

+  <distributionManagement>

+    <repository>

+      <id>maven-core-it</id>

+      <url>file:///${basedir}/repo</url>

+    </repository>

+  </distributionManagement>

+

+  <dependencies>

+    <dependency>

+      <groupId>org.apache.maven.its.shade.drpe</groupId>

+      <artifactId>b</artifactId>

+      <version>0.2</version>

+    </dependency>

+    <dependency>

+      <groupId>org.apache.maven.its.shade.drpe</groupId>

+      <artifactId>b</artifactId>

+      <classifier>alt</classifier>

+      <version>0.2</version>

+    </dependency>

+  </dependencies>

+</project>

diff --git a/src/it/mrm/repository/dep-reduced-pom-exclusions/b-0.2-alt.jar/b-alt.properties b/src/it/mrm/repository/dep-reduced-pom-exclusions/b-0.2-alt.jar/b-alt.properties
new file mode 100644
index 0000000..287f9b1
--- /dev/null
+++ b/src/it/mrm/repository/dep-reduced-pom-exclusions/b-0.2-alt.jar/b-alt.properties
@@ -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.
\ No newline at end of file
diff --git a/src/it/mrm/repository/dep-reduced-pom-exclusions/b-0.2.pom b/src/it/mrm/repository/dep-reduced-pom-exclusions/b-0.2.pom
new file mode 100644
index 0000000..4ecb2a3
--- /dev/null
+++ b/src/it/mrm/repository/dep-reduced-pom-exclusions/b-0.2.pom
@@ -0,0 +1,44 @@
+<?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>

+  <modelVersion>4.0.0</modelVersion>

+

+  <groupId>org.apache.maven.its.shade.drpe</groupId>

+  <artifactId>b</artifactId>

+  <version>0.2</version>

+  <packaging>jar</packaging>

+

+  <distributionManagement>

+    <repository>

+      <id>maven-core-it</id>

+      <url>file:///${basedir}/repo</url>

+    </repository>

+  </distributionManagement>

+

+  <dependencies>

+    <dependency>

+      <groupId>org.apache.maven.its.shade.drpe</groupId>

+      <artifactId>c</artifactId>

+      <version>1</version>

+    </dependency>

+  </dependencies>

+</project>

diff --git a/src/it/mrm/repository/dep-reduced-pom-exclusions/c-1.pom b/src/it/mrm/repository/dep-reduced-pom-exclusions/c-1.pom
new file mode 100644
index 0000000..3a40bf4
--- /dev/null
+++ b/src/it/mrm/repository/dep-reduced-pom-exclusions/c-1.pom
@@ -0,0 +1,36 @@
+<?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>

+  <modelVersion>4.0.0</modelVersion>

+

+  <groupId>org.apache.maven.its.shade.drpe</groupId>

+  <artifactId>c</artifactId>

+  <version>1</version>

+  <packaging>jar</packaging>

+

+  <distributionManagement>

+    <repository>

+      <id>maven-core-it</id>

+      <url>file:///${basedir}/repo</url>

+    </repository>

+  </distributionManagement>

+</project>

diff --git a/src/it/projects/dep-reduced-pom-exclusions/invoker.properties b/src/it/projects/dep-reduced-pom-exclusions/invoker.properties
new file mode 100644
index 0000000..9bbad67
--- /dev/null
+++ b/src/it/projects/dep-reduced-pom-exclusions/invoker.properties
@@ -0,0 +1,18 @@
+# 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.
+
+invoker.timeoutInSeconds=60
\ No newline at end of file
diff --git a/src/it/projects/dep-reduced-pom-exclusions/pom.xml b/src/it/projects/dep-reduced-pom-exclusions/pom.xml
new file mode 100644
index 0000000..6c5eb3f
--- /dev/null
+++ b/src/it/projects/dep-reduced-pom-exclusions/pom.xml
@@ -0,0 +1,75 @@
+<?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>
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>org.apache.maven.its.shade.drpe</groupId>
+  <artifactId>test</artifactId>
+  <version>1.0</version>
+
+  <name>MSHADE-223</name>
+  <description>
+    Test that creation of the dependency reduced POM properly handles dependencies with classifiers.
+  </description>
+
+  <dependencies>
+    <dependency>
+      <groupId>org.apache.maven.its.shade.drpe</groupId>
+      <artifactId>a</artifactId>
+      <version>0.1</version>
+      <exclusions>
+        <exclusion>
+          <groupId>org.apache.maven.its.shade.drpe</groupId>
+          <artifactId>c</artifactId>
+        </exclusion>
+      </exclusions>
+    </dependency>
+  </dependencies>
+
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.apache.maven.plugins</groupId>
+        <artifactId>maven-shade-plugin</artifactId>
+        <version>@project.version@</version>
+        <executions>
+          <execution>
+            <id>attach-shade</id>
+            <goals>
+              <goal>shade</goal>
+            </goals>
+            <configuration>
+              <promoteTransitiveDependencies>true</promoteTransitiveDependencies>
+              <shadedArtifactAttached>false</shadedArtifactAttached>
+              <createDependencyReducedPom>true</createDependencyReducedPom>
+              <artifactSet>
+                <includes>
+                  <include>org.apache.maven.its.shade.drpe:a</include>
+                </includes>
+              </artifactSet>
+            </configuration>
+          </execution>
+        </executions>
+      </plugin>
+    </plugins>
+  </build>
+</project>
diff --git a/src/it/projects/dep-reduced-pom-exclusions/verify.groovy b/src/it/projects/dep-reduced-pom-exclusions/verify.groovy
new file mode 100644
index 0000000..2765519
--- /dev/null
+++ b/src/it/projects/dep-reduced-pom-exclusions/verify.groovy
@@ -0,0 +1,29 @@
+/*
+ * 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.
+ */
+
+File pomFile = new File( basedir, "dependency-reduced-pom.xml" )
+assert pomFile.isFile()
+
+def ns = new groovy.xml.Namespace("http://maven.apache.org/POM/4.0.0") 
+def pom = new XmlParser().parse( pomFile )
+
+assert pom[ns.modelVersion].size() == 1
+assert pom[ns.dependencies][ns.dependency].size() == 2
+assert pom[ns.dependencies][ns.dependency][0][ns.exclusions][ns.exclusion].size() == 1
+assert pom[ns.dependencies][ns.dependency][1][ns.exclusions][ns.exclusion].size() == 1
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 07a8b8d..5e575e8 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
@@ -664,18 +664,25 @@
                                            Set<File> testArtifacts, Set<File> testSourceArtifacts,
                                            ArtifactSelector artifactSelector )
     {
+
+        List<String> excludedArtifacts = new ArrayList<>();
+        List<String> pomArtifacts = new ArrayList<>();
+        List<String> emptySourceArtifacts = new ArrayList<>();
+        List<String> emptyTestArtifacts = new ArrayList<>();
+        List<String> emptyTestSourceArtifacts = new ArrayList<>();
+
         for ( Artifact artifact : project.getArtifacts() )
         {
             if ( !artifactSelector.isSelected( artifact ) )
             {
-                getLog().info( "Excluding " + artifact.getId() + " from the shaded jar." );
+                excludedArtifacts.add( artifact.getId() );
 
                 continue;
             }
 
             if ( "pom".equals( artifact.getType() ) )
             {
-                getLog().info( "Skipping pom dependency " + artifact.getId() + " in the shaded jar." );
+                pomArtifacts.add( artifact.getId() );
                 continue;
             }
 
@@ -695,7 +702,7 @@
                     }
                     else
                     {
-                        getLog().warn( "Skipping empty source jar " + artifact.getId() + "." );
+                        emptySourceArtifacts.add( artifact.getArtifactId() );
                     }
                 }
             }
@@ -711,7 +718,7 @@
                     }
                     else
                     {
-                        getLog().warn( "Skipping empty test jar " + artifact.getId() + "." );
+                        emptyTestArtifacts.add( artifact.getId() );
                     }
                 }
             }
@@ -725,10 +732,31 @@
                 }
                 else
                 {
-                    getLog().warn( "Skipping empty test source jar " + artifact.getId() + "." );
+                    emptyTestSourceArtifacts.add( artifact.getId() );
                 }
             }
         }
+
+        for ( String artifactId : excludedArtifacts )
+        {
+            getLog().info( "Excluding " + artifactId + " from the shaded jar." );
+        }
+        for ( String artifactId : pomArtifacts )
+        {
+            getLog().info( "Skipping pom dependency " + artifactId + " in the shaded jar." );
+        }
+        for ( String artifactId : emptySourceArtifacts )
+        {
+            getLog().warn( "Skipping empty source jar " + artifactId + "." );
+        }
+        for ( String artifactId : emptyTestArtifacts )
+        {
+            getLog().warn( "Skipping empty test jar " + artifactId + "." );
+        }
+        for ( String artifactId : emptyTestArtifacts )
+        {
+            getLog().warn( "Skipping empty test source jar " + artifactId + "." );
+        }
     }
 
     private boolean invalidMainArtifact()
@@ -786,12 +814,10 @@
     private void copyFiles( File source, File target )
         throws IOException
     {
-        try ( InputStream in = new FileInputStream( source ) )
+        try ( InputStream in = new FileInputStream( source );
+              OutputStream out = new FileOutputStream( target ) )
         {
-            try ( OutputStream out = new FileOutputStream( target ) )
-            {
-                IOUtil.copy( in, out );
-            }
+            IOUtil.copy( in, out );
         }
     }
 
@@ -1252,9 +1278,7 @@
                     boolean found = false;
                     for ( Dependency dep : transitiveDeps )
                     {
-                        if ( dep.getArtifactId().equals( n3.getArtifact().getArtifactId() ) //
-                            && dep.getGroupId().equals( n3.getArtifact().getGroupId() ) //
-                            && ( dep.getType() == null || dep.getType().equals( n3.getArtifact().getType() ) ) )
+                        if ( getId( dep ).equals( getId( n3.getArtifact() ) ) )
                         {
                             found = true;
                             break;
@@ -1269,9 +1293,7 @@
                     {
                         for ( Dependency dep : dependencies )
                         {
-                            if ( dep.getArtifactId().equals( n2.getArtifact().getArtifactId() ) //
-                                && dep.getGroupId().equals( n2.getArtifact().getGroupId() ) //
-                                && ( dep.getType() == null || dep.getType().equals( n2.getArtifact().getType() ) ) )
+                            if ( getId( dep ).equals( getId( n2.getArtifact() ) ) )
                             {
                                 Exclusion exclusion = new Exclusion();
                                 exclusion.setArtifactId( n3.getArtifact().getArtifactId() );
diff --git a/src/main/java/org/apache/maven/plugins/shade/resource/GroovyResourceTransformer.java b/src/main/java/org/apache/maven/plugins/shade/resource/GroovyResourceTransformer.java
index ced9c71..754834f 100644
--- a/src/main/java/org/apache/maven/plugins/shade/resource/GroovyResourceTransformer.java
+++ b/src/main/java/org/apache/maven/plugins/shade/resource/GroovyResourceTransformer.java
@@ -39,7 +39,10 @@
     implements ResourceTransformer
 {
 
-    static final String EXT_MODULE_NAME = "META-INF/services/org.codehaus.groovy.runtime.ExtensionModule";
+    static final String EXT_MODULE_NAME_LEGACY = "META-INF/services/org.codehaus.groovy.runtime.ExtensionModule";
+
+    // Since Groovy 2.5.x/Java 9 META-INF/services may only be used by Service Providers
+    static final String EXT_MODULE_NAME = "META-INF/groovy/org.codehaus.groovy.runtime.ExtensionModule";
 
     private List<String> extensionClassesList = new ArrayList<>();
 
@@ -52,7 +55,7 @@
     @Override
     public boolean canTransformResource( String resource )
     {
-        return EXT_MODULE_NAME.equals( resource );
+        return EXT_MODULE_NAME.equals( resource ) || EXT_MODULE_NAME_LEGACY.equals( resource );
     }
 
     @Override
@@ -60,13 +63,9 @@
         throws IOException
     {
         Properties out = new Properties();
-        try
+        try ( InputStream props = is )
         {
-            out.load( is );
-        }
-        finally
-        {
-            is.close();
+            out.load( props );
         }
         String extensionClasses = out.getProperty( "extensionClasses", "" ).trim();
         if ( extensionClasses.length() > 0 )
diff --git a/src/main/java/org/apache/maven/plugins/shade/resource/ManifestResourceTransformer.java b/src/main/java/org/apache/maven/plugins/shade/resource/ManifestResourceTransformer.java
index fd0bf48..688078c 100644
--- a/src/main/java/org/apache/maven/plugins/shade/resource/ManifestResourceTransformer.java
+++ b/src/main/java/org/apache/maven/plugins/shade/resource/ManifestResourceTransformer.java
@@ -19,10 +19,9 @@
  * under the License.
  */
 
-import org.apache.maven.plugins.shade.relocation.Relocator;
-
 import java.io.IOException;
 import java.io.InputStream;
+import java.util.Arrays;
 import java.util.List;
 import java.util.Map;
 import java.util.jar.Attributes;
@@ -31,6 +30,8 @@
 import java.util.jar.JarOutputStream;
 import java.util.jar.Manifest;
 
+import org.apache.maven.plugins.shade.relocation.Relocator;
+
 /**
  * A resource processor that allows the arbitrary addition of attributes to
  * the first MANIFEST.MF that is found in the set of JARs being processed, or
@@ -42,17 +43,39 @@
 public class ManifestResourceTransformer
     implements ResourceTransformer
 {
-
+    private final List<String> defaultAttributes = Arrays.asList( "Export-Package",
+                                                                  "Import-Package",
+                                                                  "Provide-Capability",
+                                                                  "Require-Capability" ); 
+    
     // Configuration
     private String mainClass;
 
     private Map<String, Object> manifestEntries;
 
+    private List<String> additionalAttributes;
+
     // Fields
     private boolean manifestDiscovered;
 
     private Manifest manifest;
+    
+    public void setMainClass( String mainClass )
+    {
+        this.mainClass = mainClass;
+    }
+    
+    public void setManifestEntries( Map<String, Object> manifestEntries )
+    {
+        this.manifestEntries = manifestEntries;
+    }
+    
+    public void setAdditionalAttributes( List<String> additionalAttributes )
+    {
+        this.additionalAttributes = additionalAttributes;
+    }
 
+    @Override
     public boolean canTransformResource( String resource )
     {
         if ( JarFile.MANIFEST_NAME.equalsIgnoreCase( resource ) )
@@ -63,6 +86,7 @@
         return false;
     }
 
+    @Override
     public void processResource( String resource, InputStream is, List<Relocator> relocators )
         throws IOException
     {
@@ -72,15 +96,46 @@
         if ( !manifestDiscovered )
         {
             manifest = new Manifest( is );
+
+            if ( relocators != null && !relocators.isEmpty() ) 
+            {
+                final Attributes attributes = manifest.getMainAttributes();
+
+                for ( final String attribute : defaultAttributes )
+                {
+                    final String attributeValue = attributes.getValue( attribute );
+                    if ( attributeValue != null )
+                    {
+                        String newValue = relocate( attributeValue, relocators );
+                        attributes.putValue( attribute, newValue );
+                    }
+                }
+
+                if ( additionalAttributes != null )
+                {
+                    for ( final String attribute : additionalAttributes )
+                    {
+                        final String attributeValue = attributes.getValue( attribute );
+                        if ( attributeValue != null )
+                        {
+                            String newValue = relocate( attributeValue, relocators );
+                            attributes.putValue( attribute, newValue );
+                        }
+                    }
+                }
+            }
+
             manifestDiscovered = true;
         }
     }
 
+    @Override
     public boolean hasTransformedResource()
     {
         return true;
     }
 
+    @Override
     public void modifyOutputStream( JarOutputStream jos )
         throws IOException
     {
@@ -108,4 +163,20 @@
         jos.putNextEntry( new JarEntry( JarFile.MANIFEST_NAME ) );
         manifest.write( jos );
     }
+    
+    private String relocate( String originalValue, List<Relocator> relocators )
+    {
+        String newValue = originalValue;
+        for ( Relocator relocator : relocators )
+        {
+            String value;
+            do
+            {
+                value = newValue;
+                newValue = relocator.relocateClass( value );
+            }
+            while ( !value.equals( newValue ) );
+        }
+        return newValue;
+    }
 }
diff --git a/src/site/apt/examples/resource-transformers.apt.vm b/src/site/apt/examples/resource-transformers.apt.vm
index 7248027..1482baa 100644
--- a/src/site/apt/examples/resource-transformers.apt.vm
+++ b/src/site/apt/examples/resource-transformers.apt.vm
@@ -387,6 +387,18 @@
                             
     * the <<<X-Compile-Target-JDK>>> entry to the value of the <<<maven.compile.target>>> property.
 
+  By default the <<<ManifestResourceTransformer>>> will relocate the following attributes:
+
+    * Export-Package
+
+    * Import-Package
+
+    * Provide-Capability
+
+    * Require-Capability
+
+  With <<<additionalAttributes>>> you can specify the attributes that need to be relocated too.
+   
                             
 +-----
 <project>
diff --git a/src/test/java/org/apache/maven/plugins/shade/resource/GroovyResourceTransformerTest.java b/src/test/java/org/apache/maven/plugins/shade/resource/GroovyResourceTransformerTest.java
index d19f2b6..b190e86 100644
--- a/src/test/java/org/apache/maven/plugins/shade/resource/GroovyResourceTransformerTest.java
+++ b/src/test/java/org/apache/maven/plugins/shade/resource/GroovyResourceTransformerTest.java
@@ -73,13 +73,15 @@
     {
         File tempJar = File.createTempFile( "shade.", ".jar" );
         tempJar.deleteOnExit();
-        FileOutputStream fos = new FileOutputStream( tempJar );
-        JarOutputStream jaos = new JarOutputStream( fos );
-        transformer.modifyOutputStream( jaos );
-        jaos.close();
+
+        try ( FileOutputStream fos = new FileOutputStream( tempJar );
+              JarOutputStream jaos = new JarOutputStream( fos ) )
+        {
+            transformer.modifyOutputStream( jaos );
+        }
+        
         Properties desc = null;
-        JarFile jar = new JarFile( tempJar );
-        try
+        try ( JarFile jar = new JarFile( tempJar ) )
         {
             ZipEntry entry = jar.getEntry( GroovyResourceTransformer.EXT_MODULE_NAME );
             if ( entry != null )
@@ -88,10 +90,6 @@
                 desc.load( jar.getInputStream( entry ) );
             }
         }
-        finally
-        {
-            jar.close();
-        }
         return desc;
     }
 
@@ -100,6 +98,7 @@
     {
         GroovyResourceTransformer transformer = new GroovyResourceTransformer();
         assertTrue( transformer.canTransformResource( GroovyResourceTransformer.EXT_MODULE_NAME ) );
+        assertTrue( transformer.canTransformResource( GroovyResourceTransformer.EXT_MODULE_NAME_LEGACY ) );
         assertFalse( transformer.canTransformResource( "somethingElse" ) );
         assertFalse( transformer.canTransformResource( JarFile.MANIFEST_NAME ) );
     }
diff --git a/src/test/java/org/apache/maven/plugins/shade/resource/ManifestResourceTransformerTest.java b/src/test/java/org/apache/maven/plugins/shade/resource/ManifestResourceTransformerTest.java
new file mode 100644
index 0000000..c1c7ff2
--- /dev/null
+++ b/src/test/java/org/apache/maven/plugins/shade/resource/ManifestResourceTransformerTest.java
@@ -0,0 +1,170 @@
+package org.apache.maven.plugins.shade.resource;
+
+/*
+ * 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.
+ */
+
+import static org.junit.Assert.assertEquals;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+import java.util.jar.Attributes;
+import java.util.jar.JarFile;
+import java.util.jar.JarInputStream;
+import java.util.jar.JarOutputStream;
+import java.util.jar.Manifest;
+
+import org.apache.maven.plugins.shade.relocation.Relocator;
+import org.apache.maven.plugins.shade.relocation.SimpleRelocator;
+import org.junit.Before;
+import org.junit.Test;
+
+public class ManifestResourceTransformerTest
+{
+    private ManifestResourceTransformer transformer;
+    
+    @Before
+    public void setUp() 
+    {
+        transformer = new ManifestResourceTransformer();
+    }
+
+    @Test
+    public void rewriteDefaultAttributes() throws Exception
+    {
+        final Manifest manifest = new Manifest();
+        final Attributes attributes = manifest.getMainAttributes();
+        attributes.put(Attributes.Name.MANIFEST_VERSION, "1.0");
+        attributes.putValue("Export-Package",
+                "javax.decorator;version=\"2.0\";uses:=\"javax.enterprise.inject\"," +
+                        "javax.enterprise.context;version=\"2.0\";uses:=\"javax.enterprise.util,javax.inject\"");
+        attributes.putValue("Import-Package",
+                "javax.el,javax.enterprise.context;version=\"[2.0,3)\"");
+        attributes.putValue("Provide-Capability",
+                "osgi.contract;osgi.contract=JavaCDI;uses:=\"" +
+                        "javax.enterprise.context,javax.enterprise.context.spi,javax.enterprise.context.control," +
+                        "javax.enterprise.util,javax.enterprise.inject,javax.enterprise.inject.spi," +
+                        "javax.enterprise.inject.spi.configurator,javax.enterprise.inject.literal," +
+                        "javax.enterprise.inject.se,javax.enterprise.event,javax.decorator\";" +
+                        "version:List<Version>=\"2.0,1.2,1.1,1.0\"");
+        attributes.putValue("Require-Capability",
+                "osgi.serviceloader;" +
+                        "filter:=\"(osgi.serviceloader=javax.enterprise.inject.se.SeContainerInitializer)\";" +
+                        "cardinality:=multiple," +
+                        "osgi.serviceloader;" +
+                        "filter:=\"(osgi.serviceloader=javax.enterprise.inject.spi.CDIProvider)\";" +
+                        "cardinality:=multiple,osgi.extender;" +
+                        "filter:=\"(osgi.extender=osgi.serviceloader.processor)\"," +
+                        "osgi.contract;osgi.contract=JavaEL;filter:=\"(&(osgi.contract=JavaEL)(version=2.2.0))\"," +
+                        "osgi.contract;osgi.contract=JavaInterceptor;" +
+                        "filter:=\"(&(osgi.contract=JavaInterceptor)(version=1.2.0))\"," +
+                        "osgi.contract;osgi.contract=JavaInject;" +
+                        "filter:=\"(&(osgi.contract=JavaInject)(version=1.0.0))\"," +
+                        "osgi.ee;filter:=\"(&(osgi.ee=JavaSE)(version=1.8))\"");
+        
+        List<Relocator> relocators =
+            Collections.<Relocator>singletonList( new SimpleRelocator( "javax", "jakarta",
+                                                                       Collections.<String>emptyList(),
+                                                                       Collections.<String>emptyList() ) );
+        
+        final ByteArrayOutputStream out = transform( manifest, relocators );
+
+        try ( final JarInputStream jis = new JarInputStream( new ByteArrayInputStream( out.toByteArray() ) ) )
+        {
+            final Attributes attrs = jis.getManifest().getMainAttributes();
+            assertEquals(
+                    "jakarta.decorator;version=\"2.0\";uses:=\"jakarta.enterprise.inject\"," +
+                    "jakarta.enterprise.context;version=\"2.0\";uses:=\"jakarta.enterprise.util," +
+                    "jakarta.inject\"",
+                    attrs.getValue("Export-Package"));
+            assertEquals("jakarta.el,jakarta.enterprise.context;version=\"[2.0,3)\"",
+                    attrs.getValue("Import-Package"));
+            assertEquals(
+                    "osgi.contract;osgi.contract=JavaCDI;" +
+                            "uses:=\"jakarta.enterprise.context," +
+                            "jakarta.enterprise.context.spi,jakarta.enterprise.context.control," +
+                            "jakarta.enterprise.util,jakarta.enterprise.inject,jakarta.enterprise.inject.spi," +
+                            "jakarta.enterprise.inject.spi.configurator,jakarta.enterprise.inject.literal," +
+                            "jakarta.enterprise.inject.se,jakarta.enterprise.event," +
+                            "jakarta.decorator\";version:List<Version>=\"2.0,1.2,1.1,1.0\"",
+                    attrs.getValue("Provide-Capability"));
+            assertEquals(
+                    "osgi.serviceloader;" +
+                            "filter:=\"(osgi.serviceloader=jakarta.enterprise.inject.se.SeContainerInitializer)\";" +
+                            "cardinality:=multiple,osgi.serviceloader;" +
+                            "filter:=\"(osgi.serviceloader=jakarta.enterprise.inject.spi.CDIProvider)\";" +
+                            "cardinality:=multiple,osgi.extender;" +
+                            "filter:=\"(osgi.extender=osgi.serviceloader.processor)\"," +
+                            "osgi.contract;osgi.contract=JavaEL;filter:=\"(&(osgi.contract=JavaEL)(version=2.2.0))\"," +
+                            "osgi.contract;osgi.contract=JavaInterceptor;" +
+                            "filter:=\"(&(osgi.contract=JavaInterceptor)(version=1.2.0))\"," +
+                            "osgi.contract;osgi.contract=JavaInject;" +
+                            "filter:=\"(&(osgi.contract=JavaInject)(version=1.0.0))\"," +
+                            "osgi.ee;filter:=\"(&(osgi.ee=JavaSE)(version=1.8))\"",
+                    attrs.getValue("Require-Capability"));
+        }
+    }
+    
+    @Test
+    public void rewriteAdditionalAttributes() throws Exception
+    {
+        final Manifest manifest = new Manifest();
+        final Attributes attributes = manifest.getMainAttributes();
+        attributes.put(Attributes.Name.MANIFEST_VERSION, "1.0");
+        attributes.putValue("description-custom",
+                "This jar uses javax packages");
+        
+        List<Relocator> relocators =
+            Collections.<Relocator>singletonList( new SimpleRelocator( "javax", "jakarta",
+                                                                       Collections.<String>emptyList(),
+                                                                       Collections.<String>emptyList() ) );
+        
+        transformer.setAdditionalAttributes( Arrays.asList("description-custom", "attribute-unknown") );
+        final ByteArrayOutputStream out = transform( manifest, relocators );
+
+        try ( final JarInputStream jis = new JarInputStream( new ByteArrayInputStream( out.toByteArray() ) ) )
+        {
+            final Attributes attrs = jis.getManifest().getMainAttributes();
+            assertEquals( "This jar uses jakarta packages", attrs.getValue( "description-custom" ) );
+        }
+    }
+
+    private ByteArrayOutputStream transform( final Manifest manifest, List<Relocator> relocators )
+        throws IOException
+    {
+        final ByteArrayOutputStream mboas = new ByteArrayOutputStream();
+        try ( final OutputStream mos = mboas )
+        {
+            manifest.write( mos );
+        }
+        transformer.processResource( JarFile.MANIFEST_NAME, new ByteArrayInputStream( mboas.toByteArray() ),
+                                     relocators );
+
+        final ByteArrayOutputStream out = new ByteArrayOutputStream();
+        try ( final JarOutputStream jarOutputStream = new JarOutputStream( out ) )
+        {
+            transformer.modifyOutputStream( jarOutputStream );
+        }
+        return out;
+    }
+}
\ No newline at end of file