I have the following setup:
Master: has modulesAandBA: declares a dependency onB,Masteras its parentB:Masteras its parent
So basically Master has a parent pom which builds A and B where A has a dependency on B.
My problem is that I want to put all of the 3rd party dependencies in B (things like JUnit etc.). But when I do this, A does have access to the depende开发者_高级运维ncies declared by B. Why is this happening? I thought maven handles transitive dependencies.
Here are snippets of my poms just in case:
Master:
<modules>
<module>../A</module>
<module>../B</module>
</modules>
A:
<parent>
<groupId>com.project</groupId>
<artifactId>Master</artifactId>
<version>1</version>
<relativePath>../Master/pom.xml</relativePath>
</parent>
...
<dependency>
...
<artifactId>B</artifactId>
...
</dependency>
B:
<parent>
<groupId>com.project</groupId>
<artifactId>Master</artifactId>
<version>1</version>
<relativePath>../Master/pom.xml</relativePath>
</parent>
...
<dependency>
...
<artifactId>JUnit</artifactId>
...
</dependency>
Why doesn't A have access to JUnit?
If the JUnit dependency in Project B has scope 'test' then I don't believe it will be visibile as a transitive dependency in Project A. See the table in Maven Introduction to the Dependency Mechanism: Dependency Scope.
加载中,请稍侯......
精彩评论