Add basic kapt tests

This commit is contained in:
Yan Zhulanow
2015-06-16 18:39:21 +03:00
parent fee1726dfb
commit 7f2bd5b9d4
5 changed files with 125 additions and 0 deletions
@@ -58,4 +58,31 @@ class KotlinGradleIT: BaseGradleIT() {
assertContains(":compileKotlin", ":compileTestKotlin")
}
}
Test fun testKaptSimple() {
Project("kaptSimple", "1.12").build("build") {
assertSuccessful()
assertContains("kapt: Class file stubs are not used")
assertContains(":compileKotlin")
assertContains(":compileJava")
assertFileExists("build/tmp/kapt/main/wrappers/annotations.main.txt")
assertFileExists("build/generated/source/kapt/main/TestClassGenerated.java")
assertFileExists("build/classes/main/example/TestClass.class")
assertFileExists("build/classes/main/example/TestClassGenerated.class")
}
}
Test fun testKaptStubs() {
Project("kaptStubs", "1.12").build("build") {
assertSuccessful()
assertContains("kapt: Using class file stubs")
assertContains(":compileKotlin")
assertContains(":compileJava")
assertFileExists("build/tmp/kapt/main/wrappers/annotations.main.txt")
assertFileExists("build/generated/source/kapt/main/TestClassGenerated.java")
assertFileExists("build/classes/main/example/TestClass.class")
assertFileExists("build/classes/main/example/TestClassGenerated.class")
}
}
}
@@ -0,0 +1,35 @@
buildscript {
repositories {
mavenCentral()
maven {
url 'file://' + pathToKotlinPlugin
}
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:0.1-SNAPSHOT"
}
}
apply plugin: "java"
apply plugin: "kotlin"
repositories {
maven {
url 'file://' + pathToKotlinPlugin
}
mavenCentral()
}
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib:0.1-SNAPSHOT"
compile "org.jetbrains.kotlin:annotation-processor-example:0.1-SNAPSHOT"
kapt "org.jetbrains.kotlin:annotation-processor-example:0.1-SNAPSHOT"
}
task show << {
buildscript.configurations.classpath.each { println it }
}
task wrapper(type: Wrapper) {
gradleVersion="1.12"
}
@@ -0,0 +1,12 @@
package example
@example.ExampleAnnotation
public class TestClass {
@example.ExampleAnnotation
public val testVal: String = "text"
@example.ExampleAnnotation
public fun testFunction(): Int = 5
}
@@ -0,0 +1,39 @@
buildscript {
repositories {
mavenCentral()
maven {
url 'file://' + pathToKotlinPlugin
}
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:0.1-SNAPSHOT"
}
}
apply plugin: "java"
apply plugin: "kotlin"
repositories {
maven {
url 'file://' + pathToKotlinPlugin
}
mavenCentral()
}
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib:0.1-SNAPSHOT"
compile "org.jetbrains.kotlin:annotation-processor-example:0.1-SNAPSHOT"
kapt "org.jetbrains.kotlin:annotation-processor-example:0.1-SNAPSHOT"
}
task show << {
buildscript.configurations.classpath.each { println it }
}
task wrapper(type: Wrapper) {
gradleVersion="1.12"
}
kapt {
generateStubs = true
}
@@ -0,0 +1,12 @@
package example
@example.ExampleAnnotation
public class TestClass {
@example.ExampleAnnotation
public val testVal: String = "text"
@example.ExampleAnnotation
public fun testFunction(): Class<*> = javaClass<TestClassGenerated>()
}