简体   繁体   English

针对不同的依赖项集构建相同代码的推荐方法是什么?

[英]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-v1foo-v2foo-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-v1bar-with-foo-v2bar-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.

相关问题 使用maven构建具有不同依赖关系的两个相同webapp的最佳方法 - Best way to build twice the same webapp with different dependencies using maven 对使用UDP套接字的代码进行单元测试的推荐方法是什么? - What is the recommended way to unit test code that uses UDP sockets? 在Java中的源代码和测试之间共享资源的推荐方法是什么? - What is the recommended way to share resources between source code and tests in java? 有没有办法根据同一仓库中的代码目录路径使用不同的 Kube.netes 配置单独构建? - Is there a way to build separately using different Kubernetes configs according to code directory path in the same repo? 不同构建配置文件的不同依赖项 - Different dependencies for different build profiles 如何使用相同的源代码但使用不同的资源构建不同的APK - How to build different APKs with same source code but different resources 在Java中使用计时器的最推荐方法是什么 - What is the most recommended way to using timer in Java 建议使用哪种方法来构建WebService应用程序? - What's the recommended way to structure WebService app? JPA删除。 在这种情况下,建议的方法是什么? - JPA Remove . What is the recommended way to do it in this case? 使用 SPQR 进行分页的推荐方法是什么? - What is the recommended way to paginate using SPQR?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM