Grails 和本地 Maven 依赖项 [英] Grails and Local Maven Dependencies

查看:40
本文介绍了Grails 和本地 Maven 依赖项的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用 Grails 开发一个小型 Web 前端.它基本上是一个超轻量级"客户端应用程序,通过 JMS 异步连接.

I'm developing a small web frontend in Grails. It is basically a "ultra light-weight" client app that is connected async through JMS.

我想从 Maven 存储库中提取项目中的两个依赖项.它们是 activemqacme-adapter-api,这是一个内部依赖项,在远程存储库中不可用.

I have two dependencies in the project that I would like to pull from a Maven repository. They is activemq and acme-adapter-api, a in-house dependency, not available at the remote repository.

我像这样设置了我的 BuildConfig.groovy(Grails 1.2M4)文件,以便访问我的依赖项:

I set up my BuildConfig.groovy (Grails 1.2M4) file like this, in order to access my dependencies:

repositories {
    grailsPlugins()
    grailsHome()
    mavenCentral()
    mavenRepo('D:/maven-repo')
} dependencies {
    compile 'org.apache.activemq:apache-activemq:4.1.1'
    compile 'com.acme:acme-adapter-api:1.3-SNAPSHOT'
}

当我运行 grails dependency-report 时,我可以看到关于 acme-adapter-api 的这一行,例如:

When I run grails dependency-report, I can see this line concerning the acme-adapter-api, for example:

acme-adapter-api by com.acme  
108 kB (0 kB downloaded, 108 kB in cache)

当我尝试运行 grails compile 时,我并不走运,因为它随后抱怨无法解析 com.acme 组中的类.

When I try to run grails compile, I don't get lucky, as it then complains it is unable to resolve the classes from the com.acme group.

有趣的是 activemq 依赖似乎不是问题...

Interestingly the activemq dependencies don't seem to be a problem...

区别在于acme依赖不在mavenCentral()中,而只在mavenRepo("D:/maven-repo")中.所以我想:也许它没有从本地磁盘中提取它然后......"并将版本更改为一些在 BuildConfig.groovy 文件.再次运行grails compile时,命令超时,说找不到版本:

The difference is that the acme dependencies are not in mavenCentral(), but only in mavenRepo("D:/maven-repo"). So I thought: "Maybe it is not picking it up from the local disk then..." and changed the version to some funny (1.999-SNAPSHOT) value that doens't exist in the BuildConfig.groovy file. When running grails compile again, the command timed out, saying that version could not be found:

UNRESOLVED DEPENDENCIES
D:/maven-repo: unable to get resource for com/acme#acme-adapter-api;1.999-SNAPSHOT

很明显,本地依赖得到了解决,但不知何故没有应用于下一步,编译...

So obviously the local dependency gets resolved but somehow not applied in the next step, compilation...

推荐答案

原来问题出在该工件的非空缓存.虽然 activemq jar 文件未受影响,但实际上 acme-adapter-api.jar 已多次更改,但没有增加 maven build id,在上述情况下为 1.3.

It turned out that the problem was then non empty cache for the artifact. While the activemq jar file was untouched, the acme-adapter-api.jar was in fact many times changed but without increasing the maven build id, 1.3, in the above case.

我可以修复它,当我将内部版本号增加到 1.4-SNAPSHOT...

I could fix it, when I increased the build number to 1.4-SNAPSHOT...

还有两个问题:

  1. 出于完全相同的原因,maven 合同不是总是获取 SNAPSHOT 版本吗?
  2. 如何强制清空缓存?它在哪里?
  1. Isn't the maven contract to always fetch SNAPSHOT versions, for the exact same reason?
  2. How to forcefully empty the cache? And where is it?

我将打开一个新问题来回答第 2 部分 此处

I will open a new question to answer part 2 here

这篇关于Grails 和本地 Maven 依赖项的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆