gpt4 book ai didi

android - Gradle 依赖外部项目后备模块

转载 作者:行者123 更新时间:2023-12-03 04:21:39 27 4
gpt4 key购买 nike

当项目不存在于本地以使用模块项目(存在于存储库中)时,我编写了一些代码来回退,我想创建一个方法来调用而不是这个:

    if (findProject(':Project') != null) {
debugImplementation project(':Project')
} else {
debugImplementation 'com.group:artifact:1.0'
}
releaseImplementation 'com.group:artifact:1.0'

就像是 :
debugImplementation tryProject(':Project', 'com.group:artifact:1.0')
releaseImplementation 'com.group:artifact:1.0'

最佳答案

我使用 Composite builds 解决了这个问题.您可以包含完整的构建,gradle 将自动替换依赖项。

includeBuild('../Project')

如果组和名称与存储库中的组和名称匹配,则在您的 settings.gradle 中应该足够了(其中 ../Project 是依赖项的相对路径),否则类似这样
includeBuild('../Project') {
dependencySubstitution {
substitute module('com.group:artifact') with project(':')
}
}

从来没有使用过后者。

关于android - Gradle 依赖外部项目后备模块,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50151846/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com