[英]What is the recommended way to build the same code against different sets of dependencies?
My project Bar
depends on the library Foo
.我的项目
Bar
依赖于库Foo
。 There are different versions of Foo
, say foo-v1
, foo-v2
and foo-v3
. Foo
有不同的版本,比如foo-v1
、 foo-v2
和foo-v3
。
I want to build my project against each of those versions separately and produce three separate artifacts, eg bar-with-foo-v1
, bar-with-foo-v2
and bar-with-foo-v3
.我想分别针对每个版本构建我的项目并生成三个单独的工件,例如
bar-with-foo-v1
、 bar-with-foo-v2
和bar-with-foo-v3
。
What is the recommended way to do such a thing in Gradle?在 Gradle 中做这样的事情的推荐方法是什么?
You could use propery/profile:您可以使用属性/配置文件:
gradle -Pversion1 build
Configuration:配置:
dependencies {
if (project.hasProperty('version1')) {
compile "foo-v1"
} else if (project.hasProperty('version2')) {
compile "foo-v2"
} else {
compile "foo-v3"
}
...
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.