Skip to content

Gradle build: "compileKotlin" depends from "compileQuarkusGeneratedSourcesJava" #45057

@jmini

Description

@jmini

In a Quarkus project where we have the grpc extension (that generates java code) and kotlin, we sometimes have following error in the build:

FAILURE: Build failed with an exception.

* What went wrong:
Some problems were found with the configuration of task ':<project>:compileKotlin' (type 'KotlinCompile').
  - Gradle detected a problem with the following location: '/_path-to_/<project>/build/classes/java/quarkus-generated-sources'.
    
    Reason: Task ':<project>:compileKotlin' uses this output of task ':<project>:compileQuarkusGeneratedSourcesJava' 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 ':<project>:compileQuarkusGeneratedSourcesJava' as an input of ':<project>:compileKotlin'.
      2. Declare an explicit dependency on ':<project>:compileQuarkusGeneratedSourcesJava' from ':<project>:compileKotlin' using Task#dependsOn.
      3. Declare an explicit dependency on ':<project>:compileQuarkusGeneratedSourcesJava' from ':<project>:compileKotlin' using Task#mustRunAfter.
    
    For more information, please refer to https://docs.gradle.org/8.10.1/userguide/validation_problems.html#implicit_dependency in the Gradle documentation.
  - Gradle detected a problem with the following location: '/_path-to_/<project>/build/classes/java/quarkus-generated-sources/grpc'.
    
    Reason: Task ':<project>:compileKotlin' uses this output of task ':<project>:compileQuarkusGeneratedSourcesJava' 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 ':<project>:compileQuarkusGeneratedSourcesJava' as an input of ':<project>:compileKotlin'.
      2. Declare an explicit dependency on ':<project>:compileQuarkusGeneratedSourcesJava' from ':<project>:compileKotlin' using Task#dependsOn.
      3. Declare an explicit dependency on ':<project>:compileQuarkusGeneratedSourcesJava' from ':<project>:compileKotlin' using Task#mustRunAfter.
    
    For more information, please refer to https://docs.gradle.org/8.10.1/userguide/validation_problems.html#implicit_dependency in the Gradle documentation.
  - Gradle detected a problem with the following location: '/_path-to_/<project>/build/classes/java/quarkus-generated-sources/avdl'.
    
    Reason: Task ':<project>:compileKotlin' uses this output of task ':<project>:compileQuarkusGeneratedSourcesJava' 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 ':<project>:compileQuarkusGeneratedSourcesJava' as an input of ':<project>:compileKotlin'.
      2. Declare an explicit dependency on ':<project>:compileQuarkusGeneratedSourcesJava' from ':<project>:compileKotlin' using Task#dependsOn.
      3. Declare an explicit dependency on ':<project>:compileQuarkusGeneratedSourcesJava' from ':<project>:compileKotlin' using Task#mustRunAfter.
    
    For more information, please refer to https://docs.gradle.org/8.10.1/userguide/validation_problems.html#implicit_dependency in the Gradle documentation.
  - Gradle detected a problem with the following location: '/_path-to_/<project>/build/classes/java/quarkus-generated-sources/avpr'.
    
    Reason: Task ':<project>:compileKotlin' uses this output of task ':<project>:compileQuarkusGeneratedSourcesJava' 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 ':<project>:compileQuarkusGeneratedSourcesJava' as an input of ':<project>:compileKotlin'.
      2. Declare an explicit dependency on ':<project>:compileQuarkusGeneratedSourcesJava' from ':<project>:compileKotlin' using Task#dependsOn.
      3. Declare an explicit dependency on ':<project>:compileQuarkusGeneratedSourcesJava' from ':<project>:compileKotlin' using Task#mustRunAfter.
    
    For more information, please refer to https://docs.gradle.org/8.10.1/userguide/validation_problems.html#implicit_dependency in the Gradle documentation.
  - Gradle detected a problem with the following location: '/_path-to_/<project>/build/classes/java/quarkus-generated-sources/avsc'.
    
    Reason: Task ':<project>:compileKotlin' uses this output of task ':<project>:compileQuarkusGeneratedSourcesJava' 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 ':<project>:compileQuarkusGeneratedSourcesJava' as an input of ':<project>:compileKotlin'.
      2. Declare an explicit dependency on ':<project>:compileQuarkusGeneratedSourcesJava' from ':<project>:compileKotlin' using Task#dependsOn.
      3. Declare an explicit dependency on ':<project>:compileQuarkusGeneratedSourcesJava' from ':<project>:compileKotlin' using Task#mustRunAfter.
    
    For more information, please refer to https://docs.gradle.org/8.10.1/userguide/validation_problems.html#implicit_dependency in the Gradle documentation.

So for each "location":

  • quarkus-generated-sources
  • quarkus-generated-sources/grpc
  • quarkus-generated-sources/avdl
  • quarkus-generated-sources/avsc

You get one of those warnings.

I do not have a reliable reproducer (and I have the feeling that ./gradlew clean build always works), but the error looks correct to me.

I have the feeling that one reason might be that IDEA does not run the build command but select a set of tasks (probably for performance reasons)

IDEA Screenshot

07:01:48: Executing ':assemble :<project>:classes :<project>:testClasses :<project>:integrationTestClasses :<project>:nativeTestClasses :<project>:quarkusGeneratedSourcesClasses :<project>:quarkusTestGeneratedSourcesClasses --stacktrace'...

As a "fix" we are adding those to our build.gradle:

tasks.named("compileKotlin") {
    inputs.files(tasks.getByPath("compileQuarkusGeneratedSourcesJava").outputs.files)
}
tasks.named("sourcesJar") {
    inputs.files(tasks.getByPath("compileQuarkusGeneratedSourcesJava").outputs.files)
}

But this looks more an input/output declaration issue inside the quarkus gradle plugin.

Any thoughts on this?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions