helloworld
helloworld

Reputation: 31

How to include maven dependency stated on other project to my project?

So here is the structure of my project:

pom.xml
--myproject1/pom.xml
--myproject2/pom.xml

This is the dependency that I want to include:

<dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>${junit.version}</version>
    <scope>test</scope>
</dependency>

Right now I have this dependency stated on parent pom.xml. And myproject2 has myproject1 stated as its dependency.

Because of some reason, I want to move this dependency out of parent pom.xml and move it to myproject1/pom.xml. However, it seems that myproject2 cannot access the junit dependency even though myproject1 is listed as one of its dependencies.

Any idea how can I do this?

Upvotes: 2

Views: 37

Answers (1)

michaldo
michaldo

Reputation: 4609

scope test is not transitive. That's all.

If you want junit in myproject2 and you want keep junit out of parent pom then you must declare that myproject2 depends on junit.

Upvotes: 1

Related Questions