fwonce
fwonce

Reputation: 527

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

Upvotes: 5

Views: 3939

Answers (2)

Antti Kolehmainen
Antti Kolehmainen

Reputation: 1091

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

Upvotes: 10

Steven Schlansker
Steven Schlansker

Reputation: 38526

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.

Upvotes: 2

Related Questions