Reputation: 180
I have a fork artifact from one who stored in repo.maven.apache.org, it has the same group, artifact id and version. My fork is stored in my.repo.hostname.
How can I force Maven to use artifact from my repository, not from Maven Central?
Upvotes: 3
Views: 2024
Reputation: 27812
When forking an original artifact, you should use classifiers to make a distinction.
So, if the original artifact was:
<dependency>
<groupId>com.sample</groupId>
<artifactId>library</artifactId>
<version>1.0</version>
</dependency>
You can have your fork as:
<dependency>
<groupId>com.sample</groupId>
<artifactId>library</artifactId>
<version>1.0</version>
<classifier>myfork</classifier>
</dependency>
Advantages of this approach:
For the classifier name (it's a free string) I often found useful to provide additional information:
Using classifier in this case it is also a Maven recommended approach, from official documentation:
The classifier allows to distinguish artifacts that were built from the same POM but differ in their content. It is some optional and arbitrary string that - if present - is appended to the artifact name just after the version number.
As such, no repository order or any other type of issue would be present and your build will gain clarity, reproducibility and maintainability. Hope it might help.
Upvotes: 3