I want to rename the artifact id of my maven project which is fairly easy however, I want to also provide information to the old artifact that the artifact is renamed and the newer version can be found elsewhere. I am not quite sure whether that can be configured in the pom. I have seen it with multiple exisitng libraries already, but I can't find a clear documentation how to accomplish it. An example would be javax to jakarta, see here: https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api
It clearly stated that the artifact has been moved to a new place either with a different groupid or artifactid.
I want to provide the same information to my library so others still referring to the old url on maven or still searching to the old name can easily discover the new name.
So how can I achieve that for example if I have the following name:
<groupId>io.github.hakky54</groupId>
<artifactId>foo</artifactId>
<version>5.0.0</version>
which I want to link to:
<groupId>io.github.hakky54</groupId>
<artifactId>bar</artifactId>
<version>1.0.0</version>
In this case the artifact id and the version number has been changed
You can achieve this using maven's relocation feature by releasing a new version of foo
with the relocated dependency's information.
In the old foo
project’s pom.xml
, add:
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>io.github.hakky54</groupId>
<artifactId>foo</artifactId>
<version>5.0.1</version>
<packaging>pom</packaging>
<name>Foo (renamed to Bar)</name>
<description>This artifact has been renamed.</description>
<url>https://mvnrepository.com/artifact/io.github.hakky54/bar</url>
<distributionManagement>
<relocation>
<groupId>io.github.hakky54</groupId>
<artifactId>bar</artifactId>
<version>1.0.0</version>
</relocation>
</distributionManagement>
</project>