Kapt: Remove obsolete kapt1-related tests
This commit is contained in:
-23
@@ -286,18 +286,6 @@ fun getSomething() = 10
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
fun testKaptKt15814() {
|
|
||||||
val project = Project("kaptKt15814", gradleVersion)
|
|
||||||
project.allowOriginalKapt()
|
|
||||||
|
|
||||||
val options = defaultBuildOptions().copy(incremental = false)
|
|
||||||
|
|
||||||
project.build("assembleDebug", "test", options = options) {
|
|
||||||
assertSuccessful()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testAndroidIcepickProject() {
|
fun testAndroidIcepickProject() {
|
||||||
val project = Project("AndroidIcepickProject", gradleVersion)
|
val project = Project("AndroidIcepickProject", gradleVersion)
|
||||||
@@ -354,17 +342,6 @@ fun getSomething() = 10
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
|
||||||
fun testAndroidKaptChangingDependencies() {
|
|
||||||
val project = Project("AndroidKaptChangingDependencies", gradleVersion)
|
|
||||||
project.allowOriginalKapt()
|
|
||||||
|
|
||||||
project.build("assembleDebug") {
|
|
||||||
assertSuccessful()
|
|
||||||
assertNotContains("Changed dependencies of configuration .+ after it has been included in dependency resolution".toRegex())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testMultiplatformAndroidCompile() = with(Project("multiplatformAndroidProject", gradleVersion)) {
|
fun testMultiplatformAndroidCompile() = with(Project("multiplatformAndroidProject", gradleVersion)) {
|
||||||
setupWorkingDir()
|
setupWorkingDir()
|
||||||
|
|||||||
-15
@@ -30,21 +30,6 @@ abstract class BaseGradleIT {
|
|||||||
workingDir.deleteRecursively()
|
workingDir.deleteRecursively()
|
||||||
}
|
}
|
||||||
|
|
||||||
fun Project.allowOriginalKapt() {
|
|
||||||
if (!projectDir.exists()) {
|
|
||||||
setupWorkingDir()
|
|
||||||
}
|
|
||||||
|
|
||||||
val allowOriginalKaptOption = "allow.original.kapt = true"
|
|
||||||
|
|
||||||
val gradleProperties = File(projectDir, "gradle.properties")
|
|
||||||
if (gradleProperties.exists()) {
|
|
||||||
gradleProperties.appendText("\n$allowOriginalKaptOption")
|
|
||||||
} else {
|
|
||||||
gradleProperties.writeText(allowOriginalKaptOption)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// https://developer.android.com/studio/intro/update.html#download-with-gradle
|
// https://developer.android.com/studio/intro/update.html#download-with-gradle
|
||||||
fun acceptAndroidSdkLicenses() = defaultBuildOptions().androidHome?.let {
|
fun acceptAndroidSdkLicenses() = defaultBuildOptions().androidHome?.let {
|
||||||
val sdkLicenses = File(it, "licenses")
|
val sdkLicenses = File(it, "licenses")
|
||||||
|
|||||||
-228
@@ -1,228 +0,0 @@
|
|||||||
package org.jetbrains.kotlin.gradle
|
|
||||||
|
|
||||||
import org.jetbrains.kotlin.gradle.util.allJavaFiles
|
|
||||||
import org.jetbrains.kotlin.gradle.util.getFileByName
|
|
||||||
import org.jetbrains.kotlin.gradle.util.modify
|
|
||||||
import org.junit.Test
|
|
||||||
import java.io.File
|
|
||||||
|
|
||||||
class KaptIT : BaseGradleIT() {
|
|
||||||
|
|
||||||
@Test
|
|
||||||
fun testSimple() {
|
|
||||||
val project = Project("kaptSimple")
|
|
||||||
project.allowOriginalKapt()
|
|
||||||
|
|
||||||
project.build("build") {
|
|
||||||
assertSuccessful()
|
|
||||||
assertContains("kapt: Class file stubs are not used")
|
|
||||||
assertTasksExecuted(":compileKotlin", ":compileJava")
|
|
||||||
assertFileExists("build/tmp/kapt/main/wrappers/annotations.main.txt")
|
|
||||||
assertFileExists("build/generated/source/kapt/main/example/TestClassGenerated.java")
|
|
||||||
assertFileExists(kotlinClassesDir() + "example/TestClass.class")
|
|
||||||
assertFileExists(javaClassesDir() + "example/TestClassGenerated.class")
|
|
||||||
assertNoSuchFile(javaClassesDir() + "example/SourceAnnotatedTestClassGenerated.class")
|
|
||||||
assertFileExists(javaClassesDir() + "example/BinaryAnnotatedTestClassGenerated.class")
|
|
||||||
assertFileExists(javaClassesDir() + "example/RuntimeAnnotatedTestClassGenerated.class")
|
|
||||||
assertContains("example.JavaTest PASSED")
|
|
||||||
assertContains("example.KotlinTest PASSED")
|
|
||||||
assertClassFilesNotContain(File(project.projectDir, kotlinClassesDir()), "ExampleSourceAnnotation")
|
|
||||||
assertClassFilesNotContain(File(project.projectDir, javaClassesDir()), "ExampleSourceAnnotation")
|
|
||||||
}
|
|
||||||
|
|
||||||
// clean build is important
|
|
||||||
// because clean can delete hack annotation file before build
|
|
||||||
project.build("clean", "build") {
|
|
||||||
assertSuccessful()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
fun testEnumConstructor() {
|
|
||||||
val project = Project("kaptEnumConstructor")
|
|
||||||
project.allowOriginalKapt()
|
|
||||||
|
|
||||||
project.build("build") {
|
|
||||||
assertSuccessful()
|
|
||||||
assertTasksExecuted(":compileKotlin", ":compileJava")
|
|
||||||
assertFileExists("build/tmp/kapt/main/wrappers/annotations.main.txt")
|
|
||||||
}
|
|
||||||
|
|
||||||
project.build("build") {
|
|
||||||
assertSuccessful()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
fun testStubs() {
|
|
||||||
val project = Project("kaptStubs", GradleVersionRequired.Exact("3.5"))
|
|
||||||
project.allowOriginalKapt()
|
|
||||||
|
|
||||||
project.build("build") {
|
|
||||||
assertSuccessful()
|
|
||||||
assertContains("kapt: Using class file stubs")
|
|
||||||
assertTasksExecuted(":compileKotlin", ":compileJava")
|
|
||||||
assertFileExists("build/tmp/kapt/main/wrappers/annotations.main.txt")
|
|
||||||
assertFileExists("build/generated/source/kapt/main/example/TestClassGenerated.java")
|
|
||||||
assertFileExists(kotlinClassesDir() + "example/TestClass.class")
|
|
||||||
assertFileExists(javaClassesDir() + "example/TestClassGenerated.class")
|
|
||||||
assertFileExists(javaClassesDir() + "example/SourceAnnotatedTestClassGenerated.class")
|
|
||||||
assertFileExists(javaClassesDir() + "example/BinaryAnnotatedTestClassGenerated.class")
|
|
||||||
assertFileExists(javaClassesDir() + "example/RuntimeAnnotatedTestClassGenerated.class")
|
|
||||||
assertNotContains("w: Classpath entry points to a non-existent location")
|
|
||||||
assertContains("example.JavaTest PASSED")
|
|
||||||
}
|
|
||||||
|
|
||||||
project.build("build") {
|
|
||||||
assertSuccessful()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
fun testStubsWithoutJava() {
|
|
||||||
val project = Project("kaptStubs", GradleVersionRequired.Exact("3.5"))
|
|
||||||
project.allowOriginalKapt()
|
|
||||||
project.projectDir.allJavaFiles().forEach { it.delete() }
|
|
||||||
|
|
||||||
project.build("build") {
|
|
||||||
assertSuccessful()
|
|
||||||
assertContains("kapt: Using class file stubs")
|
|
||||||
assertTasksExecuted(":compileKotlin", ":compileJava")
|
|
||||||
assertFileExists(kotlinClassesDir() + "example/TestClass.class")
|
|
||||||
assertFileExists(javaClassesDir() + "example/TestClassGenerated.class")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
fun testSimpleIncrementalBuild() {
|
|
||||||
doTestIncrementalBuild("kaptSimple", listOf(":compileKotlin", ":compileJava"))
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
fun testStubsIncrementalBuild() {
|
|
||||||
doTestIncrementalBuild("kaptStubs", listOf(":compileKotlin", ":compileJava", ":compileKotlinAfterJava"))
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun doTestIncrementalBuild(projectName: String, compileTasks: List<String>) {
|
|
||||||
val project = Project(projectName, GradleVersionRequired.Exact("3.5"))
|
|
||||||
project.allowOriginalKapt()
|
|
||||||
|
|
||||||
project.build("build") {
|
|
||||||
assertSuccessful()
|
|
||||||
}
|
|
||||||
|
|
||||||
project.projectDir.getFileByName("test.kt").appendText(" ")
|
|
||||||
project.build("build") {
|
|
||||||
assertSuccessful()
|
|
||||||
assertTasksExecuted(compileTasks)
|
|
||||||
}
|
|
||||||
|
|
||||||
repeat(2) {
|
|
||||||
project.build("build") {
|
|
||||||
assertSuccessful()
|
|
||||||
assertTasksUpToDate(compileTasks)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
project.build("clean", "build") {
|
|
||||||
assertSuccessful()
|
|
||||||
assertTasksExecuted(compileTasks)
|
|
||||||
}
|
|
||||||
|
|
||||||
repeat(2) {
|
|
||||||
project.build("build") {
|
|
||||||
assertSuccessful()
|
|
||||||
assertTasksUpToDate(compileTasks)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
fun testArguments() {
|
|
||||||
val project = Project("kaptArguments")
|
|
||||||
project.allowOriginalKapt()
|
|
||||||
|
|
||||||
project.build("build") {
|
|
||||||
assertSuccessful()
|
|
||||||
assertContains("kapt: Using class file stubs")
|
|
||||||
assertTasksExecuted(":compileKotlin", ":compileJava")
|
|
||||||
assertFileExists("build/tmp/kapt/main/wrappers/annotations.main.txt")
|
|
||||||
assertFileExists("build/generated/source/kapt/main/example/TestClassCustomized.java")
|
|
||||||
assertFileExists(kotlinClassesDir() + "example/TestClass.class")
|
|
||||||
assertFileExists(javaClassesDir() + "example/TestClassCustomized.class")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
fun testInheritedAnnotations() {
|
|
||||||
val project = Project("kaptInheritedAnnotations")
|
|
||||||
project.allowOriginalKapt()
|
|
||||||
|
|
||||||
project.build("build") {
|
|
||||||
assertSuccessful()
|
|
||||||
assertFileExists("build/generated/source/kapt/main/example/TestClassGenerated.java")
|
|
||||||
assertFileExists("build/generated/source/kapt/main/example/AncestorClassGenerated.java")
|
|
||||||
assertFileExists(javaClassesDir() + "example/TestClassGenerated.class")
|
|
||||||
assertFileExists(javaClassesDir() + "example/AncestorClassGenerated.class")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
fun testOutputKotlinCode() {
|
|
||||||
val project = Project("kaptOutputKotlinCode")
|
|
||||||
project.allowOriginalKapt()
|
|
||||||
|
|
||||||
project.build("build") {
|
|
||||||
assertSuccessful()
|
|
||||||
assertContains("kapt: Using class file stubs")
|
|
||||||
assertTasksExecuted(":compileKotlin", ":compileJava")
|
|
||||||
assertFileExists("build/tmp/kapt/main/wrappers/annotations.main.txt")
|
|
||||||
assertFileExists("build/generated/source/kapt/main/example/TestClassCustomized.java")
|
|
||||||
assertFileExists("build/tmp/kapt/main/kotlinGenerated/TestClass.kt")
|
|
||||||
assertFileExists(kotlinClassesDir() + "example/TestClass.class")
|
|
||||||
assertFileExists(javaClassesDir() + "example/TestClassCustomized.class")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
fun testInternalUserIsModifiedStubsIC() {
|
|
||||||
val options = defaultBuildOptions().copy(incremental = true)
|
|
||||||
|
|
||||||
val project = Project("kaptStubs", GradleVersionRequired.Exact("3.5"))
|
|
||||||
project.allowOriginalKapt()
|
|
||||||
|
|
||||||
project.build("build", options = options) {
|
|
||||||
assertSuccessful()
|
|
||||||
}
|
|
||||||
|
|
||||||
val internalDummyUserKt = project.projectDir.getFileByName("InternalDummyUser.kt")
|
|
||||||
internalDummyUserKt.modify { it + " " }
|
|
||||||
val internalDummyTestKt = project.projectDir.getFileByName("InternalDummyTest.kt")
|
|
||||||
internalDummyTestKt.modify { it + " " }
|
|
||||||
|
|
||||||
project.build("build", options = options) {
|
|
||||||
assertSuccessful()
|
|
||||||
assertCompiledKotlinSources(project.relativize(internalDummyUserKt, internalDummyTestKt))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
fun testKotlinCompilerNotCalledStubsIC() {
|
|
||||||
val options = defaultBuildOptions().copy(incremental = true)
|
|
||||||
|
|
||||||
val project = Project("kaptStubs", GradleVersionRequired.Exact("3.5"))
|
|
||||||
project.allowOriginalKapt()
|
|
||||||
|
|
||||||
project.build("build", options = options) {
|
|
||||||
assertSuccessful()
|
|
||||||
}
|
|
||||||
|
|
||||||
val javaDummy = project.projectDir.getFileByName("JavaDummy.java")
|
|
||||||
javaDummy.modify { it + " " }
|
|
||||||
|
|
||||||
project.build("build", options = options) {
|
|
||||||
assertSuccessful()
|
|
||||||
assertCompiledKotlinSources(emptyList())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+48
-115
@@ -6,10 +6,23 @@ import org.jetbrains.kotlin.gradle.util.getFileByName
|
|||||||
import org.jetbrains.kotlin.gradle.util.modify
|
import org.jetbrains.kotlin.gradle.util.modify
|
||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
|
|
||||||
class KaptIncrementalNoStubsIT : KaptIncrementalBaseIT(shouldUseStubs = false)
|
class KaptIncrementalIT : BaseGradleIT() {
|
||||||
class KaptIncrementalWithStubsIT : KaptIncrementalBaseIT(shouldUseStubs = true)
|
companion object {
|
||||||
|
private val EXAMPLE_ANNOTATION_REGEX = "@(field:)?example.ExampleAnnotation".toRegex()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun getProject() =
|
||||||
|
Project(
|
||||||
|
"kaptIncrementalCompilationProject",
|
||||||
|
GradleVersionRequired.None
|
||||||
|
).apply { setupWorkingDir() }
|
||||||
|
|
||||||
|
private val annotatedElements =
|
||||||
|
arrayOf("A", "funA", "valA", "funUtil", "valUtil", "B", "funB", "valB", "useB")
|
||||||
|
|
||||||
|
override fun defaultBuildOptions(): BuildOptions =
|
||||||
|
super.defaultBuildOptions().copy(incremental = true)
|
||||||
|
|
||||||
class Kapt3Incremental : KaptIncrementalBaseIT(shouldUseStubs = false, useKapt3 = true) {
|
|
||||||
@Test
|
@Test
|
||||||
fun testAddNewLine() {
|
fun testAddNewLine() {
|
||||||
val project = Project("simple", directoryPrefix = "kapt2")
|
val project = Project("simple", directoryPrefix = "kapt2")
|
||||||
@@ -32,47 +45,6 @@ class Kapt3Incremental : KaptIncrementalBaseIT(shouldUseStubs = false, useKapt3
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
abstract class KaptIncrementalBaseIT(val shouldUseStubs: Boolean, val useKapt3: Boolean = false) : BaseGradleIT() {
|
|
||||||
init {
|
|
||||||
if (useKapt3) {
|
|
||||||
assert(!shouldUseStubs)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
private val EXAMPLE_ANNOTATION_REGEX = "@(field:)?example.ExampleAnnotation".toRegex()
|
|
||||||
private const val GENERATE_STUBS_PLACEHOLDER = "GENERATE_STUBS_PLACEHOLDER"
|
|
||||||
|
|
||||||
private const val APPLY_KAPT3_PLUGIN_PLACEHOLDER = "// APPLY_KAPT_PLUGIN"
|
|
||||||
private const val APPLY_KAPT3_PLUGIN = "apply plugin: \"kotlin-kapt\""
|
|
||||||
}
|
|
||||||
|
|
||||||
protected open val projectName = "kaptIncrementalCompilationProject"
|
|
||||||
|
|
||||||
private fun getProject() =
|
|
||||||
Project(
|
|
||||||
projectName,
|
|
||||||
// When running with original kapt, use Gradle 3.5, because separate classes dirs (4.0+) are not supported
|
|
||||||
if (useKapt3) GradleVersionRequired.None else GradleVersionRequired.Exact("3.5")
|
|
||||||
).apply {
|
|
||||||
setupWorkingDir()
|
|
||||||
val buildGradle = projectDir.parentFile.getFileByName("build.gradle")
|
|
||||||
buildGradle.modify { it.replace(GENERATE_STUBS_PLACEHOLDER, shouldUseStubs.toString()) }
|
|
||||||
|
|
||||||
if (useKapt3) {
|
|
||||||
buildGradle.modify { it.replace(APPLY_KAPT3_PLUGIN_PLACEHOLDER, APPLY_KAPT3_PLUGIN) }
|
|
||||||
} else {
|
|
||||||
allowOriginalKapt()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private val annotatedElements =
|
|
||||||
arrayOf("A", "funA", "valA", "funUtil", "valUtil", "B", "funB", "valB", "useB")
|
|
||||||
|
|
||||||
override fun defaultBuildOptions(): BuildOptions =
|
|
||||||
super.defaultBuildOptions().copy(incremental = true)
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testBasic() {
|
fun testBasic() {
|
||||||
@@ -80,7 +52,6 @@ abstract class KaptIncrementalBaseIT(val shouldUseStubs: Boolean, val useKapt3:
|
|||||||
|
|
||||||
project.build("build") {
|
project.build("build") {
|
||||||
assertSuccessful()
|
assertSuccessful()
|
||||||
checkStubUsage()
|
|
||||||
checkGenerated(*annotatedElements)
|
checkGenerated(*annotatedElements)
|
||||||
checkNotGenerated("notAnnotatedFun")
|
checkNotGenerated("notAnnotatedFun")
|
||||||
assertContains("foo.ATest PASSED")
|
assertContains("foo.ATest PASSED")
|
||||||
@@ -93,16 +64,10 @@ abstract class KaptIncrementalBaseIT(val shouldUseStubs: Boolean, val useKapt3:
|
|||||||
":compileJava"
|
":compileJava"
|
||||||
)
|
)
|
||||||
|
|
||||||
if (useKapt3) {
|
assertTasksUpToDate(
|
||||||
assertTasksUpToDate(
|
":kaptKotlin",
|
||||||
":kaptKotlin",
|
":kaptGenerateStubsKotlin"
|
||||||
":kaptGenerateStubsKotlin"
|
)
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (shouldUseStubs) {
|
|
||||||
assertTasksUpToDate(":compileKotlinAfterJava")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -112,7 +77,6 @@ abstract class KaptIncrementalBaseIT(val shouldUseStubs: Boolean, val useKapt3:
|
|||||||
|
|
||||||
project.build("build") {
|
project.build("build") {
|
||||||
assertSuccessful()
|
assertSuccessful()
|
||||||
checkStubUsage()
|
|
||||||
checkGenerated(*annotatedElements)
|
checkGenerated(*annotatedElements)
|
||||||
checkNotGenerated("notAnnotatedFun")
|
checkNotGenerated("notAnnotatedFun")
|
||||||
assertContains("foo.ATest PASSED")
|
assertContains("foo.ATest PASSED")
|
||||||
@@ -126,12 +90,8 @@ abstract class KaptIncrementalBaseIT(val shouldUseStubs: Boolean, val useKapt3:
|
|||||||
|
|
||||||
project.build("build") {
|
project.build("build") {
|
||||||
assertSuccessful()
|
assertSuccessful()
|
||||||
checkStubUsage()
|
assertTasksExecuted(":kaptGenerateStubsKotlin")
|
||||||
|
assertTasksUpToDate(":kaptKotlin")
|
||||||
if (useKapt3) {
|
|
||||||
assertTasksExecuted(":kaptGenerateStubsKotlin")
|
|
||||||
assertTasksUpToDate(":kaptKotlin")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -188,14 +148,12 @@ abstract class KaptIncrementalBaseIT(val shouldUseStubs: Boolean, val useKapt3:
|
|||||||
assertSuccessful()
|
assertSuccessful()
|
||||||
assertKapt3FullyExecuted()
|
assertKapt3FullyExecuted()
|
||||||
|
|
||||||
if (useKapt3) {
|
assertFileExists("$kapt3IncDataPath/bar/B.class")
|
||||||
assertFileExists("$kapt3IncDataPath/bar/B.class")
|
assertFileExists("$kapt3IncDataPath/bar/UseBKt.class")
|
||||||
assertFileExists("$kapt3IncDataPath/bar/UseBKt.class")
|
assertFileExists("$kapt3StubsPath/bar/B.java")
|
||||||
assertFileExists("$kapt3StubsPath/bar/B.java")
|
assertFileExists("$kapt3StubsPath/bar/B.kapt_metadata")
|
||||||
assertFileExists("$kapt3StubsPath/bar/B.kapt_metadata")
|
assertFileExists("$kapt3StubsPath/bar/UseBKt.java")
|
||||||
assertFileExists("$kapt3StubsPath/bar/UseBKt.java")
|
assertFileExists("$kapt3StubsPath/bar/UseBKt.kapt_metadata")
|
||||||
assertFileExists("$kapt3StubsPath/bar/UseBKt.kapt_metadata")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
with(project.projectDir) {
|
with(project.projectDir) {
|
||||||
@@ -206,14 +164,12 @@ abstract class KaptIncrementalBaseIT(val shouldUseStubs: Boolean, val useKapt3:
|
|||||||
project.build("build") {
|
project.build("build") {
|
||||||
assertFailed()
|
assertFailed()
|
||||||
|
|
||||||
if (useKapt3) {
|
assertNoSuchFile("$kapt3IncDataPath/bar/B.class")
|
||||||
assertNoSuchFile("$kapt3IncDataPath/bar/B.class")
|
assertNoSuchFile("$kapt3IncDataPath/bar/UseBKt.class")
|
||||||
assertNoSuchFile("$kapt3IncDataPath/bar/UseBKt.class")
|
assertNoSuchFile("$kapt3StubsPath/bar/B.java")
|
||||||
assertNoSuchFile("$kapt3StubsPath/bar/B.java")
|
assertNoSuchFile("$kapt3StubsPath/bar/B.kaptMetadata")
|
||||||
assertNoSuchFile("$kapt3StubsPath/bar/B.kaptMetadata")
|
assertNoSuchFile("$kapt3StubsPath/bar/UseBKt.java")
|
||||||
assertNoSuchFile("$kapt3StubsPath/bar/UseBKt.java")
|
assertNoSuchFile("$kapt3StubsPath/bar/UseBKt.kaptMetadata")
|
||||||
assertNoSuchFile("$kapt3StubsPath/bar/UseBKt.kaptMetadata")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
project.projectDir.getFileByName("JavaClass.java").delete()
|
project.projectDir.getFileByName("JavaClass.java").delete()
|
||||||
@@ -242,24 +198,17 @@ abstract class KaptIncrementalBaseIT(val shouldUseStubs: Boolean, val useKapt3:
|
|||||||
project.build("build") {
|
project.build("build") {
|
||||||
assertSuccessful()
|
assertSuccessful()
|
||||||
|
|
||||||
if (useKapt3) {
|
assertKapt3FullyExecuted()
|
||||||
assertKapt3FullyExecuted()
|
|
||||||
|
|
||||||
val useBKt = project.projectDir.getFileByName("useB.kt")
|
val useBKt = project.projectDir.getFileByName("useB.kt")
|
||||||
assertCompiledKotlinSources(project.relativize(bKt, useBKt), tasks = listOf("kaptGenerateStubsKotlin"))
|
assertCompiledKotlinSources(project.relativize(bKt, useBKt), tasks = listOf("kaptGenerateStubsKotlin"))
|
||||||
|
|
||||||
|
// java removal is detected
|
||||||
|
assertCompiledKotlinSources(
|
||||||
|
project.relativize(project.projectDir.allKotlinFiles()),
|
||||||
|
tasks = listOf("compileKotlin")
|
||||||
|
)
|
||||||
|
|
||||||
// java removal is detected
|
|
||||||
assertCompiledKotlinSources(
|
|
||||||
project.relativize(project.projectDir.allKotlinFiles()),
|
|
||||||
tasks = listOf("compileKotlin")
|
|
||||||
)
|
|
||||||
} else if (shouldUseStubs) {
|
|
||||||
// java removal is detected
|
|
||||||
assertCompiledKotlinSources(project.relativize(project.projectDir.allKotlinFiles()))
|
|
||||||
} else {
|
|
||||||
val useBKt = project.projectDir.getFileByName("useB.kt")
|
|
||||||
assertCompiledKotlinSources(project.relativize(bKt, useBKt))
|
|
||||||
}
|
|
||||||
checkGenerated(*(annotatedElements.toSet() - affectedElements).toTypedArray())
|
checkGenerated(*(annotatedElements.toSet() - affectedElements).toTypedArray())
|
||||||
checkNotGenerated(*affectedElements)
|
checkNotGenerated(*affectedElements)
|
||||||
}
|
}
|
||||||
@@ -288,20 +237,14 @@ abstract class KaptIncrementalBaseIT(val shouldUseStubs: Boolean, val useKapt3:
|
|||||||
sources: Iterable<String>,
|
sources: Iterable<String>,
|
||||||
weakTesting: Boolean = false
|
weakTesting: Boolean = false
|
||||||
) {
|
) {
|
||||||
if (useKapt3) {
|
assertCompiledKotlinSources(
|
||||||
assertCompiledKotlinSources(
|
sources, weakTesting,
|
||||||
sources, weakTesting,
|
tasks = listOf("compileKotlin", "kaptGenerateStubsKotlin")
|
||||||
tasks = listOf("compileKotlin", "kaptGenerateStubsKotlin")
|
)
|
||||||
)
|
|
||||||
} else {
|
|
||||||
assertCompiledKotlinSources(sources, weakTesting)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun CompiledProject.assertKapt3FullyExecuted() {
|
private fun CompiledProject.assertKapt3FullyExecuted() {
|
||||||
if (useKapt3) {
|
assertTasksExecuted(":kaptKotlin", ":kaptGenerateStubsKotlin")
|
||||||
assertTasksExecuted(":kaptKotlin", ":kaptGenerateStubsKotlin")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun CompiledProject.checkGenerated(vararg annotatedElementNames: String) {
|
private fun CompiledProject.checkGenerated(vararg annotatedElementNames: String) {
|
||||||
@@ -322,14 +265,4 @@ abstract class KaptIncrementalBaseIT(val shouldUseStubs: Boolean, val useKapt3:
|
|||||||
val names = annotatedElementNames.map { it.capitalize() + "Generated" }
|
val names = annotatedElementNames.map { it.capitalize() + "Generated" }
|
||||||
return names.map { it + ".java" }
|
return names.map { it + ".java" }
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun CompiledProject.checkStubUsage() {
|
|
||||||
val usingStubs = "kapt: Using class file stubs"
|
|
||||||
|
|
||||||
if (shouldUseStubs) {
|
|
||||||
assertContains(usingStubs)
|
|
||||||
} else {
|
|
||||||
assertNotContains(usingStubs)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
-13
@@ -8,19 +8,6 @@ import java.io.File
|
|||||||
import java.util.zip.ZipFile
|
import java.util.zip.ZipFile
|
||||||
|
|
||||||
class KotlinGradlePluginMultiVersionIT : BaseMultiGradleVersionIT() {
|
class KotlinGradlePluginMultiVersionIT : BaseMultiGradleVersionIT() {
|
||||||
@Test
|
|
||||||
fun testKaptProcessorPath() {
|
|
||||||
val project = Project("kaptSimple", gradleVersion)
|
|
||||||
project.allowOriginalKapt()
|
|
||||||
|
|
||||||
project.build("build") {
|
|
||||||
assertSuccessful()
|
|
||||||
assertContainsRegex("""-processorpath \S*.build.tmp.kapt.main.wrappers""".toRegex())
|
|
||||||
assertFileExists("build/generated/source/kapt/main/example/TestClassGenerated.java")
|
|
||||||
assertClassFilesNotContain(File(project.projectDir, "build/classes"), "ExampleSourceAnnotation")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
fun testKt19179() {
|
fun testKt19179() {
|
||||||
val project = Project("kt19179", gradleVersion, directoryPrefix = "kapt2")
|
val project = Project("kt19179", gradleVersion, directoryPrefix = "kapt2")
|
||||||
|
|||||||
-30
@@ -1,30 +0,0 @@
|
|||||||
buildscript {
|
|
||||||
repositories {
|
|
||||||
mavenLocal()
|
|
||||||
mavenCentral()
|
|
||||||
}
|
|
||||||
dependencies {
|
|
||||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
apply plugin: "java"
|
|
||||||
apply plugin: "kotlin"
|
|
||||||
|
|
||||||
repositories {
|
|
||||||
mavenLocal()
|
|
||||||
mavenCentral()
|
|
||||||
}
|
|
||||||
|
|
||||||
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 {
|
|
||||||
generateStubs = true
|
|
||||||
arguments {
|
|
||||||
arg("suffix", "Customized")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-12
@@ -1,12 +0,0 @@
|
|||||||
package example
|
|
||||||
|
|
||||||
@example.ExampleAnnotation
|
|
||||||
public class TestClass {
|
|
||||||
|
|
||||||
@example.ExampleAnnotation
|
|
||||||
public val testVal: String = "text"
|
|
||||||
|
|
||||||
@example.ExampleAnnotation
|
|
||||||
public fun testFunction(): Class<*> = TestClassCustomized::class.java
|
|
||||||
|
|
||||||
}
|
|
||||||
-27
@@ -1,27 +0,0 @@
|
|||||||
buildscript {
|
|
||||||
repositories {
|
|
||||||
mavenLocal()
|
|
||||||
jcenter()
|
|
||||||
}
|
|
||||||
dependencies {
|
|
||||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
apply plugin: "java"
|
|
||||||
apply plugin: "kotlin"
|
|
||||||
|
|
||||||
repositories {
|
|
||||||
mavenLocal()
|
|
||||||
jcenter()
|
|
||||||
}
|
|
||||||
|
|
||||||
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 {
|
|
||||||
generateStubs = true
|
|
||||||
}
|
|
||||||
-25
@@ -1,25 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2015 JetBrains s.r.o.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package javaPackage;
|
|
||||||
|
|
||||||
import example.TestEnum;
|
|
||||||
|
|
||||||
public class JavaClass {
|
|
||||||
public void test() {
|
|
||||||
TestEnum t = TestEnum.ENTRY;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-7
@@ -1,7 +0,0 @@
|
|||||||
// See KT-12694 Java class cannot access (Kotlin) enum with String constructor param
|
|
||||||
|
|
||||||
package example
|
|
||||||
|
|
||||||
enum class TestEnum(val value: String) {
|
|
||||||
ENTRY("");
|
|
||||||
}
|
|
||||||
+1
-5
@@ -10,7 +10,7 @@ buildscript {
|
|||||||
|
|
||||||
apply plugin: "java"
|
apply plugin: "java"
|
||||||
apply plugin: "kotlin"
|
apply plugin: "kotlin"
|
||||||
// APPLY_KAPT_PLUGIN
|
apply plugin: "kotlin-kapt"
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
jcenter()
|
jcenter()
|
||||||
@@ -23,7 +23,3 @@ dependencies {
|
|||||||
kapt "org.jetbrains.kotlin:annotation-processor-example:$kotlin_version"
|
kapt "org.jetbrains.kotlin:annotation-processor-example:$kotlin_version"
|
||||||
testCompile 'junit:junit:4.12'
|
testCompile 'junit:junit:4.12'
|
||||||
}
|
}
|
||||||
|
|
||||||
kapt {
|
|
||||||
generateStubs = GENERATE_STUBS_PLACEHOLDER
|
|
||||||
}
|
|
||||||
-23
@@ -1,23 +0,0 @@
|
|||||||
buildscript {
|
|
||||||
repositories {
|
|
||||||
mavenLocal()
|
|
||||||
jcenter()
|
|
||||||
}
|
|
||||||
dependencies {
|
|
||||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
apply plugin: "java"
|
|
||||||
apply plugin: "kotlin"
|
|
||||||
|
|
||||||
repositories {
|
|
||||||
mavenLocal()
|
|
||||||
jcenter()
|
|
||||||
}
|
|
||||||
|
|
||||||
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"
|
|
||||||
}
|
|
||||||
-22
@@ -1,22 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2015 JetBrains s.r.o.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package example
|
|
||||||
|
|
||||||
@example.ExampleAnnotation
|
|
||||||
public open class TestClass
|
|
||||||
|
|
||||||
public class AncestorClass : TestClass()
|
|
||||||
-41
@@ -1,41 +0,0 @@
|
|||||||
apply plugin: 'com.android.application'
|
|
||||||
apply plugin: 'kotlin-android'
|
|
||||||
|
|
||||||
android {
|
|
||||||
compileSdkVersion 23
|
|
||||||
buildToolsVersion "25.0.2"
|
|
||||||
defaultConfig {
|
|
||||||
applicationId "com.example.genclassesnotfound"
|
|
||||||
minSdkVersion 19
|
|
||||||
targetSdkVersion 23
|
|
||||||
versionCode 1
|
|
||||||
versionName "1.0"
|
|
||||||
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
|
|
||||||
}
|
|
||||||
buildTypes {
|
|
||||||
release {
|
|
||||||
minifyEnabled false
|
|
||||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
sourceSets {
|
|
||||||
main.java.srcDirs += 'src/main/kotlin'
|
|
||||||
test.java.srcDirs += 'src/test/kotlin'
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
compile fileTree(dir: 'libs', include: ['*.jar'])
|
|
||||||
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
|
|
||||||
exclude group: 'com.android.support', module: 'support-annotations'
|
|
||||||
})
|
|
||||||
testCompile 'junit:junit:4.12'
|
|
||||||
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
|
||||||
kaptTest "com.squareup.dagger:dagger-compiler:$dagger_version"
|
|
||||||
compile "com.squareup.dagger:dagger:$dagger_version"
|
|
||||||
}
|
|
||||||
|
|
||||||
repositories {
|
|
||||||
mavenLocal()
|
|
||||||
mavenCentral()
|
|
||||||
}
|
|
||||||
-25
@@ -1,25 +0,0 @@
|
|||||||
# Add project specific ProGuard rules here.
|
|
||||||
# By default, the flags in this file are appended to flags specified
|
|
||||||
# in /Users/knjohn/.android-sdk/tools/proguard/proguard-android.txt
|
|
||||||
# You can edit the include path and order by changing the proguardFiles
|
|
||||||
# directive in build.gradle.
|
|
||||||
#
|
|
||||||
# For more details, see
|
|
||||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
|
||||||
|
|
||||||
# Add any project specific keep options here:
|
|
||||||
|
|
||||||
# If your project uses WebView with JS, uncomment the following
|
|
||||||
# and specify the fully qualified class name to the JavaScript interface
|
|
||||||
# class:
|
|
||||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
|
||||||
# public *;
|
|
||||||
#}
|
|
||||||
|
|
||||||
# Uncomment this to preserve the line number information for
|
|
||||||
# debugging stack traces.
|
|
||||||
#-keepattributes SourceFile,LineNumberTable
|
|
||||||
|
|
||||||
# If you keep the line number information, uncomment this to
|
|
||||||
# hide the original source file name.
|
|
||||||
#-renamesourcefileattribute SourceFile
|
|
||||||
-15
@@ -1,15 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
package="com.example.genclassesnotfound">
|
|
||||||
|
|
||||||
<application
|
|
||||||
android:allowBackup="true"
|
|
||||||
android:label="@string/app_name">
|
|
||||||
<activity android:name=".MainActivity">
|
|
||||||
<intent-filter>
|
|
||||||
<action android:name="android.intent.action.MAIN"/>
|
|
||||||
<category android:name="android.intent.category.LAUNCHER"/>
|
|
||||||
</intent-filter>
|
|
||||||
</activity>
|
|
||||||
</application>
|
|
||||||
</manifest>
|
|
||||||
-13
@@ -1,13 +0,0 @@
|
|||||||
package com.example.genclassesnotfound;
|
|
||||||
|
|
||||||
import android.app.Activity;
|
|
||||||
import android.os.Bundle;
|
|
||||||
|
|
||||||
public class MainActivity extends Activity {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onCreate(Bundle savedInstanceState) {
|
|
||||||
super.onCreate(savedInstanceState);
|
|
||||||
setContentView(R.layout.activity_main);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-12
@@ -1,12 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<LinearLayout
|
|
||||||
xmlns:android="http://schemas.android.com/apk/res/android"
|
|
||||||
android:id="@+id/activity_main"
|
|
||||||
android:layout_width="match_parent"
|
|
||||||
android:layout_height="match_parent">
|
|
||||||
|
|
||||||
<TextView
|
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"/>
|
|
||||||
|
|
||||||
</LinearLayout>
|
|
||||||
-3
@@ -1,3 +0,0 @@
|
|||||||
<resources>
|
|
||||||
<string name="app_name">GenClassesNotFound</string>
|
|
||||||
</resources>
|
|
||||||
-40
@@ -1,40 +0,0 @@
|
|||||||
package com.example.genclassesnotfound
|
|
||||||
|
|
||||||
import dagger.Module
|
|
||||||
import dagger.ObjectGraph
|
|
||||||
import dagger.Provides
|
|
||||||
import org.junit.Assert.assertEquals
|
|
||||||
import org.junit.Before
|
|
||||||
import org.junit.Test
|
|
||||||
import javax.inject.Inject
|
|
||||||
|
|
||||||
class ExampleUnitTest {
|
|
||||||
|
|
||||||
lateinit var graph: ObjectGraph
|
|
||||||
lateinit @Inject var config: Config
|
|
||||||
|
|
||||||
@Before
|
|
||||||
fun setUp() {
|
|
||||||
graph = ObjectGraph.create(TestModule())
|
|
||||||
graph.inject(this)
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
fun addition_isCorrect() {
|
|
||||||
assertEquals(4 + config.magicNumber, 9)
|
|
||||||
}
|
|
||||||
|
|
||||||
@Module(
|
|
||||||
injects = arrayOf(ExampleUnitTest::class),
|
|
||||||
complete = true,
|
|
||||||
library = true
|
|
||||||
|
|
||||||
)
|
|
||||||
class TestModule {
|
|
||||||
@Provides fun providesDependency(): Config {
|
|
||||||
return Config(5)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
data class Config(val magicNumber : Int)
|
|
||||||
}
|
|
||||||
-26
@@ -1,26 +0,0 @@
|
|||||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
|
||||||
|
|
||||||
buildscript {
|
|
||||||
ext.dagger_version = '1.2.5'
|
|
||||||
repositories {
|
|
||||||
mavenLocal()
|
|
||||||
jcenter()
|
|
||||||
maven { url 'https://maven.google.com' }
|
|
||||||
}
|
|
||||||
dependencies {
|
|
||||||
classpath "com.android.tools.build:gradle:$android_tools_version"
|
|
||||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
allprojects {
|
|
||||||
repositories {
|
|
||||||
mavenLocal()
|
|
||||||
jcenter()
|
|
||||||
maven { url 'https://maven.google.com' }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
task clean(type: Delete) {
|
|
||||||
delete rootProject.buildDir
|
|
||||||
}
|
|
||||||
-1
@@ -1 +0,0 @@
|
|||||||
org.gradle.jvmargs=-ea -XX:MaxPermSize=512m
|
|
||||||
-1
@@ -1 +0,0 @@
|
|||||||
include ':app'
|
|
||||||
-31
@@ -1,31 +0,0 @@
|
|||||||
buildscript {
|
|
||||||
repositories {
|
|
||||||
mavenLocal()
|
|
||||||
jcenter()
|
|
||||||
}
|
|
||||||
dependencies {
|
|
||||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
apply plugin: "java"
|
|
||||||
apply plugin: "kotlin"
|
|
||||||
|
|
||||||
repositories {
|
|
||||||
mavenLocal()
|
|
||||||
jcenter()
|
|
||||||
}
|
|
||||||
|
|
||||||
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 {
|
|
||||||
generateStubs = true
|
|
||||||
arguments {
|
|
||||||
arg("suffix", "Customized")
|
|
||||||
arg("generate.kotlin.code", "true")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-10
@@ -1,10 +0,0 @@
|
|||||||
package example
|
|
||||||
|
|
||||||
@example.ExampleAnnotation
|
|
||||||
public class TestClass {
|
|
||||||
|
|
||||||
fun test() {
|
|
||||||
println(this.customToString())
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
-24
@@ -1,24 +0,0 @@
|
|||||||
buildscript {
|
|
||||||
repositories {
|
|
||||||
mavenLocal()
|
|
||||||
jcenter()
|
|
||||||
}
|
|
||||||
dependencies {
|
|
||||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
apply plugin: "java"
|
|
||||||
apply plugin: "kotlin"
|
|
||||||
|
|
||||||
repositories {
|
|
||||||
mavenLocal()
|
|
||||||
jcenter()
|
|
||||||
}
|
|
||||||
|
|
||||||
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"
|
|
||||||
testCompile 'junit:junit:4.12'
|
|
||||||
}
|
|
||||||
-27
@@ -1,27 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2015 JetBrains s.r.o.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package javaPackage;
|
|
||||||
|
|
||||||
public class JavaClass {
|
|
||||||
|
|
||||||
public void test() {
|
|
||||||
System.out.println(example.TestClassGenerated.class.getName());
|
|
||||||
System.out.println(example.BinaryAnnotatedTestClassGenerated.class.getName());
|
|
||||||
System.out.println(example.RuntimeAnnotatedTestClassGenerated.class.getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
-15
@@ -1,15 +0,0 @@
|
|||||||
package example
|
|
||||||
|
|
||||||
@example.ExampleAnnotation
|
|
||||||
@example.ExampleSourceAnnotation
|
|
||||||
@example.ExampleBinaryAnnotation
|
|
||||||
@example.ExampleRuntimeAnnotation
|
|
||||||
public class TestClass {
|
|
||||||
|
|
||||||
@example.ExampleAnnotation
|
|
||||||
public val testVal: String = "text"
|
|
||||||
|
|
||||||
@example.ExampleAnnotation
|
|
||||||
public fun testFunction(): Int = 5
|
|
||||||
|
|
||||||
}
|
|
||||||
-12
@@ -1,12 +0,0 @@
|
|||||||
package example;
|
|
||||||
|
|
||||||
import org.junit.Assert;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
public class JavaTest {
|
|
||||||
@Test
|
|
||||||
public void test() {
|
|
||||||
TestClass testClass = new TestClass();
|
|
||||||
Assert.assertEquals("text", testClass.getTestVal());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-12
@@ -1,12 +0,0 @@
|
|||||||
package example
|
|
||||||
|
|
||||||
import org.junit.Assert
|
|
||||||
import org.junit.Test
|
|
||||||
|
|
||||||
class KotlinTest {
|
|
||||||
@Test
|
|
||||||
fun test() {
|
|
||||||
val testClass = TestClass()
|
|
||||||
Assert.assertEquals("text", testClass.testVal)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-28
@@ -1,28 +0,0 @@
|
|||||||
buildscript {
|
|
||||||
repositories {
|
|
||||||
mavenLocal()
|
|
||||||
jcenter()
|
|
||||||
}
|
|
||||||
dependencies {
|
|
||||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
apply plugin: "java"
|
|
||||||
apply plugin: "kotlin"
|
|
||||||
|
|
||||||
repositories {
|
|
||||||
jcenter()
|
|
||||||
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"
|
|
||||||
testCompile 'junit:junit:4.12'
|
|
||||||
}
|
|
||||||
|
|
||||||
kapt {
|
|
||||||
generateStubs = true
|
|
||||||
}
|
|
||||||
-5
@@ -1,5 +0,0 @@
|
|||||||
package foo
|
|
||||||
|
|
||||||
internal class InternalDummy {
|
|
||||||
internal val x = "InternalDummy.x"
|
|
||||||
}
|
|
||||||
-7
@@ -1,7 +0,0 @@
|
|||||||
package foo
|
|
||||||
|
|
||||||
internal class InternalDummyUser {
|
|
||||||
internal fun use(dummy: InternalDummy) {
|
|
||||||
if (dummy.x != "InternalDummy.x") throw AssertionError("dummy.x = ${dummy.x}")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-28
@@ -1,28 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2015 JetBrains s.r.o.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package javaPackage;
|
|
||||||
|
|
||||||
public class JavaClass {
|
|
||||||
|
|
||||||
public void test() {
|
|
||||||
System.out.println(example.TestClassGenerated.class.getName());
|
|
||||||
System.out.println(example.SourceAnnotatedTestClassGenerated.class.getName());
|
|
||||||
System.out.println(example.BinaryAnnotatedTestClassGenerated.class.getName());
|
|
||||||
System.out.println(example.RuntimeAnnotatedTestClassGenerated.class.getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
-4
@@ -1,4 +0,0 @@
|
|||||||
package javaPackage;
|
|
||||||
|
|
||||||
public class JavaDummy {
|
|
||||||
}
|
|
||||||
-15
@@ -1,15 +0,0 @@
|
|||||||
package example
|
|
||||||
|
|
||||||
@example.ExampleAnnotation
|
|
||||||
@example.ExampleSourceAnnotation
|
|
||||||
@example.ExampleBinaryAnnotation
|
|
||||||
@example.ExampleRuntimeAnnotation
|
|
||||||
public class TestClass {
|
|
||||||
|
|
||||||
@example.ExampleAnnotation
|
|
||||||
public val testVal: String = "text"
|
|
||||||
|
|
||||||
@example.ExampleAnnotation
|
|
||||||
public fun testFunction(): TestClassGenerated = TestClassGenerated()
|
|
||||||
|
|
||||||
}
|
|
||||||
-12
@@ -1,12 +0,0 @@
|
|||||||
package example;
|
|
||||||
|
|
||||||
import org.junit.Assert;
|
|
||||||
import org.junit.Test;
|
|
||||||
|
|
||||||
public class JavaTest {
|
|
||||||
@Test
|
|
||||||
public void test() {
|
|
||||||
TestClass testClass = new TestClass();
|
|
||||||
Assert.assertEquals("text", testClass.getTestVal());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-12
@@ -1,12 +0,0 @@
|
|||||||
package foo
|
|
||||||
|
|
||||||
import org.junit.Test
|
|
||||||
|
|
||||||
class InternalDummyTest {
|
|
||||||
@Test
|
|
||||||
fun testDummy() {
|
|
||||||
val dummy = InternalDummy()
|
|
||||||
val dummyUser = InternalDummyUser()
|
|
||||||
dummyUser.use(dummy)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user