Upgrading to Groovy 3.0.x with Griffon 2.15.1 via Gradle

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Upgrading to Groovy 3.0.x with Griffon 2.15.1 via Gradle

zlatinb
Hi,

I went through quite an adventure upgrading to Groovy 3.0.x with Griffon 2.15.1.  Below are my notes; if there is a better way please let me know.

The problem:

the Griffon Gradle plugin always includes groovy-all-2.4.15.  Groovy 3.0.x does not have an -all jar, and if you look at the .pom you will see the dependencies to each Groovy component.  Those components in turn bring in other dependencies and bloat the size of the final package.

Wrong solution 1: set "includeGroovyDependencies = false"

There is a property in the "griffon" gradle extension called "includeGroovyDependencies". This is the first thing I tried to disable, thinking it was just about pulling in the groovy dependencies and that I would be able to declare individual 3.0.x components explicitly.  Turns out that also completely disabled the annotation processing tasks, rendering dependency injection of the the Griffon artifacts impossible.  

Wrong solution 2: add "exclude" block under the groovy-all dependency, or set "transitive = false"

The thinking here is that if I specify groovy-all-3.0.x as a dependency to the "compile" configuration, it's higher version will override the 2.4.15 that the plugin adds.  That works, however adding "exclude" blocks under that dependency doesn't.  All Groovy 3.0.x components and transitive dependencies get pulled in the final package all the same.

Heavy-handed solution that worked: exclude unneeded components from all configurations

I basically excluded the unnecessary groovy components from all configurations.  My application does not have any tests (for the Griffon part), so the following Gradle block did the trick:

configurations.all {
        exclude group:'org.codehaus.groovy', module:'groovy-test'
        exclude group:'org.codehaus.groovy', module:'groovy-testng'
        exclude group:'org.codehaus.groovy', module:'groovy-test-junit5'
        // ... others ...
}

This will not be acceptable for many applications; is there a more fine-grained way to do a Groovy version upgrade?  Ideally a property in the "griffon" gradle extension to specify the Groovy version to use.

Thanks
Zlatin  
Reply | Threaded
Open this post in threaded view
|

Re: Upgrading to Groovy 3.0.x with Griffon 2.15.1 via Gradle

aalmiray
Administrator
Hi Zlatin,

Thank your for the feedback, and sorry for making you jump through too many hoops.
Griffon 3.x will upgrade to latest Groovy 3. The Griffon plugin will also make it easier to override dependencies as needed. Note that the use of the Griffon Gradle plugin is a convenience, you can configure the project to run without it, as shown at http://griffon-framework.org/tutorials/6_minimalistic_build.html

Cheers,
Andres