父pom中的某些内容可以采用子pom中声明的值吗?
具体来说,我想做这样的事情。
上级:
<scm>
<connection>scm:git:[email protected]:team/${git.repo}.git</connection>
<developerConnection>scm:git:[email protected]:team/${git.repo}.git</developerConnection>
<url>http://github.corp.com/team/${git.repo}</url>
</scm>
孩子:
<properties>
<git.repo>Foo</git.repo>
</properties>
理想情况下,git.repo属性未在父级中显式设置,因此子级必须覆盖它或完全覆盖scm节。
父pom中的某些内容可以采用子pom中声明的值吗?
是的。但是,为了拥有有效的父POM,我建议${git.repo}
在父中提供默认值/虚拟值。
为了处理子POM不覆盖(即重新定义)的情况,${git.repo}
您可以在父POM中引入一个配置文件,如下所示:
<profiles>
<profile>
<id>property-not-redefined</id>
<activation>
<activeByDefault>false</activeByDefault>
<property>
<name>git.repo</name>
<value>your-default-value</value>
</property>
</activation>
<build>
<plugins>
<!-- do something here -->
</plugins>
</build>
</profile>
</profiles>
当git.repo
属性仍具有默认值时,此配置文件将变为活动状态。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句