I'm developing a small web frontend in Grails. It is basically a "ultra light-weight" client app that is connected async through JMS.
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.
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'
}
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)
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.
Interestingly the activemq
dependencies don't seem to be a problem...
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 d开发者_如何转开发isk 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...
Grails 1.3.6 has been updated with Ivy 2.2 (which indicated that it applied a fix for https://issues.apache.org/jira/browse/IVY-938) and I can get updates to SNAPSHOT versions if I specify "changing = true", as in:
dependencies {
runtime ('groupId:artifactId:version-SNAPSHOT') {
changing = true
}
}
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.
I could fix it, when I increased the build number to 1.4-SNAPSHOT...
Two question remain:
- 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?
I will open a new question to answer part 2 here
精彩评论