How to make Grails get latest local jars from Mave

2019-02-23 04:26发布

问题:

  1. In my Maven repo (.m2). there is one my local jar like sub_app-0.1.jar.
  2. I have same copy of the it in ivy-cache.
  3. I run maven install on sub_app then new sub_app-0.1.jar file created.
  4. After, I run grails clean and it not getting my new sub_app-0.1.jar from .m2.
  5. But, if I remove (delete) sub_app-0.1.jar file from ivy-cache and run the grails clean then it is getting new sub_app-0.1.jar file into ivy-cache.

  6. If I change the version in sub-app pom and grails pom and Grails is taking latest one. install again it not taking.

  7. I tried by adding SNAPSHOT to sup-app jar even. Same result, first time it is taking, after not.

ie. Grails considering only jar name and version in ivy-cache, if having - it not take. If not having - it taking from .m2.

But it not considering new/old build.

How can I get the same behavior (step 5) in step 4 also?

回答1:

UPDATED

You can try adding changing=true to your dependency in the BuildConfig.groovy, as specified in the Grails Guide

compile ('YOUR_GROUP_ID:YOUR_SUB_AP:0.1') {
    changing = true
}


回答2:

Not sure if this is the same problem as you, but I use Spring Source Tool Suite (STS) with a 'grails' project having a dependency on an 'interfaces' project (which just contains interfaces, beans, pojos, etc).

If I run a maven install on interfaces in STS, then maven correctly updated with latest jar (I use '-1.0-SNAPSHOT' as my version number).

If I then run a grails clean on my 'grails' project in STS, Grails correctly identifies the change of the interfaces jar (I have {changing=true} in BuildConfig.groovy), downloads the pom, but fails to download the jar as it cannot delete the jar from the ivy-cache. Looks like STS has a handle on the ivy-cache which prevents this.

As I inherited this project from another developer who informed me it was a bug/feature of Grails and/or STS, I've bowed to his knowledge and workaround this by either:

  1. maven package instead of install on 'interfaces' then copy the latest jar to the ivy-cache. It seems STS will let me replace the contents of the jar. Then grails clean uses the latest jar from ivy-cache (no attempt to download from maven).
  2. maven install on 'interfaces', close down STS, delete jar from ivy-cache, re-open STS, grails clean which downloads latest jar from maven.

Both workarounds as a pain, so I'd be interested if anyone has any ideas?



回答3:

Grails not supports to get latest of same (group-id, artifact-id, version) jar even SNAPSHOT jar also.

Solutions:

  1. Every-time, delete the sub-app-version.jar from ivy-cache. or
  2. Every-time, change the version to next value(should be greater than current value) of the sub-app jar in pom.xml.

4 Configuration - Reference Documentation

Please read:

4.7.6 Snapshots and Other Changing Dependencies