Can I have partial maven workspace resolution in eclipse?

79 views Asked by At

I have 3 projects - A, B and C.

A has dependencies on B and C, and I deploy A to Tomcat in eclipse.

I want A to deploy with the workspace versions of A and B. I don't want my workspace copy of project C to be picked up (instead I want the installed version in ~/.m2/ to be picked up).

I can achieve this by closing project C in Eclipse. However, I want to keep project C open.

Is this possible?

1

There are 1 answers

0
Jorge_B On BEST ANSWER

You can execute mvn install on your project C with a closed version in your pom.xml file, let's say 1.0. This will leave a 1.0 version of your project C deliverable in your ~/.m2.

Make sure project A pom.xml and project B pom.xml depend on version 1.0 of project C.

For example, Project A and B pom.xml:

...    
<dependency>
       <groupId>myproject</groupId>
       <artifactId>C</artifactId>
       <version>1.0</version>
    </dependency>
...

Then you can just change the version in your project C pom.xml to, let's say 2.0, and then tell Eclipse to update all your maven projects.

Project C pom.xml:

<project>
<modelVersion>4.0.0</modelVersion>
<groupId>myproject</groupId>
<artifactId>C</artifactId>
<version>2.0</version>
...

The situation will be:

  • Eclipse A project depending on Eclipse B project and ~/.m2/.../C/1.0/C.jar.
  • Eclipse B project depending on ~/.m2/.../C/1.0/C.jar.
  • Eclipse C project open but out of the tomcat deploy.

This way you can always adjust maven dependencies back in A and B in order to depend on your development version of C, or just keep them depending on your closed version of C.jar