【问题标题】:Debugging Grails command "refresh-dependencies" with maven\issues with Nexus使用 maven\issues 调试 Grails 命令“刷新依赖项”与 Nexus
【发布时间】:2014-12-24 12:24:13
【问题描述】:

我在公司网络上,因此要检索我们使用 Nexus 的依赖项。 Grails repo 已添加到 nexus 存储库中,所以现在剩下的就是配置 grails 以使用 nexus。

对于 Java Maven 项目的开发,我只需要指定应该注意哪个 settings.xml 文件,因为 Nexus URL 和凭据存储在那里。

现在我们切换到 Grails,在创建一个新项目时,grails 在配置类路径上挂起大约 200 秒(因为它被配置为在 200 秒后超时),然后说:

Resolve error obtaining dependencies: Failed to read artifact descriptor for jline:jline:jar:2.12 (Use --stacktrace to see the full trace)
Error |
Required Grails build dependencies were not found. This is normally due to internet connectivity issues (such as a misconfigured proxy) or missing repositories in grails-app/conf/BuildConfig.groovy. Please verify your configuration to continue.
Process was killed

现在这可能是 repo 配置的问题,但是我无法正确调试它。

我尝试调用grails refresh-dependencies --stacktrace,尝试将日志记录从error 更改为debugConfig.groovy 中的trace。尝试在BuildConfig.groovy 中将日志记录设置为verbose(但这是针对Ivy,我们使用的是Maven,所以它当然什么也不做),现在我不确定该怎么做。

如果有帮助,这是我在 BuildConfig.groovy 中的当前 repo 配置:

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

    grailsPlugins()
    grailsHome()
    mavenLocal()

    mavenRepo(id:'nexusconf', url:"https://nexusurl/repository/rootrepo/") {
        auth username: "user", password: "pass"
    }
    //grailsCentral()
    //mavenCentral()
    // uncomment these (or add new ones) to enable remote dependency resolution from public Maven repositories          
    //mavenRepo "http://repository.codehaus.org"
    //mavenRepo "http://download.java.net/maven/2/"
    //mavenRepo "http://repository.jboss.com/maven2/"
}

【问题讨论】:

  • BuildConfig 中的grails.project.dependency.resolver 有什么价值?是maven 还是ivy

标签: java maven grails groovy


【解决方案1】:

我认为这取决于您使用的 grails 版本以及您是使用以太还是常春藤进行依赖解析(在 BuildConfig 中使用 grails.project.dependency.resolver 设置)。根据 grails 2.4.4 文档,要使用 Aether 进行身份验证,需要在 BuildConfig 以及 USER_HOME/.grails/settings.groovy 中进行配置。要使用 Ivy 进行身份验证,配置仅在 USER_HOME/.grails/settings.groovy 中进行。

文档是这样说的:


以太坊身份验证

要使用 Aether 进行身份验证,您可以在存储库定义中定义凭据:

mavenRepo(url:"http://localhost:8082/myrepo") { auth username: "foo", password: "bar" }

或者您可以在存储库上指定一个 id:

mavenRepo(id:'myrepo', url:"http://localhost:8082/myrepo")

然后在 USER_HOME/.grails/settings.groovy 中声明您的凭据:

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

使用 Ivy 进行身份验证

如果您的存储库需要身份验证,您可以使用凭据块进行配置:

credentials { realm = ".." host = "localhost" username = "myuser" password = "mypass" }

这可以使用 grails.project.ivy.authentication 设置放置在您的 USER_HOME/.grails/settings.groovy 文件中:

grails.project.ivy.authentication = { credentials { realm = ".." host = "localhost" username = "myuser" password = "mypass" } }

Here's the documentation in its entirety

【讨论】:

  • 我已经设法通过将凭据放入 settings.groovy 来解决我的问题,但是在我看来,使用 maven (Aether) 调试依赖项管理很困难。如果我没看错的话,会有依赖管理日志记录,但仅适用于 Ivy。如何调试/记录 Aether/Maven 依赖管理?
  • 我认为是在settings.groovy文件中配置的。尝试将log '<log level>'credentials 一起放在grails.project.dependency.authentication 定义中。
  • 我试过了,但遗憾的是它什么也没做。据我所见,在 grails 文档中的任何地方都找不到 Aether 日志记录,这让我相信它要么不可能,要么被忽视了。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-02-09
  • 2011-10-19
  • 1970-01-01
  • 2017-08-13
  • 2014-06-23
  • 1970-01-01
相关资源
最近更新 更多