Kapt: Map kaptGenerateStubsKotlin task classpath properly, ensure the destination for compileKotlin isn't in it (KT-18799)
This commit is contained in:
+19
@@ -223,6 +223,25 @@ open class Kapt3IT : Kapt3BaseIT() {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testKt18799() {
|
||||
val project = Project("kt18799", GRADLE_VERSION, directoryPrefix = "kapt2")
|
||||
|
||||
project.build("kaptKotlin") {
|
||||
assertSuccessful()
|
||||
}
|
||||
|
||||
project.projectDir.getFileByName("com.b.A.kt").modify {
|
||||
val line = "@Factory(factoryClass = CLASS_NAME, something = arrayOf(Test()))"
|
||||
assert(line in it)
|
||||
it.replace(line, "@Factory(factoryClass = CLASS_NAME)")
|
||||
}
|
||||
|
||||
project.build("kaptKotlin") {
|
||||
assertSuccessful()
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testKaptClassesDirSync() {
|
||||
val project = Project("autoService", GRADLE_VERSION, directoryPrefix = "kapt2")
|
||||
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
apply plugin: 'kotlin'
|
||||
apply plugin: 'kotlin-kapt'
|
||||
|
||||
dependencies {
|
||||
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
|
||||
|
||||
compile 'com.google.dagger:dagger:2.9'
|
||||
kapt 'com.google.dagger:dagger-compiler:2.9'
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
package com
|
||||
|
||||
const val CLASS_NAME = "com.test.Something"
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package com.b
|
||||
|
||||
import com.CLASS_NAME
|
||||
import com.lib.*
|
||||
|
||||
@Factory(factoryClass = CLASS_NAME, something = arrayOf(Test()))
|
||||
interface A
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
package com.lib
|
||||
|
||||
@Retention(AnnotationRetention.SOURCE)
|
||||
@kotlin.annotation.Target(AnnotationTarget.CLASS, AnnotationTarget.FILE)
|
||||
annotation class Factory(val factoryClass: String, val something: Array<Test> = arrayOf())
|
||||
|
||||
@Retention(AnnotationRetention.RUNTIME)
|
||||
@Target(AnnotationTarget.FUNCTION, AnnotationTarget.CLASS)
|
||||
annotation class Test
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
}
|
||||
dependencies {
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
}
|
||||
}
|
||||
|
||||
allprojects {
|
||||
repositories {
|
||||
jcenter()
|
||||
mavenLocal()
|
||||
}
|
||||
}
|
||||
|
||||
task clean(type: Delete) {
|
||||
delete rootProject.buildDir
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
include ':app'
|
||||
+1
@@ -26,6 +26,7 @@ import org.gradle.api.artifacts.Dependency
|
||||
import org.gradle.api.tasks.SourceSet
|
||||
import org.gradle.api.tasks.compile.AbstractCompile
|
||||
import org.gradle.api.tasks.compile.JavaCompile
|
||||
import org.jetbrains.kotlin.com.intellij.openapi.util.io.FileUtil
|
||||
import org.jetbrains.kotlin.gradle.plugin.*
|
||||
import org.jetbrains.kotlin.gradle.tasks.CompilerPluginOptions
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||
|
||||
+4
@@ -23,6 +23,8 @@ import org.jetbrains.kotlin.gradle.plugin.kotlinDebug
|
||||
import org.jetbrains.kotlin.gradle.tasks.FilteringSourceRootsContainer
|
||||
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
|
||||
import org.jetbrains.kotlin.incremental.ChangedFiles
|
||||
import org.jetbrains.kotlin.incremental.classpathAsList
|
||||
import org.jetbrains.kotlin.incremental.destinationAsFile
|
||||
import org.jetbrains.kotlin.incremental.pathsAsStringRelativeTo
|
||||
import java.io.File
|
||||
|
||||
@@ -67,6 +69,8 @@ open class KaptGenerateStubsTask : KotlinCompile() {
|
||||
args.pluginClasspaths = (pluginOptions.classpath + args.pluginClasspaths).toSet().toTypedArray()
|
||||
args.pluginOptions = (pluginOptions.arguments + args.pluginOptions).toTypedArray()
|
||||
args.verbose = project.hasProperty("kapt.verbose") && project.property("kapt.verbose").toString().toBoolean() == true
|
||||
args.classpathAsList = this.compileClasspath.toList()
|
||||
args.destinationAsFile = this.destinationDir
|
||||
|
||||
compilerCalled = true
|
||||
callCompiler(args, sourceRoots, ChangedFiles(inputs))
|
||||
|
||||
Reference in New Issue
Block a user