为Artifactory配置grails maven身份验证的正确方法是什么?

Gre*_*ner 6 grails artifactory maven

使用Maven解析器为Artifactory配置身份验证的正确方法是什么?

目前我正在使用:

grails.project.ivy.authentication = {
    repositories {
        mavenRepo "http://SERVER:8081/artifactory/remote-repos"

    }
    credentials {
        realm = "Artifactory Realm"
        host = "SERVER"
        username = "USER"
        password = "PASSWORD"
    }
}

grails.project.dependency.resolver = "maven" // or ivy

grails.project.dependency.resolution = {
    // inherit Grails' default dependencies
    inherits("global") {
        // specify dependency exclusions here; for example, uncomment this to disable ehcache:
        // excludes 'ehcache'
    }
    log "warn" // log level of Ivy resolver, either 'error', 'warn', 'info', 'debug' or 'verbose'
    checksums true // Whether to verify checksums on resolve
    legacyResolve false // whether to do a secondary resolve on plugin installation, not advised and here for backwards compatibility

    repositories {
        inherits true // Whether to inherit repository definitions from plugins

//        mavenLocal()

        mavenRepo id: 'Artifactory', url: "http://SERVER:8081/artifactory/remote-repos"

    }
Run Code Online (Sandbox Code Playgroud)

如果我将解析器更改为"常春藤",则会下载依赖项.

使用maven解析器Artifactory请求日志显示401错误

相关Grails文档:http://grails.org/doc/latest/guide/conf.html#dependencyRepositories

也许它尚未针对Maven进行更新.

小智 4

我们的商店目前使用的是 Grails 2.3.8,每个开发人员都在我们的主目录中保存一个外部构建配置,其中包含以下内容:

artifactory.username = 'username'
artifactory.password = 'password'
artifactory.repo = 'http://our.artifactory.server.com:8080/artifactory/central'
artifactory.repositoryLocation = "http://our.artifactory.server.com:8080/artifactory/libs-release-local"
Run Code Online (Sandbox Code Playgroud)

以下是我们在 BuildConfig.groovy 中配置所有 Grails 项目的方法:

def config = new ConfigSlurper(grailsSettings.grailsEnv).parse(new File("$home/my_build_config.groovy").toURI().toURL())

grails.project.dependency.resolver = "maven"

grails.project.dependency.resolution = {

    inherits("global") {
    }

    log "error"
    checksums true
    legacyResolve false

    repositories {

        String artifactoryUrl = config.artifactory.repo
        mavenRepo(artifactoryUrl) {

            auth([
                    username: config.artifactory.username,
                    password: config.artifactory.password
            ])

            updatePolicy "always"
        }
        mavenLocal()
    }

    dependencies {

        // ...
    }

    plugins {

        // ...
    }
}
Run Code Online (Sandbox Code Playgroud)

如果这不起作用,我建议您查看虚拟存储库的 Artifactory 权限设置和一般用户权限。