You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@maven.apache.org by "Guillaume Boué (JIRA)" <ji...@apache.org> on 2016/09/30 23:21:20 UTC
[jira] [Updated] (MSHADE-237) ServicesResourceTransformer relocates
excluded classes
[ https://issues.apache.org/jira/browse/MSHADE-237?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Guillaume Boué updated MSHADE-237:
----------------------------------
Affects Version/s: (was: 3.0.0)
> ServicesResourceTransformer relocates excluded classes
> -------------------------------------------------------
>
> Key: MSHADE-237
> URL: https://issues.apache.org/jira/browse/MSHADE-237
> Project: Maven Shade Plugin
> Issue Type: Bug
> Affects Versions: 2.4.3
> Reporter: James Phillpotts
> Assignee: Guillaume Boué
> Fix For: 3.0.0
>
>
> If an exclude pattern is specified on a relocator, the {{ServicesResourceTransformer}} ignores them.
> This is demonstrated by the test, and fixed in the following:
> {noformat}
> Index: src/main/java/org/apache/maven/plugins/shade/resource/ServicesResourceTransformer.java
> ===================================================================
> --- src/main/java/org/apache/maven/plugins/shade/resource/ServicesResourceTransformer.java (revision 1762668)
> +++ src/main/java/org/apache/maven/plugins/shade/resource/ServicesResourceTransformer.java (working copy)
> @@ -86,7 +86,10 @@
> String relContent = line;
> for ( Relocator relocator : relocators )
> {
> - relContent = relocator.applyToSourceContent( relContent );
> + if ( relocator.canRelocateClass(relContent) )
> + {
> + relContent = relocator.relocateClass(relContent);
> + }
> }
> fout.append( relContent + "\n" );
> }
> Index: src/test/java/org/apache/maven/plugins/shade/resource/ServiceResourceTransformerTest.java
> ===================================================================
> --- src/test/java/org/apache/maven/plugins/shade/resource/ServiceResourceTransformerTest.java (revision 1762668)
> +++ src/test/java/org/apache/maven/plugins/shade/resource/ServiceResourceTransformerTest.java (working copy)
> @@ -27,6 +27,7 @@
> import java.io.File;
> import java.io.FileOutputStream;
> import java.io.InputStream;
> +import java.util.Collections;
> import java.util.List;
> import java.util.jar.JarEntry;
> import java.util.jar.JarFile;
> @@ -46,10 +47,11 @@
>
> @Test
> public void relocatedClasses() throws Exception {
> - SimpleRelocator relocator = new SimpleRelocator("org.foo", "borg.foo", null, null);
> + SimpleRelocator relocator = new SimpleRelocator("org.foo", "borg.foo", null,
> + Collections.singletonList("org.foo.exclude.**"));
> List<Relocator> relocators = Lists.<Relocator>newArrayList( relocator );
>
> - String content = "org.foo.Service\n";
> + String content = "org.foo.Service\norg.foo.exclude.OtherService\n";
> byte[] contentBytes = content.getBytes( "UTF-8" );
> InputStream contentStream = new ByteArrayInputStream( contentBytes );
> String contentResource = "META-INF/services/org.foo.something.another";
> @@ -73,7 +75,8 @@
> InputStream entryStream = jarFile.getInputStream( jarEntry );
> try {
> String xformedContent = IOUtils.toString(entryStream, "utf-8");
> - assertEquals("borg.foo.Service" + System.getProperty( "line.separator" ), xformedContent);
> + assertEquals("borg.foo.Service" + System.getProperty( "line.separator" )
> + + "org.foo.exclude.OtherService" + System.getProperty( "line.separator" ), xformedContent);
> } finally {
> IOUtils.closeQuietly( entryStream );
> jarFile.close();
> {noformat}
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)