Search code examples
javaeclipsemavenjar-with-dependencies

How to discard a local dependency in a maven project?


I have a question about the integration the eclipse and maven.

I have a project A with dependencies in project B which is itself just a container for a bunch of projects B-i.

Project B is imported in Eclipse but most of the B-i are not imported in eclipse. Sometimes, I want to work on a patch in B-n. So I import the B-n project and dependency resolving usually works well, that is, project A uses the project B-n and recompiles.

Problem happens often when I want to discard the local dependency, close the local project, and make sure that the remote B-n from our repository is used by A (let's say that the other team patched project B).

What is the good and proper "way" to do that kind of patching/ensure that A is using the remote/server version of B-n and not the previously compiled local jar ?
Removing the local project ? Removing the dependency in the local project ? Will I always have to "clean install" project A when I do such a change ?

Thanks.


Solution

  • If I understand you correctly, you do the following:

    You have a project B-n with a version (say 1.0.0-SNAPSHOT). It is built on some kind of build server.

    Then you check it out, built it locally (still with version 1.0.0-SNAPSHOT). Now you want to discard your locally built version and refer again to the 1.0.0-SNAPSHOT from the repository (correct me if you did not understand you correctly).

    For that, you can purge the local repository by dependency:purge-local-repository. You can start this from Eclipse through "Run As -> Maven Build...". See also

    https://maven.apache.org/plugins/maven-dependency-plugin/examples/purging-local-repository.html