Grails 和本地 Maven 依赖项

编程入门 行业动态 更新时间:2024-10-27 23:29:43
本文介绍了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 存储库中提取项目中的两个依赖项.它们是 activemq 和 acme-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...

还有两个问题:

  • 出于完全相同的原因,maven 合同不是总是获取 SNAPSHOT 版本吗?
  • 如何强制清空缓存?它在哪里?
  • Isn't the maven contract to always fetch SNAPSHOT versions, for the exact same reason?
  • How to forcefully empty the cache? And where is it?
  • 我将打开一个新问题来回答第 2 部分 此处

    I will open a new question to answer part 2 here

    更多推荐

    Grails 和本地 Maven 依赖项

    本文发布于:2023-11-13 11:50:34,感谢您对本站的认可!
    本文链接:https://www.elefans.com/category/jswz/34/1584285.html
    版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
    本文标签:Grails   Maven

    发布评论

    评论列表 (有 0 条评论)
    草根站长

    >www.elefans.com

    编程频道|电子爱好者 - 技术资讯及电子产品介绍!