Dejan Stojadinović created KAFKA-20062:
------------------------------------------

             Summary: Provide compatible CheckStyle versions for a different 
Java versions
                 Key: KAFKA-20062
                 URL: https://issues.apache.org/jira/browse/KAFKA-20062
             Project: Kafka
          Issue Type: Wish
          Components: build
            Reporter: Dejan Stojadinović


(x) *Issue description:* Java 17 Gradle build fails with Checkstyle 13+ version:

{code:java}
> Task :streams:upgrade-system-tests-22:checkstyleTest FAILED
Running checkstyle with toolchain 
'/home/dejan/.sdkman/candidates/java/17.0.17-tem'.

> Task :clients:processMessages
MessageGenerator: processed 197 Kafka message JSON file(s).

[Incubating] Problems report is available at: 
file:///home/dejan/kafka/build/reports/problems/problems-report.html

FAILURE: Build completed with 7 failures.

1: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':test-common:test-common-util:checkstyleMain'.
> A failure occurred while executing 
> org.gradle.api.plugins.quality.internal.CheckstyleAction
   > com/puppycrawl/tools/checkstyle/ant/CheckstyleAntTask has been compiled by 
a more recent version of the Java Runtime (class file version 65.0), this 
version of the Java Runtime only recognizes class file versions up to 61.0

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --debug option to get more log output.
> Get more help at https://help.gradle.org.
{code}


(on) *What can be done* - change Gradle build and resolve CheckStyle version 
like this: 
* for Java 17 build: use CheckStyle version 12
* for Java 25 build: use CheckStyle version 13+
 
(i) Related useful links: 
* CheckStyle 13 release notes: 
https://checkstyle.sourceforge.io/releasenotes.html#Release_13.0.0
* 
https://www.baeldung.com/java-gradle-toolchains-jvm-projects#toolchains-on-task-level
* 
https://discuss.gradle.org/t/conditional-dependency-based-on-toolchains-version/46369
* https://docs.gradle.org/9.2.1/userguide/toolchains.html
* 
https://docs.gradle.org/9.2.1/samples/sample_jvm_multi_project_with_toolchains.html
 
* 
https://discuss.gradle.org/t/conditional-dependency-based-on-toolchains-version/46369
 
* https://discuss.gradle.org/t/using-variants-and-toolchains-together/44658/13 
* https://docs.gradle.org/current/userguide/getting_started_dep_man.html 

(!) Pitfalls:
* 
https://docs.gradle.org/9.2.1/userguide/toolchains.html#sec:using-java-toolchains
 (it seems that toolchain support for Scala is not complete at the moment)
* KAFKA-19976 and 
[KIP-1244|https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=399278767]



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to