Maven版本:prepare用解析的值覆盖SCM属性 [英] Maven release:prepare overwrites SCM properties with resolved values

查看:118
本文介绍了Maven版本:prepare用解析的值覆盖SCM属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我认为这很明显,但是我仍然认为这是一个缺点...

I suppose this is kinda obvious, but I still judge it as a shortcoming...

我有23个Mavenized项目.我现在要添加< scm>有点,因为我已经开始使用发布插件.这是我的思考过程:

I have 23 Mavenized projects. I'm now adding the <scm> bit because I've started using the release plugin. Here was my thought process:

  • 我将添加< scm>部分仅在我的公司 base POM中进行设置,并使用属性(例如
  • )对网址进行参数化
  • I'll add the <scm> section only in my company base POM, and parameterise the URLs with properties, e.g.
<scm>
    <connection>${scmBaseConnection}/${scm.module}/${scm.edition}</connection>
    <developerConnection>${scmBaseConnection}/${scm.module}/${scm.edition}</developerConnection>
    <url>${fisheyeBaseUrl}/${scm.module}</url>
</scm>

  • 然后,每个项目根(聚合器)POM只需声明其 scm. <properties>(不必重新声明整个< scm>部分),例如:
    • Then each project root (aggregator) POM need only declare its scm. <properties> accordingly (and not have to re-declare the whole <scm> section), e.g.:
    •    <scm.module>sharktopus</scm.module>
         <scm.edition>trunk</scm.edition>
      

      但是我很快意识到我无法做到这一点:发布插件使用 tag next 版本的每个POM重写 SCM信息,因此每个这样的POM都需要其自己的< scm>部分.

      But I soon realised that I can't do that: the release plugin rewrites each POM with the tag and next versions of the SCM info, so each such POM needs its own <scm> section.

      很好,所以我决定将常见的SCM详细信息存储在基本POM属性中,并让每个项目根POM声明其< scm>使用这些道具的部分以及其自身的详细信息,例如:

      Fine, so I decided I'll store the common SCM details in base POM properties, and have each project root POM declare its <scm> section using those props, plus its own specifics e.g.:

      <scm>
          <connection>${scmBaseConnection}/sharktopus/trunk</connection>
          <developerConnection>${scmBaseConnection}/sharktopus/trunk</developerConnection>
          <url>${fisheyeBaseUrl}/sharktopus</url>
      </scm>
      

      但这也不起作用,因为发布插件使用 resolved 值重写(事后看来,这很明显).因此,例如对于 release标签 POM,上面的信息将被重写为:

      But that doesn't work either, because the release plugin rewrites using the resolved values (which is kinda obvious, in hindsight). So, e.g. for the release tag POM, the info above would be rewritten as:

      <scm>
          <connection>scm:svn:https://mysvnhost.net/sharktopus/tags/R1_NewStuff</connection>
          <developerConnection>scm:svn:https://mysvnhost.net/sharktopus/tags/R1_NewStuff</developerConnection>
          <url>https://mysvnhost.net/sharktopus</url>
      </scm>
      

      这意味着每个POM必须具有其自己的< scm>具有硬编码URL 的部分.

      This means that each POM must have its own <scm> section with hardcoded URLs.

      • 这是每个人都在做什么吗?
      • 如果您的SCM URL发生了变化,会发生什么-您只是在所有项目中进行搜索/替换吗?
      • 是否可以要求版本插件重写部分网址,例如保留属性引用,但覆盖最终"细节?

      推荐答案

      定义scm部分的唯一位置是项目根目录而不是公司根目录.在多模块构建中,仅需要一个scm部分.发布插件将替换属性的原因非常简单.发布后,这些pom必须代表该软件的状态.如果它们具有属性,就无法保证正确的值等.因此结果将无法重现... 如果SCM URL更改,则仅对新项目有效,而对旧项目无效,因为它们已经被部署等.

      The only place to define scm part is in the project root not company root. In a multimodule build it's needed to have only a single scm part. The reason that the release plugin will replace the properties is very simple. After a release these pom's must represent that state for that software. If they would have properties in it would be imposible to gurantee the corret values etc. So the result would not reproducible... If the SCM URL changes it will be valid only for new projects and not for the old ones, cause they are already been deployed etc.

      这篇关于Maven版本:prepare用解析的值覆盖SCM属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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