diff --git a/pom.xml b/pom.xml index 8fca8d3e..cb10a847 100644 --- a/pom.xml +++ b/pom.xml @@ -78,6 +78,9 @@ Anthony Dahanne + + Fabiano Cipriano de Oliveira + diff --git a/src/main/java/org/apache/maven/plugins/shade/resource/ServicesResourceTransformer.java b/src/main/java/org/apache/maven/plugins/shade/resource/ServicesResourceTransformer.java index f1cb9d64..d0875226 100644 --- a/src/main/java/org/apache/maven/plugins/shade/resource/ServicesResourceTransformer.java +++ b/src/main/java/org/apache/maven/plugins/shade/resource/ServicesResourceTransformer.java @@ -138,20 +138,6 @@ public void modifyOutputStream( JarOutputStream jos ) while ( ( className = reader.readLine() ) != null ) { - - if ( relocators != null ) - { - for ( Relocator relocator : relocators ) - { - //if the class can be relocated then relocate it - if ( relocator.canRelocateClass( className ) ) - { - className = relocator.applyToSourceContent( className ); - break; - } - } - } - writer.println( className ); writer.flush(); } diff --git a/src/test/java/org/apache/maven/plugins/shade/resource/ServiceResourceTransformerTest.java b/src/test/java/org/apache/maven/plugins/shade/resource/ServiceResourceTransformerTest.java index a9f78dbd..18dab2ff 100644 --- a/src/test/java/org/apache/maven/plugins/shade/resource/ServiceResourceTransformerTest.java +++ b/src/test/java/org/apache/maven/plugins/shade/resource/ServiceResourceTransformerTest.java @@ -89,6 +89,50 @@ public void relocatedClasses() throws Exception { tempJar.delete(); } } + + @Test + public void concatanationAppliedMultipleTimes() throws Exception { + SimpleRelocator relocator = + new SimpleRelocator( "org.eclipse", "org.eclipse1234", null, null ); + List relocators = Lists.newArrayList( relocator ); + + String content = "org.eclipse.osgi.launch.EquinoxFactory\n"; + byte[] contentBytes = content.getBytes( "UTF-8" ); + InputStream contentStream = new ByteArrayInputStream( contentBytes ); + String contentResource = "META-INF/services/org.osgi.framework.launch.FrameworkFactory"; + + ServicesResourceTransformer xformer = new ServicesResourceTransformer(); + xformer.processResource( contentResource, contentStream, relocators ); + contentStream.close(); + + File tempJar = File.createTempFile("shade.", ".jar"); + tempJar.deleteOnExit(); + FileOutputStream fos = new FileOutputStream( tempJar ); + JarOutputStream jos = new JarOutputStream( fos ); + try { + xformer.modifyOutputStream( jos ); + jos.close(); + jos = null; + JarFile jarFile = new JarFile( tempJar ); + JarEntry jarEntry = jarFile.getJarEntry( contentResource ); + assertNotNull( jarEntry ); + InputStream entryStream = jarFile.getInputStream( jarEntry ); + try { + String xformedContent = IOUtils.toString(entryStream, "utf-8"); + assertEquals( "org.eclipse1234.osgi.launch.EquinoxFactory" + System.getProperty( "line.separator" ), xformedContent ); + + } finally { + IOUtils.closeQuietly( entryStream ); + jarFile.close(); + } + } finally { + if (jos != null) + { + IOUtils.closeQuietly( jos ); + } + tempJar.delete(); + } + } @Test public void concatenation() throws Exception {