Kapt: Extract annotation processing running logic from the compiler plugin

This commit is contained in:
Yan Zhulanow
2018-05-14 16:37:05 +03:00
parent 3ecf355e7a
commit 2bc45e0484
43 changed files with 843 additions and 577 deletions
@@ -7,6 +7,7 @@
<properties>
<maven.version>3.0.4</maven.version>
<annotation-processing.src>${basedir}/../../../plugins/kapt3/kapt3-compiler/src</annotation-processing.src>
<annotation-processing.base.src>${basedir}/../../../plugins/kapt3/kapt3-base/src</annotation-processing.base.src>
<annotation-processing.runtime.src>${basedir}/../../../plugins/kapt3/kapt3-runtime/src</annotation-processing.runtime.src>
<annotation-processing.target-src>${basedir}/target/src/main/kotlin</annotation-processing.target-src>
<annotation-processing.target-src-test>${basedir}/target/src/test/kotlin</annotation-processing.target-src-test>
@@ -69,6 +70,7 @@
<outputDirectory>${annotation-processing.target-src}</outputDirectory>
<resources>
<resource><directory>${annotation-processing.src}</directory></resource>
<resource><directory>${annotation-processing.base.src}</directory></resource>
<resource><directory>${annotation-processing.runtime.src}</directory></resource>
</resources>
</configuration>
@@ -120,24 +120,6 @@ open class Kapt3IT : Kapt3BaseIT() {
}
}
@Test
fun testArguments() {
Project("arguments", directoryPrefix = "kapt2").build("build") {
assertSuccessful()
assertKaptSuccessful()
assertContains(
"Options: {suffix=Customized, justColon=:, justEquals==, containsColon=a:b, " +
"containsEquals=a=b, startsWithColon=:a, startsWithEquals==a, endsWithColon=a:, " +
"endsWithEquals=a:, withSpace=a b c,"
)
assertContains("-Xmaxerrs=500, -Xlint:all=-Xlint:all") // Javac options test
assertFileExists("build/generated/source/kapt/main/example/TestClassCustomized.java")
assertFileExists(kotlinClassesDir() + "example/TestClass.class")
assertFileExists(javaClassesDir() + "example/TestClassCustomized.class")
assertContains("Annotation processor class names are set, skip AP discovery")
}
}
@Test
fun testInheritedAnnotations() {
Project("inheritedAnnotations", directoryPrefix = "kapt2").build("build") {
@@ -150,6 +132,24 @@ open class Kapt3IT : Kapt3BaseIT() {
}
}
@Test
fun testArguments() {
Project("arguments", directoryPrefix = "kapt2").build("build") {
assertSuccessful()
assertKaptSuccessful()
assertContains(
"AP options: {suffix=Customized, justColon=:, justEquals==, containsColon=a:b, " +
"containsEquals=a=b, startsWithColon=:a, startsWithEquals==a, endsWithColon=a:, " +
"endsWithEquals=a:, withSpace=a b c,"
)
assertContains("-Xmaxerrs=500, -Xlint:all=-Xlint:all") // Javac options test
assertFileExists("build/generated/source/kapt/main/example/TestClassCustomized.java")
assertFileExists(kotlinClassesDir() + "example/TestClass.class")
assertFileExists(javaClassesDir() + "example/TestClassCustomized.class")
assertContains("Annotation processor class names are set, skip AP discovery")
}
}
@Test
fun testGeneratedDirectoryIsUpToDate() {
val project = Project("generatedDirUpToDate", directoryPrefix = "kapt2")