android-studio - Gradle 下载并解压多个依赖
问题描述
我有一个通用的 Artifatory 存储库,其中包含一些我需要在 Android Studio 项目中下载和提取的 zip 文件。我是 Gradle 新手,但发现使用 Ivy 存储库对象可能是最好的方法,而不是仅使用调用 curl 的 Gradle 任务下载文件。
我已经设法下载并解压缩了一个 zip 文件,但是一旦我尝试添加另一个依赖项,它就会覆盖我的配置。请参阅下面代码中的依赖项块。
为什么它不添加另一个依赖项,有没有更好的方法来做到这一点?
应用程序:build.gradle:
repositories {
ivy {
url property("artifactoryUrl")
credentials {
username property("artifactoryUser")
password property("artifactoryPassword")
}
authentication {
basic(BasicAuthentication)
}
patternLayout {
artifact '/[organisation]/[module]/third-party/[revision](.[ext])'
}
metadataSources {
artifact()
}
}
}
configurations {
thirdPartyDependencies
}
dependencies {
thirdPartyDependencies "artifactory:test-generic:FreeImage@zip"
thirdPartyDependencies "artifactory:test-generic:GLEW@zip" // thirdPartyDependencies has been overwritten
}
task CopyThirdPartyDependencies(type: Copy) {
def thirdPartyDirectory = getProject().getRootDir().toString() + "/third-party/"
println(configurations.thirdPartyDependencies.resolvedConfiguration.resolvedArtifacts)
configurations.thirdPartyDependencies.resolvedConfiguration.resolvedArtifacts.each { artifact ->
copy {
from zipTree(artifact.getFile())
into thirdPartyDirectory
}
}
}
preBuild.dependsOn(CopyThirdPartyDependencies)
解决方案
推荐阅读
- python - 收到的标签值 17 超出 [0, 12) 的有效范围 - Keras Python
- typescript - TypeScript - 包含其他泛型类型的类字典泛型 - 泛型类型在方法中丢失的问题
- php - 在同一台服务器上托管 Nodejs 和 PHP
- csv - 作业前测试文件名
- c++ - 无法根据对象的属性值对对象数组进行排序
- r - 如何在此情节中添加图例?
- python - 如何在熊猫中将“0天00:39:00”转换为只有39?
- c++ - 具有非 ASCII 文件名的 Microsoft Speech to Text
- ios - Swift中的“[self] in”和“[weak self] in”有什么区别?
- python - PyCryptodome AES,“EcbMode”对象没有属性“encrypt_and_digest”