繁体   English   中英

如何在Grails 2.4中外化Maven凭据

[英]How to externalise Maven credentials in Grails 2.4

我正在尝试从使用Ivy迁移到Grails 2.4项目中使用Aether解析器。

我遇到的问题与外部化凭据有关。 与此相关的信息可以在Grails手册中找到: http//grails.org/doc/latest/guide/conf.html#dependencyRepositories

似乎没有一种记录方式可以像使用常春藤一样以外部方式使用Maven。

有了常春藤,我可以将这样的东西放到我的.grails/settings.groovy文件中:

grails.project.ivy.authentication = {
    credentials {
        realm = "My Repo"
        host = "repo.mycustomrepo.com"
        username = "user"
        password = "password"
    }
}

要使用Aether,我不得不将凭证块直接放在我的BuildConfig.groovy如下所示:

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

    grailsPlugins()
    grailsHome()
    mavenLocal()
    grailsCentral()
    mavenCentral()
    mavenRepo("http://repo.mycustomrepo.com") {
      //Add authentication details to repository connection
      auth([
        username: 'user',
        password: 'password'
      ])
    }
}

不幸的是,这对我来说确实存在问题,因为在我的组织中我们使用Artifactory配置为使用我们的LDAP凭据。 这是一个问题,因为我不想在源代码管理中提交我的凭据。

有没有未记录的解决方案,或Grails不支持它?

使用id定义您的仓库:

 mavenRepo(id:'myrepo', url:"http://localhost:8085/artifactory/libs-release-local/") 

然后使用之前指定的id~/.grails/settings.groovy定义您的凭据:

grails.project.dependency.authentication = {
  credentials {
    id = "myrepo"
    username = "foo"
    password = "bar"
  } 
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM