相对于POM中的父SCM URL的SCM URL [英] SCM URL relative to parent SCM URL in POMs

查看:84
本文介绍了相对于POM中的父SCM URL的SCM URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个由几个模块和子模块组成的Maven项目. 我使用SVN对源文件进行版本控制.

I have a Maven project made of several modules and sub-modules. I use SVN to version the source files.

如何在POM文件的scm属性中指定相对于其父文件的URL.

How do I specify URL in scm properties of a POM file, that are relative to the ones of its parent.

某些模块及其子模块共享相同的版本号/发布过程,而某些模块使用独立的版本号/发布过程.对于具有独立版本号的模块,我设置了一个分支/树干/标签布局,以使发布插件感到满意.

Some modules and their sub modules share a common version number / release process, and some use independant ones. For the module with independant version number, I have set up a branches/trunk/tags layout, for the release-plugin to be happy.

为此,我在存储库中有两个SVN布局.一个保存所有的主干/分支/标签混乱,另一个保存一个干净的随时可结帐的工作目录,其中包含svn:对树干的外部引用.

For that, I haveb two SVN layouts in my repository. One holds all the trunk/branches/tags mess, the other one holds a clean ready-to-checkout working directory with svn:external references to the trunks.

这看起来像这样;您拥有真实的SVN布局,并且行李箱/支行/标签杂乱无章:

This looks like this; You have the real world SVN layout, with trunk/branches/tags mess:

  • pom.xml (主要父级)
  • 实用程序
    • 分支机构
    • 标签
    • 树干
      • pom.xml ,src,目标等...
  • pom.xml (main parent)
  • utils
    • branches
    • tags
    • trunk
      • pom.xml, src, target, etc...
  • 分支机构
  • 标签
  • 树干
    • pom.xml
    • lib
      • pom.xml ,src,目标等...
      • branches
      • tags
      • trunk
        • pom.xml
        • lib
          • pom.xml, src, target, etc...
          • pom.xml ,src,目标等...
          • pom.xml, src, target, etc...
          • pom.xml ,src,目标等...
          • pom.xml, src, target, etc...
          • bin-module-1 (已发布)
            • 分支机构
            • 标签
            • 树干
              • pom.xml ,src,目标等...
              • bin-module-1 (released)
                • branches
                • tags
                • trunk
                  • pom.xml, src, target, etc ...
                  • 分支机构
                  • 标签
                  • 树干
                    • pom.xml ,src,目标等...
                    • branches
                    • tags
                    • trunk
                      • pom.xml, src, target, etc...

                      以及工作目录的整洁布局,用"svn:externals"标签隐藏分支/行李箱的东西:

                      And the clean layout of the working direcotry, hidding the branches/trunk stuff with "svn:externals" tags:

                      • pom.xml (主要父级)
                      • 实用程序(-> utils/trunk )
                        • pom.xml ,src,目标等...
                      • pom.xml (main parent)
                      • utils (-> utils/trunk)
                        • pom.xml, src, target, etc...
                      • pom.xml
                        • lib
                          • pom.xml ,src,目标等...
                          • pom.xml
                            • lib
                              • pom.xml, src, target, etc...
                              • pom.xml ,src,目标等...
                              • pom.xml, src, target, etc...
                              • pom.xml ,src,目标等...
                              • pom.xml, src, target, etc...
                              • pom.xml
                              • bin-module-1 (-> bin-module-1/trunk )
                                • pom.xml ,src,目标等...
                                • pom.xml
                                • bin-module-1 (-> bin-module-1/trunk)
                                  • pom.xml, src, target, etc ...
                                  • pom.xml ,src,目标等...
                                  • pom.xml, src, target, etc...

                                  到目前为止,太好了. 我已经在父POM中设置了根SCM URL,而Maven正确地暗示了子模块的URL. 我已经用mvn help:effective-pom

                                  So far, so good. I have set up the root SCM URLs in my parent POM, and Maven correctly implies the URLs for the sub-modules. I have checked it with mvn help:effective-pom

                                  我有以下scm网址:

                                  • root :[root-url]
                                  • 实用程序:[root-url]/utils
                                  • 数据模型:[root-url]/data-model/
                                  • 数据模型/库:[root-url]/data-model/lib
                                  • 数据模型/客户端:[root-url]/data-model/client
                                  • 数据模型/服务器:[root-url]/data-model/server
                                  • bin-module-1 :[root-url]/bin-module-1/
                                  • bin-module-2 :[root-url]/bin-module-2/
                                  • root : [root-url]
                                  • utils : [root-url]/utils
                                  • data-model : [root-url]/data-model/
                                  • data-model/lib : [root-url]/data-model/lib
                                  • data-model/client : [root-url]/data-model/client
                                  • data-model/server : [root-url]/data-model/server
                                  • bin-module-1 : [root-url]/bin-module-1/
                                  • bin-module-2 : [root-url]/bin-module-2/

                                  但是Maven不知道实际的SVN布局. 我希望看到它:

                                  But Maven is unaware of the actual SVN layout. I would like it to see :

                                  • root :[root-url]
                                  • 实用程序:[root-url]/utils/trunk
                                  • 数据模型:[root-url]/data-model/trunk
                                  • 数据模型/库:[root-url]/data-model/trunk/lib
                                  • 数据模型/客户端:[root-url]/data-model/trunk/client
                                  • 数据模型/服务器:[root-url]/data-model/trunk/server
                                  • bin-module-1 :[root-url]/bin-module-1/trunk
                                  • bin-module-2 :[root-url]/bin-module-2/trunk
                                  • root : [root-url]
                                  • utils : [root-url]/utils/trunk
                                  • data-model : [root-url]/data-model/trunk
                                  • data-model/lib : [root-url]/data-model/trunk/lib
                                  • data-model/client : [root-url]/data-model/trunk/client
                                  • data-model/server : [root-url]/data-model/trunk/server
                                  • bin-module-1 : [root-url]/bin-module-1/trunk
                                  • bin-module-2 : [root-url]/bin-module-2/trunk

                                  为此,我需要在数据模型 bin-module-1 pom.xml中添加 scm 部分 bin-module-2 .

                                  For that, I need to add a scm section to the pom.xml of data-model, bin-module-1 and bin-module-2.

                                  我已经尝试过类似的方法(对于数据模型):

                                  I have tried something like (for data-model) :

                                  <scm>
                                      <connection>./data-model/trunk</connection>
                                      <developerConnection>./sdr/trunk</developerConnection>
                                      <url>./sdr/trunk</url
                                  </scm>
                                  

                                  <scm>
                                      <connection>${project.parent.scm.connection}/data-model/trunk</connection>
                                      <developerConnection>${project.parent.scm.developerConnection}/data-model/trunk</developerConnection>
                                      <url>${project.parent.scm.url}/data-model/trunk</url>
                                  </scm>
                                  

                                  但是似乎没有一个起作用.属性$ {...}甚至不会被替换. 那么,如何相对于其父SCM URL覆盖SCM路径?

                                  But none seem to work. The properties ${...} are not even replaced. So, how do I override a SCM path, relative to its parent SCM URL ?

                                  任何帮助和建议,将不胜感激.

                                  Any help, advice, would be much appreciated.

                                  预先感谢, 拉斐尔

                                  推荐答案

                                  我以为这可行:

                                  <scm>
                                      <connection>${project.parent.scm.connection}/data-model/trunk</connection>
                                      <developerConnection>${project.parent.scm.developerConnection}/data-model/trunk</developerConnection>
                                      <url>${project.parent.scm.url}/data-model/trunk</url>
                                  </scm>
                                  

                                  如果没有,则仍然可以通过编程方式分配这些值(我将使用 GMaven 做到这一点,但您也可以使用antrun插件或编写自定义插件)

                                  If it doesn't, there's still the possibility to assign these values programmatically (I'll use GMaven to do that, but you can also use the antrun plugin or write a custom plugin)

                                  首先,设置一个属性

                                  <properties>
                                      <relativeScmPath>data-model/trunk</relativeScmPath>
                                  </properties>
                                  

                                  然后为所有SCM属性分配一个相对偏移:

                                  Then assign a relative offset to all SCM properties:

                                  <plugin>
                                      <groupId>org.codehaus.gmaven</groupId>
                                      <artifactId>gmaven-plugin</artifactId>
                                      <version>1.3</version>
                                      <executions>
                                          <execution>
                                              <id>assign-scm</id>
                                              <phase>validate</phase>
                                              <goals>
                                                  <goal>execute</goal>
                                              </goals>
                                              <configuration>
                                                  <source>
                                                  <![CDATA[
                                                  def parentScm = project.parent.scm;
                                                  def thisScm = project.scm;
                                                  def relPath = project.properties['relativeScmPath'];
                                                  ['connection','developerConnection','url'].each{
                                                      thisScm[it] = parentScm[it] + relPath;
                                                  }
                                                  ]]>
                                                  </source>
                                              </configuration>
                                          </execution>
                                      </executions>
                                  </plugin>
                                  

                                  您可以将其添加到根pom并对其进行更改,以使其仅在找到该属性时才运行,然后您只需将属性添加到n个子模块即可自动为它们设置值.

                                  You could add this to the root pom and change it so that it runs only if it finds the property, and then you can automatically set the value for n sub modules by simply adding the property to them.

                                  这篇关于相对于POM中的父SCM URL的SCM URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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