为您的Maven 2存储库中的每个旧版本的foo创建一个最小的Maven pom文件. pom文件只需要包含groupId,artifactId,version和relocation部分.
注意:在用这些最小的pom文件替换/bar/foo/中的旧pom文件之前,请确保已进行备份!
Note: Before you replace your old pom files in /bar/foo/ with these minimal pom files, make sure you have made backups!
对于foo版本1.0,最小的pom文件可能看起来像这样:
The minimal pom file might look like this for version 1.0 of foo:
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>bar</groupId>
<artifactId>foo</artifactId>
<version>1.0</version>
<distributionManagement>
<relocation>
<groupId>org.bar</groupId>
</relocation>
</distributionManagement>
</project>
在这种情况下,由于groupId已更改,因此我们正在重新定位.我们只需要将已更改的元素添加到重定位元素.有关重定位元素中允许哪些元素的信息,请参阅pom参考.
In this case we are relocating because the groupId has changed. We only need to add the element that has changed to the relocation element. For information on which elements are allowed in the relocation element, see the pom reference.
如果您的项目使用MD5或SHA1校验和,则现在必须在Maven存储库中的/bar/foo/中为pom文件创建新的校验和.如果需要对pom文件进行签名,请同样执行该操作.
If your project uses MD5 or SHA1 checksums you must now create new checksums for the pom files in /bar/foo/ in your Maven repository. If the pom file needs to be signed, do that as well.
如果您的项目与Central同步,则现在应该启动该同步.这可能会自动发生,具体取决于您的项目同步策略.
If your project syncs with central, you should now initiate that sync. This might happen automatically depending on your projects sync policy.
您的foo-artifacts现在可用于具有新的groupId和新的groupId的Maven用户.使用旧groupId的项目将自动重定向到新的groupId,并会发出警告,告知用户更新其依赖项.
发布下一个版本
Your foo-artifacts are now available to Maven users with both the old and the new groupId. Projects using the old groupId will automatically be redirected to the new groupId and a warning telling the user to update their dependencies will be issued.
Releasing the next version
下一次发布foo时,应该发布两个Maven pom文件.首先,您应该使用新的groupId org.bar发布pom.
When the next release of foo is made, you should publish two Maven pom files. First you should publish a pom with the new groupId org.bar.
由于不应更改存储库中的数据,因此Maven不会下载已下载的pom文件.因此,您还需要发布带有新版本的旧groupId栏的pom文件.这应该是最小的重定位pom(如上面的第4步所述),但是对于新版本的foo.
Because data in the repository is not supposed to change, Maven doesn't download pom files that it has already downloaded. Therefor you will also need to publish a pom file with the old groupId bar for the new version. This should be a minimal relocation pom (as described in step 4 above), but for the new version of foo.
在此之后的发行中,您只需要发布groupId为org.bar的Maven pom,因为先前版本的用户已获悉已更改的groupId.
For the release after that, you only need to publish a Maven pom with a groupId of org.bar, since users of the previous version have been informed of the changed groupId.
这篇关于Maven Pom搬迁的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!