Sudden issue with Gradle 3.5.1 and codenarc


(Shawn Crain) #1

We have a project in my org using gradle 3.5.1 and codenarc which was working fine, but this week started failing with the error java.lang.NoClassDefFoundError: groovy/text/SimpleTemplateEngine for the codenarc tasks. We traced this down to the fact that the version of Groovy for the codenarc configuration is getting increased from 2.1.8 to 3.0.0-alpha-4 which doesn’t have the necessary implementation.

I’m unable to determine why the version of Groovy is getting resolved to the newer version. Codenarc clearly declares 2.1.8 as the dependent version and nothing else appears to be referencing anything newer.

Even with the below, stripped down, build.gradle, we get the same result. Seems to clear up under gradle 4.+, so we’re looking at making the move but that might take a little time.

Just wondering if anyone could point out something we might be missing that explains this.

Thanks much.

build.gradle

apply plugin: 'groovy'
apply plugin: 'codenarc'

repositories {
    jcenter()
}

output of: gradle dependencies --configuration codenarc

codenarc - The CodeNarc libraries to be used for this project.
\--- org.codenarc:CodeNarc:0.25.2
     +--- junit:junit:4.8.1
     +--- org.codehaus.groovy:groovy-xml:2.1.8 -> 3.0.0-alpha-4
     |    \--- org.codehaus.groovy:groovy:3.0.0-alpha-4
     +--- org.codehaus.groovy:groovy:2.1.8 -> 3.0.0-alpha-4
     +--- org.codehaus.groovy:groovy-ant:2.1.8 -> 3.0.0-alpha-4
     |    +--- org.codehaus.groovy:groovy:3.0.0-alpha-4
     |    +--- org.codehaus.groovy:groovy-groovydoc:3.0.0-alpha-4
     |    +--- org.apache.ant:ant-junit:1.10.5
     |    \--- org.apache.ant:ant-antlr:1.10.5
     \--- org.gmetrics:GMetrics:0.7
          +--- org.codehaus.groovy:groovy:[2.1.0,) -> 3.0.0-alpha-4
          +--- org.codehaus.groovy:groovy-xml:[2.1.0,) -> 3.0.0-alpha-4 (*)
          \--- org.codehaus.groovy:groovy-ant:[2.1.0,) -> 3.0.0-alpha-4 (*)

(*) - dependencies omitted (listed previously)

output of gradle dependencyInsight --configuration codenarc --dependency groovy

org.codehaus.groovy:groovy:3.0.0-alpha-4
+--- org.codehaus.groovy:groovy-ant:3.0.0-alpha-4
|    +--- org.codenarc:CodeNarc:0.25.2
|    |    \--- codenarc
|    \--- org.gmetrics:GMetrics:0.7
|         \--- org.codenarc:CodeNarc:0.25.2 (*)
\--- org.codehaus.groovy:groovy-xml:3.0.0-alpha-4
     +--- org.codenarc:CodeNarc:0.25.2 (*)
     \--- org.gmetrics:GMetrics:0.7 (*)

org.codehaus.groovy:groovy:2.1.8 -> 3.0.0-alpha-4
\--- org.codenarc:CodeNarc:0.25.2
     \--- codenarc

org.codehaus.groovy:groovy:[2.1.0,) -> 3.0.0-alpha-4
\--- org.gmetrics:GMetrics:0.7
     \--- org.codenarc:CodeNarc:0.25.2
          \--- codenarc

org.codehaus.groovy:groovy-ant:3.0.0-alpha-4 (conflict resolution)

org.codehaus.groovy:groovy-ant:2.1.8 -> 3.0.0-alpha-4
\--- org.codenarc:CodeNarc:0.25.2
     \--- codenarc

org.codehaus.groovy:groovy-ant:[2.1.0,) -> 3.0.0-alpha-4
\--- org.gmetrics:GMetrics:0.7
     \--- org.codenarc:CodeNarc:0.25.2
          \--- codenarc

org.codehaus.groovy:groovy-groovydoc:3.0.0-alpha-4 (conflict resolution)
\--- org.codehaus.groovy:groovy-ant:3.0.0-alpha-4
     +--- org.codenarc:CodeNarc:0.25.2
     |    \--- codenarc
     \--- org.gmetrics:GMetrics:0.7
          \--- org.codenarc:CodeNarc:0.25.2 (*)

org.codehaus.groovy:groovy-xml:3.0.0-alpha-4 (conflict resolution)

org.codehaus.groovy:groovy-xml:2.1.8 -> 3.0.0-alpha-4
\--- org.codenarc:CodeNarc:0.25.2
     \--- codenarc

org.codehaus.groovy:groovy-xml:[2.1.0,) -> 3.0.0-alpha-4
\--- org.gmetrics:GMetrics:0.7
     \--- org.codenarc:CodeNarc:0.25.2
          \--- codenarc

(Shawn Crain) #2

We have some builds that can’t be moved past Gradle 3.x at the moment. Still unable to determine the root cause. Current work-around is to override the resolution strategy.

configurations.codenarc {
    resolutionStrategy.eachDependency { DependencyResolveDetails d ->
        if (d.requested.group == 'org.codehaus.groovy') {
            d.useVersion '2.1.8'
        }
    }
}

(Chandrasekar) #3

I am getting the same error too but with Gradle 2.12 version.
Are you still using the work around?
I see the Groovy’s 3.0 alpha 4 release in Jan 1st,2019. Might be some conflict with that


(Jenn Strater) #4

Hi everyone.

There is an issue with that version of codenarc pulling in some dependencies which are using a dynamic versioning strategy which you can see in that output. To resolve this, you should upgrade to codenarc 1.0+ which uses static version numbers instead.

Although a lot of internals changed in codenarc 1.0, usage should be the same. If you include all the rules by default, you may start getting some new failures, but most users were fine upgrading. Just let me know if you need help.


(Shawn Crain) #5

Thanks Jenn,

Just out of curiosity, do you know offhand where the dynamic versions were defined? I dug through source for the older versions of the codenarc project in github and everything appeared to be static versions to me.

Thanks again!

Shawn


(Jenn Strater) #6

Hi @scrain,

It’s actually from GMetrics which codenarc depends on.

Best,
Jenn