SpongePowered / SpongeGradle

Handy gradle utilities for the various gradle projects of SpongePowered
MIT License
21 stars 16 forks source link

Misleading "Cannot run plugin annotation processor..." when using Kotlin's kapt #13

Closed BenWoodworth closed 2 years ago

BenWoodworth commented 6 years ago

https://github.com/SpongePowered/SpongeGradle/blob/bac4799a938c12a1a482a9391e40aad7e7a3ff4d/src/main/groovy/org/spongepowered/gradle/plugin/SpongePluginBasePlugin.groovy#L49-L55

Kotlin's annotation processor, kapt, disables Java's annotation processor (by adding the -proc:none flag to the compiler arguments), and processes Java annotations itself.

https://github.com/JetBrains/kotlin/blob/06903f803bb9ef9c2f8f625e428e8dcedf4cd3f9/libraries/tools/kotlin-gradle-plugin/src/main/kotlin/org/jetbrains/kotlin/gradle/internal/Kapt3KotlinGradleSubplugin.kt#L360-L373

Everything processes and compiles as expected (including the plugin metadata), but since the Sponge Gradle plugin sees the -proc:none flag, it displays an error.

Cannot run plugin annotation processor; annotation processing is disabled. Plugin metadata will NOT be merged with the @Plugin annotation!

It would be nice if there were a way to disable this message, since an error message in a successful compilation can be misleading.

stephan-gh commented 6 years ago

The annotation processor is separate from SpongeGradle, and generally works without it. If you run into this error, all extended functionality in SpongeGradle won't work correctly (e.g. merging of existing mcmod.info in the resource folder, or overriding values from Gradle).

This is because the additional compiler arguments read by the annotation processor won't be set because it returns earlier with this error: https://github.com/SpongePowered/SpongeGradle/blob/master/src/main/groovy/org/spongepowered/gradle/plugin/SpongePluginBasePlugin.groovy#L66-L70

So the actual question is: If we disable this error and set the compiler arguments anyway, will kapt take them from the Java task and apply them when running the annotation processor? Or do we need to do handle this manually?

zml2008 commented 2 years ago

This issue is no longer applicable to SpongeGradle 2.0.0+