Skip annotation processing when there's no AP specified

This also fixes KT-29302 where stub generation is skipped while the
subsequent annotation processing phase anticipates the generated stubs.

This patch addresses cases where kapt.use.worker.api=true. The cases
where kapt.use.worker.api=false are handled in the same place of stub
generation.
This commit is contained in:
Ting-Yuan Huang
2019-01-16 17:54:15 -08:00
committed by Yan Zhulanow
parent 53fa647d41
commit 3a768060ca
5 changed files with 41 additions and 0 deletions
@@ -56,6 +56,17 @@ class Kapt3WorkersIT : Kapt3IT() {
assertSubstringCount("Loaded com.sun.tools.javac.util.Context from", 1)
}
}
@Test
fun testKaptSkipped() {
val gradleVersionRequired = GradleVersionRequired.AtLeast("4.3")
val project =
Project("kaptSkipped", directoryPrefix = "kapt2", gradleVersionRequirement = gradleVersionRequired)
project.build("build") {
assertSuccessful()
}
}
}
open class Kapt3IT : Kapt3BaseIT() {
@@ -0,0 +1,22 @@
buildscript {
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
apply plugin: "java"
apply plugin: "kotlin"
apply plugin: "kotlin-kapt"
repositories {
mavenLocal()
mavenCentral()
}
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
}
@@ -0,0 +1,3 @@
public class Referring {
public Referred r;
}
@@ -79,6 +79,10 @@ open class KaptWithoutKotlincTask @Inject constructor(private val workerExecutor
kaptFlagsForWorker
)
// Skip annotation processing if no annotation processors were provided.
if (annotationProcessorFqNames.isEmpty() && kaptClasspath.isEmpty())
return
val kaptClasspath = kaptJars + findKotlinStdlibClasspath(project)
workerExecutor.submit(KaptExecution::class.java) { config ->