maven-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Guillaume Boué (JIRA) <j...@apache.org>
Subject [jira] [Commented] (MSHADE-237) ServicesResourceTransformer relocates excluded classes
Date Fri, 30 Sep 2016 21:31:21 GMT

    [ https://issues.apache.org/jira/browse/MSHADE-237?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15537128#comment-15537128
] 

Guillaume Boué commented on MSHADE-237:
---------------------------------------

Fixed in [r1762963|http://svn.apache.org/viewvc?view=revision&revision=1762963]. Thanks
for the diff!

> 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: 3.0.0, 2.4.3
>            Reporter: James Phillpotts
>
> 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)

Mime
View raw message