Загрузка Gradle и распаковка нескольких зависимостей

#android-studio #gradle #groovy #dependencies #artifactory

#android-studio #Gradle #groovy #зависимости #артефактор

Вопрос:

У меня есть общее искусственное репозиторий, который содержит некоторые zip-файлы, которые мне нужно загрузить и извлечь в проекте Android Studio. Я новичок в Gradle, но обнаружил, что использование объекта хранилища Ivy, возможно, лучший способ сделать это вместо простой загрузки файлов с помощью задачи Gradle, которая вызывает curl.

Мне удалось загрузить и извлечь один 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)