Kapt: Support apt options (KT-13984)
(cherry picked from commit b566a37)
This commit is contained in:
committed by
Yan Zhulanow
parent
0ae9a7a9d1
commit
f15f90a719
+15
-1
@@ -25,6 +25,8 @@ class Kapt2IT: BaseGradleIT() {
|
||||
private const val GRADLE_VERSION = "2.10"
|
||||
private const val GRADLE_2_14_VERSION = "2.14.1"
|
||||
private const val ANDROID_GRADLE_PLUGIN_VERSION = "1.5.+"
|
||||
|
||||
private val KAPT_SUCCESSFUL_REGEX = "Annotation processing complete in [0-9]+ ms, 0 errors, 0 warnings".toRegex()
|
||||
}
|
||||
|
||||
private fun androidBuildOptions() =
|
||||
@@ -35,8 +37,9 @@ class Kapt2IT: BaseGradleIT() {
|
||||
override fun defaultBuildOptions(): BuildOptions =
|
||||
super.defaultBuildOptions().copy(withDaemon = true)
|
||||
|
||||
|
||||
private fun CompiledProject.assertKaptSuccessful() {
|
||||
assertContains("Kapt: Annotation processing complete, 0 errors, 0 warnings")
|
||||
KAPT_SUCCESSFUL_REGEX.findAll(this.output).single()
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -98,6 +101,17 @@ class Kapt2IT: BaseGradleIT() {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testArguments() {
|
||||
Project("arguments", GRADLE_VERSION, directoryPrefix = "kapt2").build("build") {
|
||||
assertSuccessful()
|
||||
assertKaptSuccessful()
|
||||
assertFileExists("build/generated/source/kapt2/main/example/TestClassCustomized.java")
|
||||
assertFileExists("build/classes/main/example/TestClass.class")
|
||||
assertFileExists("build/classes/main/example/TestClassCustomized.class")
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testInheritedAnnotations() {
|
||||
Project("inheritedAnnotations", GRADLE_VERSION, directoryPrefix = "kapt2").build("build") {
|
||||
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
}
|
||||
dependencies {
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
}
|
||||
}
|
||||
|
||||
apply plugin: "kotlin"
|
||||
apply plugin: "kotlin-kapt"
|
||||
|
||||
repositories {
|
||||
mavenLocal()
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||
compile "org.jetbrains.kotlin:annotation-processor-example:$kotlin_version"
|
||||
kapt "org.jetbrains.kotlin:annotation-processor-example:$kotlin_version"
|
||||
}
|
||||
|
||||
kapt {
|
||||
arguments {
|
||||
arg("suffix", "Customized")
|
||||
}
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
kapt.verbose=true
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
package example
|
||||
|
||||
@example.ExampleAnnotation
|
||||
public class TestClass {
|
||||
|
||||
@example.ExampleAnnotation
|
||||
public val testVal: String = "text"
|
||||
|
||||
@example.ExampleAnnotation
|
||||
public fun testFunction(): Class<*> = TestClassCustomized::class.java
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user