Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jmini opened this issue Dec 11, 2024 · 1 comment

Comments

@jmini
Copy link
Contributor

jmini commented Dec 11, 2024

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?

Copy link

quarkus-bot bot commented Dec 11, 2024

/cc @geoand (kotlin), @glefloch, @quarkusio/devtools

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant