Skip to content

Bug: Spotless gradle plugin execution fails with Gradle 8.0 #1572

@dejan2609

Description

@dejan2609

Note: related to apache/kafka#13205

Summary of the problem: 'spotlessScalaCheck' gradle task works as expected in isolation, but fails when combined with other Gradle tasks.

Gradle version: 8.0
Spotless Gradle plugin version: 6.15.0
Java version: 11
OS and version: Ubuntu 22.04

Reproducer: https://github.com/dejan2609/kafka/tree/gradle-8-java-11-spotlessPluginGradle-6.15.0

Step-by-step:

  • git clone https://github.com/dejan2609/kafka.git
  • cd kafka
  • git checkout gradle-8-java-11-spotlessPluginGradle-6.15.0
  • execute ./gradlew clean spotlessScalaCheck ➡️ build works fine ✅, but
  • execute same taks combined with other tasks (this long command is used on CI server, see Jenkinsfile):
    ./gradlew -PscalaVersion=2.13 clean compileJava compileScala compileTestJava compileTestScala spotlessScalaCheck checkstyleMain checkstyleTest spotbugsMain rat --profile --continue -PxmlSpotBugsReport=true -PkeepAliveMode="session"
  • and build breaks ❌ (see below for more details).
dejan@dejan-HP-ProBook-450-G7:~/IdeaProjects/kafka$ date
Wed 15 Feb 15:39:17 CET 2023
dejan@dejan-HP-ProBook-450-G7:~/IdeaProjects/kafka$ java -version
openjdk version "11.0.17" 2022-10-18
OpenJDK Runtime Environment (build 11.0.17+8-post-Ubuntu-1ubuntu222.04)
OpenJDK 64-Bit Server VM (build 11.0.17+8-post-Ubuntu-1ubuntu222.04, mixed mode, sharing)
dejan@dejan-HP-ProBook-450-G7:~/IdeaProjects/kafka$ git log -3 --oneline
4c366b4e23 (HEAD -> gradle-8-java-11-spotlessPluginGradle-6.15.0, origin/gradle-8-java-11-spotlessPluginGradle-6.15.0) Spotless Gradle plugin version is bumped from 6.13.0 to 6.15.0
0e82675469 (origin/gradle-8-test, origin/gradle-8, gradle-8-test, gradle-8) KAFKA-14680: gradle version upgrade 7 -->> 8
b9754747d6 (upstream/trunk, origin/trunk, origin/HEAD, trunk) KAFKA-14653: Use raw properties instead of post-resolution properties for MirrorMaker connectors(#13163)
dejan@dejan-HP-ProBook-450-G7:~/IdeaProjects/kafka$ ./gradlew clean spotlessScalaCheck

> Configure project :
Starting build with version 3.5.0-SNAPSHOT (commit id 4c366b4e) using Gradle 8.0, Java 11 and Scala 2.13.10
Build properties: maxParallelForks=8, maxScalacThreads=8, maxTestRetries=0

BUILD SUCCESSFUL in 5s
51 actionable tasks: 4 executed, 47 up-to-date
dejan@dejan-HP-ProBook-450-G7:~/IdeaProjects/kafka$ ./gradlew -PscalaVersion=2.13 clean compileJava compileScala compileTestJava compileTestScala spotlessScalaCheck checkstyleMain checkstyleTest spotbugsMain rat --profile --continue -PxmlSpotBugsReport=true -PkeepAliveMode="session"

> Configure project :
Starting build with version 3.5.0-SNAPSHOT (commit id 4c366b4e) using Gradle 8.0, Java 11 and Scala 2.13.10
Build properties: maxParallelForks=8, maxScalacThreads=8, maxTestRetries=0

> Task :spotlessScala FAILED

> Task :core:compileScala
Unexpected javac output: warning: [options] bootstrap class path not set in conjunction with -source 8
1 warning.

> Task :core:compileTestScala
Unexpected javac output: warning: [options] bootstrap class path not set in conjunction with -source 8
1 warning.

FAILURE: Build failed with an exception.

* What went wrong:
Some problems were found with the configuration of task ':spotlessScala' (type 'SpotlessTaskImpl').
  - Gradle detected a problem with the following location: '/home/dejan/IdeaProjects/kafka'.
   
    Reason: Task ':spotlessScala' uses this output of task ':streams:processResources' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed.
   
    Possible solutions:
      1. Declare task ':streams:processResources' as an input of ':spotlessScala'.
      2. Declare an explicit dependency on ':streams:processResources' from ':spotlessScala' using Task#dependsOn.
      3. Declare an explicit dependency on ':streams:processResources' from ':spotlessScala' using Task#mustRunAfter.
   
    Please refer to https://docs.gradle.org/8.0/userguide/validation_problems.html#implicit_dependency for more details about this problem.
  - Gradle detected a problem with the following location: '/home/dejan/IdeaProjects/kafka'.
   
    Reason: Task ':spotlessScala' uses this output of task ':streams:processTestResources' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed.
   
    Possible solutions:
      1. Declare task ':streams:processTestResources' as an input of ':spotlessScala'.
      2. Declare an explicit dependency on ':streams:processTestResources' from ':spotlessScala' using Task#dependsOn.
      3. Declare an explicit dependency on ':streams:processTestResources' from ':spotlessScala' using Task#mustRunAfter.
   
    Please refer to https://docs.gradle.org/8.0/userguide/validation_problems.html#implicit_dependency for more details about this problem.
  - Gradle detected a problem with the following location: '/home/dejan/IdeaProjects/kafka'.
   
    Reason: Task ':spotlessScala' uses this output of task ':streams:upgrade-system-tests-0100:compileTestJava' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed.
   
    Possible solutions:
      1. Declare task ':streams:upgrade-system-tests-0100:compileTestJava' as an input of ':spotlessScala'.
      2. Declare an explicit dependency on ':streams:upgrade-system-tests-0100:compileTestJava' from ':spotlessScala' using Task#dependsOn.
      3. Declare an explicit dependency on ':streams:upgrade-system-tests-0100:compileTestJava' from ':spotlessScala' using Task#mustRunAfter.
   
    Please refer to https://docs.gradle.org/8.0/userguide/validation_problems.html#implicit_dependency for more details about this problem.
  - Gradle detected a problem with the following location: '/home/dejan/IdeaProjects/kafka'.
   
    Reason: Task ':spotlessScala' uses this output of task ':streams:upgrade-system-tests-0101:compileTestJava' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed.
   
    Possible solutions:
      1. Declare task ':streams:upgrade-system-tests-0101:compileTestJava' as an input of ':spotlessScala'.
      2. Declare an explicit dependency on ':streams:upgrade-system-tests-0101:compileTestJava' from ':spotlessScala' using Task#dependsOn.
      3. Declare an explicit dependency on ':streams:upgrade-system-tests-0101:compileTestJava' from ':spotlessScala' using Task#mustRunAfter.
   
    Please refer to https://docs.gradle.org/8.0/userguide/validation_problems.html#implicit_dependency for more details about this problem.
  - Gradle detected a problem with the following location: '/home/dejan/IdeaProjects/kafka'.
   
    Reason: Task ':spotlessScala' uses this output of task ':streams:upgrade-system-tests-0102:compileTestJava' without declaring an explicit or implicit dependency. This can lead to incorrect results being produced, depending on what order the tasks are executed.
   
    Possible solutions:
      1. Declare task ':streams:upgrade-system-tests-0102:compileTestJava' as an input of ':spotlessScala'.
      2. Declare an explicit dependency on ':streams:upgrade-system-tests-0102:compileTestJava' from ':spotlessScala' using Task#dependsOn.
      3. Declare an explicit dependency on ':streams:upgrade-system-tests-0102:compileTestJava' from ':spotlessScala' using Task#mustRunAfter.
   
    Please refer to https://docs.gradle.org/8.0/userguide/validation_problems.html#implicit_dependency for more details about this problem.

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org/

BUILD FAILED in 8m 7s
251 actionable tasks: 196 executed, 55 up-to-date

See the profiling report at: file:///home/dejan/IdeaProjects/kafka/build/reports/profile/profile-2023-02-15-15-40-14.html
A fine-grained performance profile is available: use the --scan option.
dejan@dejan-HP-ProBook-450-G7:~/IdeaProjects/kafka$ date
Wed 15 Feb 15:48:53 CET 2023
dejan@dejan-HP-ProBook-450-G7:~/IdeaProjects/kafka$

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions