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:
committed by
Yan Zhulanow
parent
53fa647d41
commit
3a768060ca
+11
@@ -56,6 +56,17 @@ class Kapt3WorkersIT : Kapt3IT() {
|
|||||||
assertSubstringCount("Loaded com.sun.tools.javac.util.Context from", 1)
|
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() {
|
open class Kapt3IT : Kapt3BaseIT() {
|
||||||
|
|||||||
+22
@@ -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"
|
||||||
|
}
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
class Referred
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
public class Referring {
|
||||||
|
public Referred r;
|
||||||
|
}
|
||||||
+4
@@ -79,6 +79,10 @@ open class KaptWithoutKotlincTask @Inject constructor(private val workerExecutor
|
|||||||
kaptFlagsForWorker
|
kaptFlagsForWorker
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Skip annotation processing if no annotation processors were provided.
|
||||||
|
if (annotationProcessorFqNames.isEmpty() && kaptClasspath.isEmpty())
|
||||||
|
return
|
||||||
|
|
||||||
val kaptClasspath = kaptJars + findKotlinStdlibClasspath(project)
|
val kaptClasspath = kaptJars + findKotlinStdlibClasspath(project)
|
||||||
|
|
||||||
workerExecutor.submit(KaptExecution::class.java) { config ->
|
workerExecutor.submit(KaptExecution::class.java) { config ->
|
||||||
|
|||||||
Reference in New Issue
Block a user