Maven Pom搬迁 [英] Maven pom relocation

查看:165
本文介绍了Maven Pom搬迁的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以将POM(而不是罐子)重新放置到新的groupIdartifactId?我能够使用重定位POM重定位jar,但是无法重定位用于进行依赖项管理的POM.

Is it possible to relocate a POM (not the jars) to a new groupId and artifactId? I was able to relocate jars with a relocation POM but unable to relocate a POM we use to do dependency management.

推荐答案

以下内容来自

  • 将所有与foo相关的文件从Maven存储库中的/bar/foo/复制到一个临时位置.
  • 在临时位置的所有与foo相关的pom文件中,将groupId更改为org.bar.
  • 将所有文件从临时位置复制到Maven 2存储库中的/org/bar/foo/.
  • 为您的Maven 2存储库中的每个旧版本的foo创建一个最小的Maven pom文件. pom文件只需要包含groupId,artifactId,version和relocation部分.

    • Copy all foo-related files from /bar/foo/ in your Maven repository to a temporary location.
    • Change the groupId to org.bar in all foo-related pom files in the temporary location.
    • Copy all files from the temporary location to /org/bar/foo/ in your Maven 2 repository.
    • Create a minimal Maven pom file for every old release of foo in your Maven 2 repository. The pom files only need to include groupId, artifactId, version and the relocation section.

    注意:在用这些最小的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屋!

  • 查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆