Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

maven-eclipse-plugin: how to force to use a jar dependency rather than project dependency

Encountered a problem when using maven's Eclipse plugin. In the same workspace, there are two projects, A and B.
Project A will be provided as a jar to a 3rd-party and Project B was created to simulate the scene to use A. So definitely I want jar dependency in B rather than project dependency.
In B's pom.xml:

<dependency>
    <groupId>com.foo.bar</groupId>
    <artifactId>artifact-A</artifactId>
    <version>1.0-SNAPSHOT</version>
    <type>jar</type>
</dependency>

As mvn eclipse:clean eclipse:eclipse executed successfully on B, I always got project dependency. The workaround is to modify .classpath file, or just copy B to another workspace, but both is inconvenient.

maven 3.0.2; eclipse 3.7 without m2eclipse

like image 953
fwonce Avatar asked Oct 25 '11 07:10

fwonce


2 Answers

You need to set the maven-eclipse-plugin's useProjectResources to false. This way the project should only use jar dependencies directly and not reference any projects.

mvn eclipse:eclipse -Declipse.useProjectReferences=false
like image 112
Antti Kolehmainen Avatar answered Nov 04 '22 20:11

Antti Kolehmainen


Try disabling workspace resolution (right click project B, Maven -> Disable Workspace Resolution). If you want a more sure way, simply closing project A in Eclipse is sufficient.

like image 32
Steven Schlansker Avatar answered Nov 04 '22 20:11

Steven Schlansker