I'm having an issue where applying the kapt plugin...
# kapt
I'm having an issue where applying the kapt plugin in gradle prevents it from running other java annotation processors during
. Any idea why that could be happening?
Looks like they now run when I apply
on them, but the problem I had still persists :/
you want to run APT for some annotation processors and Kapt for another?
Kapt doesn’t run as part of compileJava, you have to specify APs explicitly using configuration
, actually I even not sure that compileJava runs Apt, I think Gradle now requires using configuration
for them
This is what I ended up with. The following sights may be disturbing.
Copy code
protected void passArgument(KaptTask compileTask, String key, String value) {
		// Kapt doesn't provide an api to pass the AP args directly to the task so we need to do this hackery.
		CompilerPluginOptions options;
		if (compileTask instanceof KaptWithoutKotlincTask) {
			KaptWithoutKotlincTask task = (KaptWithoutKotlincTask) compileTask;
			// We are now entering the danger zone
			//noinspection KotlinInternalInJava aka @ts-ignore
			options = task.getProcessorOptions$kotlin_gradle_plugin();
		} else {
			KaptWithKotlincTask task = (KaptWithKotlincTask) compileTask;
			//noinspection KotlinInternalInJava aka @ts-ignore
			options = task.getPluginOptions$kotlin_gradle_plugin();

		options.addPluginArgument(Kapt3KotlinGradleSubplugin.Companion.getKAPT_SUBPLUGIN_ID(), new SubpluginOption(key, value));
Aaaand it doesn't work with
since it's encoded
Do you need different arguments for different Kapt tasks? There is an extension on project level (but it will be applied to all tasks): https://kotlinlang.org/docs/reference/kapt.html#java-compiler-options
actually I even not sure that compileJava runs Apt
Yes, it does, checked this. But it’s not recommended way and Gradle recommends to have annotation processors separately and use
annotation This behaviour probably can be changed with kapt.include.compile.classpath=true, but it’s not recommended
Thank you, I managed to work around being able to only supply args to all tasks at once