You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@maven.apache.org by David Gay <dg...@axway.com> on 2013/08/30 17:47:39 UTC

Maven Shade-Plugin strange behavior

Hi all,

I would like to know if this behavior is normal while using the maven-shade-plugin.

Take this sample pom as input:
<project>
                <modelVersion>4.0.0</modelVersion>
                <groupId>sample</groupId>
                <artifactId>shade-effect</artifactId>
                <packaging>jar</packaging>
                <version>1.0.0-SNAPSHOT</version>
                <build>
                               <plugins>
                                               <plugin>
                                                               <groupId>org.apache.maven.plugins</groupId>
                                                               <artifactId>maven-shade-plugin</artifactId>
                                                               <version>2.1</version>
                                                               <executions>
                                                                              <execution>
                                                                                              <phase>package</phase>
                                                                                              <goals>
                                                                                                              <goal>shade</goal>
                                                                                              </goals>
                                                                                              <configuration>
                                                                                                              <createDependencyReducedPom>true</createDependencyReducedPom>
                                                                                              </configuration>
                                                                              </execution>
                                                               </executions>
                                               </plugin>

                               </plugins>
                </build>
                <dependencies>
                               <dependency>
                                               <groupId>commons-io</groupId>
                                               <artifactId>commons-io</artifactId>
                                               <version>2.4</version>
                               </dependency>
                               <dependency>
                                               <groupId>org.mockito</groupId>
                                               <artifactId>mockito-core</artifactId>
                                               <version>1.9.5</version>
                                               <scope>test</scope>
                               </dependency>
                </dependencies>
</project>

And do a mvn clean install.
The real pom that is deployed in the repository is the one that has been "transformed" by the shade plugin (ie: dependency-reduced-pom.xml)
If I look at this pom, the compile dependencies are removed as expected. Good.
But, if you look at the dependencies with scope test, they is a super strange behavior:

<project>
  <modelVersion>4.0.0</modelVersion>
  <groupId>sample</groupId>
  <artifactId>shade-effect</artifactId>
  <version>1.0.0-SNAPSHOT</version>
  <build>
    <plugins>
      <plugin>
        <artifactId>maven-shade-plugin</artifactId>
        <version>2.1</version>
        <executions>
          <execution>
            <phase>package</phase>
            <goals>
              <goal>shade</goal>
            </goals>
            <configuration>
              <createDependencyReducedPom>true</createDependencyReducedPom>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
  <dependencies>
    <dependency>
      <groupId>org.mockito</groupId>
      <artifactId>mockito-core</artifactId>
      <version>1.9.5</version>
      <scope>test</scope>
      <exclusions>
        <exclusion>
          <artifactId>hamcrest-core</artifactId>
          <groupId>org.hamcrest</groupId>
        </exclusion>
        <exclusion>
          <artifactId>objenesis</artifactId>
          <groupId>org.objenesis</groupId>
        </exclusion>
      </exclusions>
    </dependency>
  </dependencies>
</project>

Why are all the transitive dependencies of the test artifacts being excluded ????
It surprise me a lot (and made some of my jobs fails in specific situations, for example when using Sonar, but that's another story/problem)

BTW: I use Maven 3.0.5

Thanks for your help.
WBR // David


Re: Maven Shade-Plugin strange behavior

Posted by Michael-O <19...@gmx.net>.
Am 2013-08-30 17:47, schrieb David Gay:
> [...]
> Why are all the transitive dependencies of the test artifacts being excluded ????
> It surprise me a lot (and made some of my jobs fails in specific situations, for example when using Sonar, but that's another story/problem)

Please suffer with me: https://jira.codehaus.org/browse/MSHADE-95

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@maven.apache.org
For additional commands, e-mail: users-help@maven.apache.org