Am I missing something obvious? I feel like compil...
# compiler
r
Am I missing something obvious? I feel like compiler plugins can easily break with incremental compilation. My plugin generates a new Kotlin file when another file contains an annotation. I add the plugin with
Copy code
dependencies {
  kotlinCompilerPluginClasspath project(':myplugin')
}
If I change something in my compiler plugin, then I see that the Kotlin compilation tasks aren’t up to date, because my compiler plugin changed. Good! The problem now is that the incremental compilation kicks in and doesn’t recompile the code in the module, because nothing has changed for the source files individually, only the Kotlin compiler plugin dependency has changed. Is there a way to recompile a module, if one of its compiler plugins has changed? (I tested disabling incremental compilation and this fixes the problem. But I’m afraid of the slow compilation long term.)
s
you can add sources to gradle config?
Copy code
tasks.withType(KotlinCompile).all { it -> 
    it.source(myDir)
}
r
myDir
would be a dependency on the compiler plugin and I don’t want to include it there. But I found a workaround now. I register a custom Gradle task that toggles the incremental flag. The input for the custom task is necessary classpath (the compiler plugin classpath most of the time). That means when my plugin changes, then my custom task will run and disable incremental compilation. If my plugin doesn’t change, then my custom task won’t run and I don’t disable incremental compilation. It works quite nicely. I’ll follow up with a bug report.