nebula-plugins / gradle-lint-plugin

A pluggable and configurable linter tool for identifying and reporting on patterns of misuse or deprecations in Gradle scripts.
Apache License 2.0
761 stars 88 forks source link

Incompatible with Groovy 3.0.9 #374

Closed fawind closed 2 years ago

fawind commented 2 years ago

It looks like in newer versions of Groovy, GroovyCodeVisitor added some additional abstract methods, e.g. GroovyCodeVisitor#visitMethodReferenceExpression and GroovyCodeVisitor#visitLambdaExpression.

As a result, compiling a custom lint rule fails if it not explicitly implements those methods. Example error:

../MyCustomLintRule.java:87: error: MyCustomLintRule is not abstract and does not override abstract method visitMethodReferenceExpression(MethodReferenceExpression) in GroovyCodeVisitor

This is because we don't provide a default override in GroovyAstVisitor yet, forcing subclasses to provide an implementation themselfes: https://github.com/nebula-plugins/gradle-lint-plugin/blob/bab4653121e793e37a7163b54b2603390b504e0d/src/main/groovy/com/netflix/nebula/lint/rule/GroovyAstVisitor.groovy#L12

Note that Gradle 7.4 depends on Groovy 3.0.9 so this is blocking repos to adopt newer Gradle versions.

chali commented 2 years ago

The goal of lint plugin is to keep backward compatibility. For that reason it needs to keep using Gradle 6.x as API and with that Groovy 2.x. It is possible to have a plugin compiled against older Gradle and Groovy version and use it in Gradle 7.x but not the other way.

You can see the Gradle API declaration here https://github.com/nebula-plugins/gradle-lint-plugin/blob/main/build.gradle#L62

If you are developing custom rules and they are using Gradle 7.x you need to fill the missing methods there. It is not possible to put them here because both missing methods are using classes from Groovy 3 as parameters.