8

I am using Grails 2.1.1 and Maven 3.0.3.

In my buildConfig.groovy, I have pom true and I generated the pom.xml via grails create-pom. In this pom I have a dependency with <version>1.0-SNAPSHOT</version> which exists only in my local maven repository. I can successfully run mvn clean compile on this pom.

However running grails refresh-dependencies does not download the most recent version of my snapshot dependency from my local maven repository. The only way I can get it to download the latest version is to manually delete it from the ivy cache.

According to the documentation:

All dependencies (jars and plugins) with a version number ending in -SNAPSHOT are implicitly considered to be changing by Grails.

I assume it would recognize my snapshot file as changing and download it when it is modified. Am I missing some other configuration step? I only want to use maven for dependency management, but is this entirely the wrong way to use Maven with Grails?

beldenge
  • 156
  • 2
  • 8

2 Answers2

8

This is actually the normal behavior of the Aether resolver.

--refresh-dependencies doesn't bypass your local maven cache. To do that, you'll need to set the maven repository that contains your dependency to always download new snapshots. In BuildConfig.groovy's repositories block:

mavenRepo ("http://my.server/repos/my-grails-plugins") {
    updatePolicy 'always'
}

Credit to http://asoftwareguy.com/2013/10/25/grails-2-3-maven-dependency-caching-issues/.

jonnybot
  • 2,435
  • 1
  • 32
  • 56
0

Since I haven't got any responses, what seems like the solution to this is to just not use the grails command line, but rather use the maven goals for Grails.

mvn grails:run-app does the trick. All snapshot dependencies are refreshed and I can start up my app and see the local changes reflected. This way I'm ignoring ivy altogether and letting maven take care of everything.

Edit: If you go this route, I suggest following chapter 5 of the User Guide on Maven Integration for setting up your pom.xml, etc. I was able to follow this and get it set up without any surprises.

beldenge
  • 156
  • 2
  • 8