chr*_*ke- 26 pom.xml maven versions-maven-plugin
我有两个顶级Maven项目,backend
并且frontend
以各自的速度推进版本.由于每个模块都有多个模块,因此我dependencyManagement
在父/聚合POM 中的部分中定义了我的依赖项版本,并使用属性作为版本号.
我想用版本号干净地更新属性frontend
,最好随意更新,但我可以忍受要求实时上游版本匹配.我尝试过使用versions:update-property
,但这个目标似乎完全不起作用; 无论是否真的有匹配的上游版本,我得到这个调试输出:
$ mvn versions:update-property -Dproperty=frontend.version -DnewVersion=0.13.2 -DautoLinkItems=false -X
...
[DEBUG] Searching for properties associated with builders
[DEBUG] Property ${frontend.version}
[DEBUG] Property ${frontend.version}: Looks like this property is not associated with any dependency...
[DEBUG] Property ${frontend.version}: Set of valid available versions is [0.9.0, 0.9.1, 0.9.2, 0.9.3, 0.9.4, 0.9.5, 0.10.0, 0.10.1, 0.11.0, 0.12.0, 0.13.0, 0.13.1, 0.13.2, 0.13.3]
[DEBUG] Property ${frontend.version}: Restricting results to 0.13.2
[DEBUG] Property ${frontend.version}: Current winner is: null
[DEBUG] Property ${frontend.version}: Searching reactor for a valid version...
[DEBUG] Property ${frontend.version}: Set of valid available versions from the reactor is []
[INFO] Property ${frontend.version}: Leaving unchanged as 0.13.1
[INFO] ------------------------------------------------------------------------
Run Code Online (Sandbox Code Playgroud)
我已经指定了-DautoLinkItems=false
,这似乎没有效果; versions-maven-plugin
仍会扫描我的所有POM以查找匹配的依赖项,然后退出并退出.我也试着设置searchReactor
到false
在插件配置该属性.看来插件(1)错误地扫描依赖关系,即使我明确地说要忽略它们,(2)甚至过滤掉明确的特定匹配.
有没有一种简单的方法可以将Maven属性条目重写为特定值,或者强制versions-maven-plugin
执行我所说的而不验证版本号或使用其他目标?我宁愿避免使用sed
不懂XML 的工具(正如我在类似问题中看到的那样推荐),但我可以使用简单的XPath操作.
Geo*_*sty 21
有没有一种简单的方法可以将Maven属性条目重写为特定值
从版本2.5
我们可以使用set-property
(文档):
mvn versions:set-property -Dproperty=your.property -DnewVersion=arbitrary_value
如文档所述,set-property
目标不会对您指定的值执行任何"完整性检查",因此它应始终有效,但您应谨慎使用.
dre*_*our 15
newVersion参数记录严密(与此插件的大部分内容一样).通过检查集成测试,我发现它需要Maven版本范围而不是简单的版本号.此外,它不允许您提供任何值 - 它必须是Maven可以解析的有效值.如果被调用,参数会更好constrainRange
对于将来的其他人,请试试这个:
mvn versions:update-property -Dproperty=frontend.version -DnewVersion=[0.13.2]
Run Code Online (Sandbox Code Playgroud)
如果需要更新到快照,请确保将该属性设置allowSnapshots
为true
mvn versions:update-property -Dproperty=frontend.version -DnewVersion=[0.13.2] -DallowSnapshots=true
Run Code Online (Sandbox Code Playgroud)
How to update property in existing POM:
Try to use filtering in maven-resource-plugin:
Advantages:
Disadvantages:
How to provide propery on build time:
You could specify any property by build parameter.
For example, I have property in my pom.xml like:
<properties>
<build.date>TODAY</build.date>
</properties>
Run Code Online (Sandbox Code Playgroud)
To change it during build I simply use parameter:
mvn compile -Dbuild.date=10.10.2010
Run Code Online (Sandbox Code Playgroud)
I'm pretty sure it will work for version as well. Also, properties from top level projects are inherited by childs.
归档时间: |
|
查看次数: |
22800 次 |
最近记录: |