Gradle 2.2-rc-1 regression: codenarcTest fails with NoClassDefFoundError

One of our projects fails with the following error:

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ‘:foo:bar:codenarcTest’. > java.lang.NoClassDefFoundError: groovy.text.SimpleTemplateEngine

the module in question is using the codenarc plugin: apply plugin: ‘codenarc’

This is the thrown exception:

The same project/module builds fine with Gradle 2.1

Thanks for reporting.

which groovy and codenarc dependencies / versions are you using in your build?

It will be this change:

Most likely cause is that you are using a transform (perhaps even implicitly) that is doing the wrong thing and trying to load classes.

Would you be able to provide the complete stacktrace (will need to run with ‘-S’, not ‘-s’)?. Also, if you can provide a reproducible sample that would be even better.

Thanks for your reliable testing of the RCs once more.

Hi there.

Exception with -S:

configuration of the modules:


The groovy version we reference in our builds (i.e. in our own code) is 2.3.7 and we don’t explicitly use any codenarc dependencies. We just apply the plugin. So I assume the build is just using the groovy and codenarc versions used by Gradle 2.2-rc-1. Is there something like ‘gradle dependencies’ but for the build instead of the module?

Please let me know if I can do anything else to help resolving this.

Sorry for the delayed answer. No problem regarding the ongoing testing. :slight_smile:

Do you have some kind of dependency rules for the Groovy dependency of your main code? Some kind of force rule maybe? Also, are you depending on groovy-core?

I found the culprit!

We have (beside other replacements)

project.allprojects { project ->
   resolutionStrategy.eachDependency { DependencyResolveDetails details ->
  def req = details.requested
  if ( == 'org.codehaus.groovy' && == 'groovy-all') {
   details.useTarget managedDependency('org.codehaus.groovy:groovy')

in our build since we consider the ‘groovy-all’ dependency a no-no. We prefer explicit dependencies over catch-all ones. Essentially like ye olde ‘org.springframework:spring’. The Groovy devs consider getting rid of the ‘-all’ dependency in the future, I think.

I didn’t expect that to have an influence on plugin dependencies, though.


The CodeNarc plugin gets its CodeNarc implementation from the ‘codenarc’ configuration. Until 2.2, we imposed Gradle’s version of Groovy on CodeNarc instead of the version in its classpath, which was not a good situation.

I’ve started a thread on the dev list to try and work out what we can do about this problem.