google / protobuf-gradle-plugin

Protobuf Plugin for Gradle
Other
1.76k stars 274 forks source link

KSP dependency on generateProto - unable to build project due to KspTaskJvm issue #740

Open bardale opened 10 months ago

bardale commented 10 months ago

I am using Kotlin 1.9.20 with Gradle 8.4 with id("com.google.devtools.ksp") version "1.9.20-1.0.14" in a gradle multimodule project and I am unable to build the project. Getting the errors below:

What went wrong:

Some problems were found with the configuration of task ':xxxxx:kspKotlin' (type 'KspTaskJvm').

   Gradle detected a problem with the following location: 'C:\Users...\ServiceGrpc.java'.

  Reason: Task ':xxxxx-rest:kspKotlin' uses this output of task ':xxxxx-rest:generateProto' 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:

    Declare task ':xxxxx-rest:generateProto' as an input of ':xxxxx-rest:kspKotlin'.
    Declare an explicit dependency on ':xxxxx-rest:generateProto' from ':xxxxx-rest:kspKotlin' using Task#dependsOn.
    Declare an explicit dependency on ':xxxxx-rest:generateProto' from ':xxxxx-rest:kspKotlin' using Task#mustRunAfte
    r.

When setting explicit dependency as suggest, gradle is unable to find the task kspKotlin.

Thanks

ejona86 commented 10 months ago

It looks like those issues are just with your usage of ksp, and not related to this plugin. I'm not really able to help with that.

Unable to find the task is probably due to execution ordering. If you are able to configure it in an evaluateAfter {} block, then it confirms it is just an ordering problem.