Skip to content

[MSHADE-374] Exclude test shading when shadeTestJar is enabled #706

@jira-importer

Description

@jira-importer

Yana Vasileva opened MSHADE-374 and commented

Scenario:

  • Plugin version - 3.2.3 (I tried with 3.2.4 as well)
  • Maven version - 3.2.5 (old one, so I tried with 3.6.3 as well - same result)
  • Project A shades some libraries - httpclient, commons-coded, commons-logging
  • shadeTestJar is enabled so the created projectA-tests.jar can resolve the shaded source classes
  • The plugin configuration looks similar to the following:
<plugin>
  <groupId>org.apache.maven.plugins</groupId>
  <artifactId>maven-shade-plugin</artifactId>
  <configuration>
    <promoteTransitiveDependencies>false</promoteTransitiveDependencies>
    <createSourcesJar>true</createSourcesJar>
    <createDependencyReducedPom>true</createDependencyReducedPom>
    <keepDependenciesWithProvidedScope>true</keepDependenciesWithProvidedScope>
    <relocations>
      <relocation>
        <pattern>org.apache.http</pattern>
        <shadedPattern>myjar.impl.org.apache.http</shadedPattern>
      </relocation>
      <relocation>
        <pattern>org.apache.commons.codec</pattern>
        <shadedPattern>myjar.impl.org.apache.commons.codec</shadedPattern>
      </relocation>
      <relocation>
        <pattern>org.apache.commons.logging</pattern>
        <shadedPattern>myjar.impl.org.apache.commons.logging</shadedPattern>
      </relocation>
    </relocations>
    <transformers>
      <transformer implementation="org.apache.maven.plugins.shade.resource.ServicesResourceTransformer" />
    </transformers>
    <shadeTestJar>true</shadeTestJar> 
  </configuration>
</plugin>

 

As a result, projectA-tests.jar includes the shaded classes from the commons-codec-tests.jar and commons-logging-tests.jar which cause troubles when some of the tests scenarios are being executed for project A.

Question:
Is it possible to exclude the classes of commons-*-tests.jar and prevent their shading in the projectA-tests.jar?

I tried the following as it is documented here, however, the classes are still shaded:

<artifactSet>
  <excludes>
    <exclude>commons-codec:commons-codec:tests</exclude>
    <exclude>commons-logging:commons-logging:tests</exclude>
  </excludes>
</artifactSet>

Is the observed behavior expected? Is there any way to exclude the tests shading?

Any help is highly appreciated, please let me know if I need to provide some further information.


Affects: 3.2.3, 3.2.4

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions