Maven:在解除嵌套依赖关系时发出问题

时间:2017-01-29 08:20:12

标签: java eclipse maven intellij-idea

我有项目A,它依赖于项目B,它进一步依赖于项目C,进一步依赖于项目C. A-> B - > C-> d

第一个项目B使用maven shade插件构建, 所以B jar依赖于C和D

现在,当我在A中包含项目B时,A已经具有不同版本的D的依赖关系。 当我排除 我从项目B中排除了D.但没有任何反应。

在Project A pom.xml中:

<dependencies>
    <dependency>
      <groupId>sample.ProjectB</groupId>
      <artifactId>Project-B</artifactId>
      <version>1.0-SNAPSHOT</version>
      <exclusions>
        <exclusion>
          <groupId>sample.ProjectD</groupId> <!-- Exclude Project-D from Project-B -->
          <artifactId>Project-D</artifactId>
        </exclusion>
      </exclusions>
    </dependency>
  </dependencies>



 mvn dependecy:tree doesnt show that it has C in its path or D in its path after exclude. 
    But within scala class, I am able to use classes from package D. 

    When I open the Jar of B, I can see C and D as classPaths in B. Is it anything to do be maven-shade ?

带有构建标记的My Maven Pom:

<build>
    <finalName>dp-experiment</finalName>
    <plugins>
        <plugin>
            <groupId>org.scala-tools</groupId>
            <artifactId>maven-scala-plugin</artifactId>
            <version>2.15.0</version>
            <executions>
                <execution>
                    <goals>
                        <goal>compile</goal>
                        <goal>testCompile</goal>
                    </goals>
                    <configuration>
                        <args>
                            <arg>-make:transitive</arg>
                            <arg>-dependencyfile</arg>
                            <arg>${project.build.directory}/.scala_dependencies</arg>
                        </args>
                    </configuration>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-jar-plugin</artifactId>
            <configuration>
                <outputDirectory>${basedir}/target</outputDirectory>
            </configuration>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-shade-plugin</artifactId>
            <configuration>
                <filters>
                    <filter>
                        <artifact>*:*</artifact>
                        <excludes>
                            <exclude>META-INF/*.SF</exclude>
                            <exclude>META-INF/*.DSA</exclude>
                            <exclude>META-INF/*.RSA</exclude>
                        </excludes>
                    </filter>
                </filters>
                <createDependencyReducedPom>false</createDependencyReducedPom>
                <keepDependenciesWithProvidedScope>true</keepDependenciesWithProvidedScope>
            </configuration>
            <executions>
                <execution>
                    <phase>package</phase>
                    <goals>
                        <goal>shade</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.7</version>
            <configuration>
                <skipTests>false</skipTests>
            </configuration>
        </plugin>
    </plugins>

</build>

我能在项目A pom中做些什么? 排除B中的C罐

我无法做什么? 排除C中任何依赖关系的jar或B内依赖关系的内部依赖关系。

0 个答案:

没有答案