Can we somewhat disable/"unregister" a Processor t...
# kapt
s
Can we somewhat disable/"unregister" a Processor that previously registered either via @AutoService or META-INF? My case is I want to disable some processor from kapt when running unit test because it's unnecessary to execute them. Thanks
t
could you describe your issue a little more? AFAIK you need explicitly specify kapt processors for tests annotation processing.
s
Hi @tapchicoma! I'm terribly sorry for the late reply since I sign-out from the workplace a while ago. Given:
Copy code
// build.gradle

dependencies {
    kapt(libraryA)
}
When I run the unit test, I can see the kapt libraryA is running (main classpath) which I don't think it's necessary to run since my unit test simply doesn't need any of its generated codes. My question is can I skip this particular kapt when running unit test? Currently I just apply the conditional check:
Copy code
dependencies {
    if (task is not unit test) {
        kapt(libraryA)
    }
}
It works but I'm just wondering for more cleaner way if any.
t
hm, probably cleaner way would be to split you code that does not require annotation processor into separate Gradle sub-project and include it into the code that require annotation processor as project dependency
b
I use this:
Copy code
tasks
  .matching {
    it.name.startsWith("kapt") && it.name.endsWith("TestKotlin")
  }
  .configureEach { it.enabled = false }
from: https://www.zacsweers.dev/kapts-hidden-test-costs/ it only works if you don't want to run any annotation processor on your tests.