Configuring CodeNarc for JDK 17

82 Views Asked by At

What are the best practices for configuring codenarc in Gradle for JDK 17 and above?

There is a very tempting toolVersion documented here: https://docs.gradle.org/current/dsl/org.gradle.api.plugins.quality.CodeNarcExtension.html

But, it doesn't appear to work as I always get this error:

Execution failed for task ':app:codenarcTest'.
> A failure occurred while executing org.gradle.api.plugins.quality.internal.CodeNarcAction
   > BUG! exception in phase 'semantic analysis' in source unit 'Script1.groovy' Unsupported class file major version 61

The only workaround that I've discovered is to use:

   configurations.configureEach {
        resolutionStrategy {
            eachDependency {
              if (requested.group == 'org.codenarc' && requested.name == 'CodeNarc') {
                  useVersion "3.3.0"
              }
        }
    }

Which seems like an overkill.

0

There are 0 best solutions below