Grails 2.3 Maven dependency caching issues

tl;dr version:
Change BuildConfig.groovy to reference your local mavenRepo repository as:

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

Long version:
If you have played around with Grails 2.3, you know that the project has switched to Maven (Aether, actually) as default for dependency resolution, as opposed to Ivy. However, on my current project, we have run into a few issues with the semantics of dependency caching with Aether as opposed to Ivy.

In Ivy, when you updated a snapshot dependency, it would detect that and immediately go download it from the repository. Aether’s default update policy on snapshots is to update at most once per day. This doesn’t work well when a Grails plugin is under active development and you are constantly publishing new versions to your own hosted artifact repository, such as Artifactory.

The fix listed above instructs Aether to always update the dependencies in that particular repository. You can read more about it in the Grails docs.

Here are the possible values for updatePolicy:

  • never – Never check for new snapshots
  • always – Always check for new snapshots
  • daily – Check once a day for new snapshots (the default)
  • interval:x – Check once every x minutes for new snapshots

Once you set a more frequent update policy, you should see something similar in the logs when you refresh-dependencies. This lets you know that Grails is checking the repository for new artifacts:

| Downloading: org/grails/plugins/xyz/1.0-SNAPSHOT/maven-metadata.xml
| Downloading: org/grails/plugins/abc/1.0-SNAPSHOT/maven-metadata.xml

This entry was posted in Grails, Maven and tagged , , , , . Bookmark the permalink.

2 Responses to Grails 2.3 Maven dependency caching issues

  1. stenis999 says:

    Has this option changed? I’m using grails 2.3.5 and get an error message: “There was an error loading the BuildConfig: No signature of method: groovy.util.ConfigSlurper$_parse_closure5.updatePolicy() is applicable for argument types: (java.lang.String) values: [always]” when I try this.

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.