Reputation: 36219
Let's say I have two projects on my machine, ProjectA and ProjectB; ProjectB uses ProjectA as a dependency.
I publish both of these packages separately as well. Now I want to develop locally, make changes to A but test is in B. How do I "link" ProjectA locally in ProjectB so that when I run ProjectB, it is using the local ProjectA and not the published package?
Upvotes: 0
Views: 306
Reputation: 2863
First of all, when referencing maven dependencies, you can use a fixed version number like 5.2.0
or a SNAPHOT
-version like 5.2.0-SNAPSHOT
, which has the semantics as being currently in development or work in progress. Also, those versions are associated with an update timestamp in the repository to decide which SNAPHOT
version is the newest.
Project A:
.pom
to a SNAPHOT
-version. (In multi-module projects, you can use [1] instead to not change every version manually.)mvn install
your artifact to the local maven repository.Project B:
SNAPSHOT
-version for project A in the dependencies section.mvn compile
and the new version will be used.Remember that releases sould not contain references to snaphot versions. To automate this process (of changing back an forth between snapshot and release), you can use [2].
mvn versions:set -DnewVersion=your_new_version
to change a version.mvn versions:commit
or mvn versions:rollback
respecively.Upvotes: 1