Author: rfscholte Date: Sat Aug 19 11:38:02 2017 New Revision: 1805501 URL: http://svn.apache.org/viewvc?rev=1805501&view=rev Log: [MSHADE-242] Plugin does not work with Java 9 Upgraded ASM + JDependency Adjust code due to dependency upgrades
Modified: maven/plugins/trunk/maven-shade-plugin/pom.xml maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/DefaultShader.java maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/filter/MinijarFilter.java Modified: maven/plugins/trunk/maven-shade-plugin/pom.xml URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-shade-plugin/pom.xml?rev=1805501&r1=1805500&r2=1805501&view=diff ============================================================================== --- maven/plugins/trunk/maven-shade-plugin/pom.xml (original) +++ maven/plugins/trunk/maven-shade-plugin/pom.xml Sat Aug 19 11:38:02 2017 @@ -62,7 +62,7 @@ <properties> <mavenVersion>3.0</mavenVersion> <currentVersion>${project.version}</currentVersion> - <asmVersion>5.1</asmVersion> + <asmVersion>6.0_BETA</asmVersion> </properties> <contributors> @@ -112,7 +112,7 @@ <dependency> <groupId>org.apache.maven.shared</groupId> <artifactId>maven-artifact-transfer</artifactId> - <version>0.9.0</version> + <version>0.9.1</version> </dependency> <!-- Others --> <dependency> @@ -143,7 +143,7 @@ <dependency> <groupId>org.vafer</groupId> <artifactId>jdependency</artifactId> - <version>1.1</version> + <version>1.2</version> </dependency> <dependency> <groupId>org.codehaus.plexus</groupId> @@ -200,6 +200,29 @@ </excludes> </configuration> </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-enforcer-plugin</artifactId> + <executions> + <execution> + <id>enforce-bytecode-version</id> + <configuration> + <rules> + <enforceBytecodeVersion> + <ignoreClasses> + <ignoreClass>module-info</ignoreClass> + </ignoreClasses> + </enforceBytecodeVersion> + </rules> + </configuration> + </execution> + </executions> + </plugin> + <plugin> + <groupId>org.apache.maven.plugins</groupId> + <artifactId>maven-plugin-plugin</artifactId> + <version>3.5</version> + </plugin> </plugins> </pluginManagement> Modified: maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/DefaultShader.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/DefaultShader.java?rev=1805501&r1=1805500&r2=1805501&view=diff ============================================================================== --- maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/DefaultShader.java (original) +++ maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/DefaultShader.java Sat Aug 19 11:38:02 2017 @@ -19,23 +19,6 @@ package org.apache.maven.plugins.shade; * under the License. */ -import com.google.common.base.Joiner; -import com.google.common.collect.HashMultimap; -import com.google.common.collect.Multimap; -import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.plugins.shade.filter.Filter; -import org.apache.maven.plugins.shade.relocation.Relocator; -import org.apache.maven.plugins.shade.resource.ManifestResourceTransformer; -import org.apache.maven.plugins.shade.resource.ResourceTransformer; -import org.codehaus.plexus.component.annotations.Component; -import org.codehaus.plexus.logging.AbstractLogEnabled; -import org.codehaus.plexus.util.IOUtil; -import org.objectweb.asm.ClassReader; -import org.objectweb.asm.ClassVisitor; -import org.objectweb.asm.ClassWriter; -import org.objectweb.asm.commons.Remapper; -import org.objectweb.asm.commons.RemappingClassAdapter; - import java.io.BufferedOutputStream; import java.io.File; import java.io.FileOutputStream; @@ -59,6 +42,25 @@ import java.util.regex.Matcher; import java.util.regex.Pattern; import java.util.zip.ZipException; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugins.shade.filter.Filter; +import org.apache.maven.plugins.shade.relocation.Relocator; +import org.apache.maven.plugins.shade.resource.ManifestResourceTransformer; +import org.apache.maven.plugins.shade.resource.ResourceTransformer; +import org.codehaus.plexus.component.annotations.Component; +import org.codehaus.plexus.logging.AbstractLogEnabled; +import org.codehaus.plexus.util.IOUtil; +import org.objectweb.asm.ClassReader; +import org.objectweb.asm.ClassVisitor; +import org.objectweb.asm.ClassWriter; +import org.objectweb.asm.commons.ClassRemapper; +import org.objectweb.asm.commons.Remapper; + + +import com.google.common.base.Joiner; +import com.google.common.collect.HashMultimap; +import com.google.common.collect.Multimap; + /** * @author Jason van Zyl */ @@ -175,6 +177,13 @@ public class DefaultShader // later continue; } + + if ( "module-info.class".equals( name ) ) + { + getLogger().warn( "Discovered module-info.class. " + + "Shading will break its strong encapsulation." ); + continue; + } if ( !entry.isDirectory() && !isFiltered( jarFilters, name ) ) { @@ -425,7 +434,7 @@ public class DefaultShader ClassWriter cw = new ClassWriter( 0 ); final String pkg = name.substring( 0, name.lastIndexOf( '/' ) + 1 ); - ClassVisitor cv = new RemappingClassAdapter( cw, remapper ) + ClassVisitor cv = new ClassRemapper( cw, remapper ) { @Override public void visitSource( final String source, final String debug ) Modified: maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/filter/MinijarFilter.java URL: http://svn.apache.org/viewvc/maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/filter/MinijarFilter.java?rev=1805501&r1=1805500&r2=1805501&view=diff ============================================================================== --- maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/filter/MinijarFilter.java (original) +++ maven/plugins/trunk/maven-shade-plugin/src/main/java/org/apache/maven/plugins/shade/filter/MinijarFilter.java Sat Aug 19 11:38:02 2017 @@ -102,6 +102,10 @@ public class MinijarFilter } removable = cp.getClazzes(); + if ( removable.remove( new Clazz( "module-info" ) ) ) + { + log.warn( "Removing module-info from " + artifactFile.getName() ); + } removePackages( artifactUnit ); removable.removeAll( artifactUnit.getClazzes() ); removable.removeAll( artifactUnit.getTransitiveDependencies() );