I am trying to move my Groovy project (a plugin for Nextflow) to Groovy 4. However, I keep getting this error:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':plugins:nf-quilt:compileGroovy'.
> BUG! exception in phase 'semantic analysis' in source unit '/Users/ernest/GitHub/nf-quilt/plugins/nf-quilt/src/main/nextflow/quilt/QuiltObserver.groovy' No such property: importPackages for class: org.codehaus.groovy.ast.ModuleNode
What's crazy is that I no longer (directly) import any codehaus packages. I'm only using groovy4 from Apache:
groovyVer= '4.0.24'
dependencies {
// see https://docs.gradle.org/4.1/userguide/dependency_management.html#sec:module_replacement
implementation 'com.github.groovy-wslite:groovy-wslite:1.1.3'
implementation "org.apache.groovy:groovy-all:${groovyVer}"
implementation 'com.fasterxml.jackson.core:jackson-databind:2.18.2'
implementation 'com.upplication:s3fs:2.2.2'
modules {
module('commons-logging:commons-logging') { replacedBy('org.slf4j:jcl-over-slf4j') }
}
// Documentation required libraries
groovyDoc 'org.fusesource.jansi:jansi:2.4.1'
groovyDoc "org.apache.groovy:groovy-groovydoc:${groovyVer}"
groovyDoc "org.apache.groovy:groovy-ant:${groovyVer}"
}
I tried the other StackOverflow suggestions of clearing the cache, but no long.
My only guess is that one of my dependencies is somehow pulling in groovy3, and it is causing a weird conflict. Any suggestions for how to find it?
The short answer is that I had to do a lot of exclude group:
(with help from ChatGPT) to avoid collisions when moving to groovy4
;
https://github.com/quiltdata/nf-quilt/blob/main/plugins/nf-quilt/build.gradle
There were also some weird version issues in my codebase. Here's the definitions that finally worked:
groovyVersion = 4.0.24
groovyV = groovy-4.0
groovySource = apache
jdkVersion = 11
javaLangVersion = 21