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

Peter De Maeyer commented on MSHADE-284:
----------------------------------------

OK, that's a fair point, I'll try to do that after I familiarize myself with 
the test code.

> Shaded test JARs are always empty
> ---------------------------------
>
>                 Key: MSHADE-284
>                 URL: https://issues.apache.org/jira/browse/MSHADE-284
>             Project: Maven Shade Plugin
>          Issue Type: Bug
>    Affects Versions: 3.1.0
>            Reporter: Peter De Maeyer
>            Priority: Major
>         Attachments: shadeTestJar.patch
>
>
> Shading test JARs using the {{shadeTestJar}} configuration option yields an 
> empty test JAR. This has been noticed by others, see for example Steve K's 
> answer [on 
> StackOverflow|https://stackoverflow.com/questions/5149130/how-can-i-configure-the-maven-shade-plugin-to-include-test-code-in-my-jar/49617516#49617516],
>  but people have reverted to other hacks and workarounds to overcome this 
> (e.g. use a different plugin).
> Scenario:
>  # Create modules {{api}}, {{impl}} and a module {{uber}} which has as sole 
> purpose to make an uber JAR for the combination of the first two modules. 
> {{uber}} itself has no sources.
>  # Both modules have both {{jar}} and {{test-jar}} artifacts.
>  # Configure the {{maven-shade-plugin}} in the {{uber}} module with the 
> configuration option {{shadeTestJar}} set to {{true}}.
> Expected:
>  # Content of {{uber.jar}} is the aggregate content of {{api.jar}} and 
> {{impl.jar}}.
>  # Content of {{uber-tests.jar}} is the aggregate content of 
> {{api-tests.jar}} and {{impl-tests.jar}}.
> Actual:
>  # Content of {{uber.jar}} is as expected.
>  # {{uber-tests.jar}} is empty.
> Root cause:
>  * The implementation of the {{shadeTestJar}} feature in {{ShaderMojo}} is 
> buggy and incomplete.
>  * The call to {{processArtifactSelectors}} on line 425 doesn't pass the 
> {{testArtifacts}}, so they are never correctly filled in.
>  * The implementation of {{processArtifactSelectors}} doesn't deal with test 
> JARs at all and has to be extended to support them.
>  * The "if" statement on line 452 incorrectly treats a test JAR as sources.
> This whole feature looks like it was done in a hurry as a sloppy copy-paste 
> job, and in 5 years nobody took the time to report or fix it. Amazing. 
> Anyway, you can find my proposed fix in attachment: [^shadeTestJar.patch]. I 
> have tested it manually on my project and it works.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to