I'm developing a Gradle Plugin that needs to read an output generated by an annotation processor wit...
b
I'm developing a Gradle Plugin that needs to read an output generated by an annotation processor with kapt. For that reason I'm depending on kapt task and all of that works fine. But now I want to test it because I want to also support the Android flavours and without tests that's a mess. When I run:
Copy code
val project = ProjectBuilder.builder()
    .build()

project.pluginManager.apply(KotlinPluginWrapper::class.java)
project.pluginManager.apply(Kapt3GradleSubplugin::class.java)
project.pluginManager.apply(LightsaberPlugin::class.java)
I can see the tasks generated by kotlin and my plugin but I can't see any task generated by kapt. This makes that my tests pointless because want I want is to assert that the tasks that my plugin adds depends on the correct kapt tasks (for example, that
:lightsaberDebugCheck
depends on
:kaptDebugKotlin
). I have some tests using
GradleRunner
but those tests are way slower and I can't assert the dependencies I just can assert that "X" task was executed without knowing the reason. Is there a way to make this work with
ProjectBuilder
? Any other idea to how to test this?
t
are you calling
project.evaluate()
and then make assertions?
b
I wasn't. I'm going to try that. I need to make an ugly cast to
ProjectInternal
but I only want it to works.
t
Kapt plugin does the main configuration quite late in the configuration phase, so you have to call
evaluate()
to get the actual state
b
It works! Thank you so much. I didn't know about the
evaluate
function.
👍 1