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

Reply via email to