如何在gradle中添加神器库?

时间:2017-03-24 12:18:34

标签: android maven gradle repository artifactory

我需要在gradle(android app)中配置artifactory。

我已将所有脚本放在build.gradle中:

buildscript {
    repositories {
        jcenter()
        maven {
            url '.../artifactory/plugins-releases'
            credentials {
                username = "${artifactory_user}"
                password = "${artifactory_password}"
            }
        }
    }
    dependencies {    
        classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4.4.14"    
    }
}

apply plugin: "com.jfrog.artifactory"

allprojects {
    repositories {
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

artifactory {
    contextUrl = "${artifactory_contextUrl}"   //The base Artifactory URL if not overridden by the publisher/resolver
    publish {
        repository {
            repoKey = 'libs-releases-local'
            username = "${artifactory_user}"
            password = "${artifactory_password}"
            maven = true

        }
    }
    resolve {
        repository {
            repoKey = 'libs-releases'
            username = "${artifactory_user}"
            password = "${artifactory_password}"
            maven = true

        }
    }
}

当我尝试从这个神器中编译一个lib时,我收到了这个错误:

Failed to resolve: my-lib:1.0.0

2 个答案:

答案 0 :(得分:0)

com.jfrog.artifactory插件用于发布到神器中,而不是用于它。如果要使用它,则需要将其定义为构建的存储库。

答案 1 :(得分:0)

我有类似的问题。对我来说,就是那个maven {url""需要以" http://"开头的值。所以对于exmaple

    maven {
        url 'http://.../artifactory/plugins-releases'
        credentials {
            username = "${artifactory_user}"
            password = "${artifactory_password}"
        }
    }