Maven:依赖关系的动态规范 [英] Maven: dynamic specification of dependencies
问题描述
我已经开始学习Maven并有以下问题:
I have started to learn Maven and have the following question:
我想动态指定用于构建Maven项目的依赖关系,而不是使用POM中指定的依赖关系-有办法吗?
I would like to dynamically specify a dependency for building maven project instead of using the dependency specified in POMs - is there a way to do that?
因此,尽管我在POM中指定了以下依赖项
So although I have the following dependencies specified in POM
...
<dependencies>
<dependency>
<groupId>group</groupId>
<artifactId>ProjectComponent</artifactId>
<version>1.0</version>
</dependency>
...
我想在build命令中指定要使用其他版本. 有没有办法指定这个?
I would like to specify in the build command that I want to use a different version. Is there a way to specify this?
这个想法是,我想在Jenkins中建立一个集成构建,并依赖于特定分支机构系统的最新可用快照.该快照尚未发布到Maven存储库中,因此我想在Jenkins中获取它,并指定mvn构建的依赖项.
The idea is that I want to have an integration build made in Jenkins with a dependency on the latest available snapshot of the system for a particular branch. That snapshot is not released to the maven repository yet, so I would like to fetch it in Jenkins and specify a dependency for mvn build.
谢谢!
可能的解决方案:我最终得到的是使用$ {my.lib.version}构造,并在调用mvn时使用-Dmy.lib.version = 1.0-SNAPSHOT进行指定.因此,我可以通过从svn获取依赖项的任意快照版本并将其快照版本提供给集成构建pom来将其用于Jenkins集成构建.
POSSIBLE SOLUTION: What I ended up with is to use ${my.lib.version} construction and specify it with -Dmy.lib.version=1.0-SNAPSHOT" when calling to mvn. Thus I can use it for Jenkins integration builds by fetching arbitrary snapshot versions of dependencies from svn and feeding their snapshot versions to the integration build pom.
推荐答案
我最终得到的是使用$ {my.lib.version}构造,并在-Dmy.lib.version = 1.0-SNAPSHOT中指定它.调用mvn.因此,我可以通过从svn获取依赖项的任意快照版本并将其快照版本提供给集成构建pom来将其用于Jenkins集成构建.
What I ended up with is to use ${my.lib.version} construction and specify it with -Dmy.lib.version=1.0-SNAPSHOT" when calling to mvn. Thus I can use it for Jenkins integration builds by fetching arbitrary snapshot versions of dependencies from svn and feeding their snapshot versions to the integration build pom.
这篇关于Maven:依赖关系的动态规范的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!