相对于父级的Maven SCM URL [英] Maven SCM URL relative to the parent

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

问题描述

我们在SVN中具有以下项目结构,其中一个父项目(非聚合器)定义了公共配置.父级是单独管理和释放的.

We have the following project structure in SVN with a parent (not aggregator) project defining common configuration. The parent is individually managed and released.

trunk
    +parent
        pom.xml
    +project1
        pom.xml
        +project1_1
            pom.xml
        +project1_2
            pom.xml
    +project2
        pom.xml

因此,基本上每个真实项目(project1,project2)都用作其子项目的聚集器.常用配置设置(Java编译器版本,其他插件)保留在父级中,该父级在所有项目(project1,project2)中均用作Maven parent.

So basically each real project (project1, project2) is used as an aggregator for its sub-projects. Common configuration settings (Java Compiler version, other plugins) are kept in the parent, which is used as the Maven parent in all of the projects (project1, project2).

我要在父级中定义的设置之一是Subversion的SCM URL,例如http://svnhost/base/trunk/parent在父pom.xml中.

One of the settings I would like to define in the parent is the SCM URL for Subversion, e.g. http://svnhost/base/trunk/parent in the parent pom.xml.

当我这样做时,各个项目都会继承此设置,但是当然不能反映路径的相对性质.在 project1 中,此问题已解析为http://svnhost/base/trunk/parent/-我已通过mvn help:effective-pom进行了检查.

When I do this, the individual projects inherit this setting, but of course don't reflect the relative nature of the path. In project1, this is resolved to http://svnhost/base/trunk/parent/ - I've checked this with mvn help:effective-pom.

有没有一种方法可以指定SCM连接,以便相对于父级进行解析?还是我必须在每个项目中提供SCM URL?

Is there a way to specify the SCM connection so that is resolved relative to the parent? Or do I have to provide the SCM URL in each individual project?

推荐答案

如果使用诸如${svn.host}${svn.path}之类的属性来构建scm.url,应该有可能.该发布插件有一个错误,该错误在发布期间替换了属性: http://jira.codehaus.org /browse/MRELEASE-128 ,但自2.3版以来,该问题似乎已修复.因此,您的孩子poms仅定义属性,而不再定义scm url.

It should be possible if you use properties like ${svn.host} and ${svn.path} to build the scm.url. The release plugin had a bug where properties where replaced during a release: http://jira.codehaus.org/browse/MRELEASE-128 but since version 2.3 that seems to be fixed. So your child poms only define the properties but no longer the scm url.

我不知道这是否有帮助.您不会在pom.xml中保存很多行,并且会引入人们不更改属性的危险.

I don't know if that helps. You don't save much lines in the pom.xml and you introduce the danger people don't change the properties.

如果在父级中定义parent.scm.url的属性,然后在子级中使用该属性添加相对URL(<scm.url>${parent.scm.url}/../myproject</scm.url>) 如果您基于该属性在scm.url中进行相对路径操作,您仍然不会节省很多配置?

If you define a property of the parent.scm.url in the parent and then use that property in the child adding a relative url (<scm.url>${parent.scm.url}/../myproject</scm.url>) If you do relative path in scm.url based on that property you still don't save much of the configuration?

我想确实想要您需要编写一个插件,该插件读取父URL,然后从当前工作副本中读取URL(因为maven不知道在其他地方可以找到该项目URL,因为它未配置),然后从中计算相对路径.与仅在每个pom中重复scm.url配置相比,我认为那是一个奇怪的事情.

I think to exactly do want you want to you need to write a plugin that reads the parent-url, then reads the url from the current working copy (as maven does not know where else to find that project url, since it is not configured) and then calculate the relative path from it. I think thats a but weird compared to just repeat the scm.url configuration in every pom.

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

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