Kapt3: Add friend paths to kapt tasks
This commit is contained in:
committed by
Yan Zhulanow
parent
75a8088f65
commit
e4de840b8a
+25
-25
@@ -20,13 +20,13 @@ import org.jetbrains.kotlin.gradle.util.*
|
|||||||
import org.junit.Test
|
import org.junit.Test
|
||||||
import java.io.File
|
import java.io.File
|
||||||
|
|
||||||
class Kapt2IT: BaseGradleIT() {
|
class Kapt3IT : BaseGradleIT() {
|
||||||
companion object {
|
companion object {
|
||||||
private const val GRADLE_VERSION = "2.10"
|
private const val GRADLE_VERSION = "2.10"
|
||||||
private const val GRADLE_2_14_VERSION = "2.14.1"
|
private const val GRADLE_2_14_VERSION = "2.14.1"
|
||||||
private const val ANDROID_GRADLE_PLUGIN_VERSION = "1.5.+"
|
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 val KAPT_SUCCESSFUL_REGEX = "Annotation processing complete, errors: 0".toRegex()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun androidBuildOptions() =
|
private fun androidBuildOptions() =
|
||||||
@@ -51,7 +51,7 @@ class Kapt2IT: BaseGradleIT() {
|
|||||||
assertKaptSuccessful()
|
assertKaptSuccessful()
|
||||||
assertContains(":compileKotlin")
|
assertContains(":compileKotlin")
|
||||||
assertContains(":compileJava")
|
assertContains(":compileJava")
|
||||||
assertFileExists("build/generated/source/kapt2/main/example/TestClassGenerated.java")
|
assertFileExists("build/generated/source/kapt/main/example/TestClassGenerated.java")
|
||||||
assertFileExists("build/classes/main/example/TestClass.class")
|
assertFileExists("build/classes/main/example/TestClass.class")
|
||||||
assertFileExists("build/classes/main/example/TestClassGenerated.class")
|
assertFileExists("build/classes/main/example/TestClassGenerated.class")
|
||||||
assertFileExists("build/classes/main/example/SourceAnnotatedTestClassGenerated.class")
|
assertFileExists("build/classes/main/example/SourceAnnotatedTestClassGenerated.class")
|
||||||
@@ -106,7 +106,7 @@ class Kapt2IT: BaseGradleIT() {
|
|||||||
Project("arguments", GRADLE_VERSION, directoryPrefix = "kapt2").build("build") {
|
Project("arguments", GRADLE_VERSION, directoryPrefix = "kapt2").build("build") {
|
||||||
assertSuccessful()
|
assertSuccessful()
|
||||||
assertKaptSuccessful()
|
assertKaptSuccessful()
|
||||||
assertFileExists("build/generated/source/kapt2/main/example/TestClassCustomized.java")
|
assertFileExists("build/generated/source/kapt/main/example/TestClassCustomized.java")
|
||||||
assertFileExists("build/classes/main/example/TestClass.class")
|
assertFileExists("build/classes/main/example/TestClass.class")
|
||||||
assertFileExists("build/classes/main/example/TestClassCustomized.class")
|
assertFileExists("build/classes/main/example/TestClassCustomized.class")
|
||||||
}
|
}
|
||||||
@@ -117,8 +117,8 @@ class Kapt2IT: BaseGradleIT() {
|
|||||||
Project("inheritedAnnotations", GRADLE_VERSION, directoryPrefix = "kapt2").build("build") {
|
Project("inheritedAnnotations", GRADLE_VERSION, directoryPrefix = "kapt2").build("build") {
|
||||||
assertSuccessful()
|
assertSuccessful()
|
||||||
assertKaptSuccessful()
|
assertKaptSuccessful()
|
||||||
assertFileExists("build/generated/source/kapt2/main/example/TestClassGenerated.java")
|
assertFileExists("build/generated/source/kapt/main/example/TestClassGenerated.java")
|
||||||
assertFileExists("build/generated/source/kapt2/main/example/AncestorClassGenerated.java")
|
assertFileExists("build/generated/source/kapt/main/example/AncestorClassGenerated.java")
|
||||||
assertFileExists("build/classes/main/example/TestClassGenerated.class")
|
assertFileExists("build/classes/main/example/TestClassGenerated.class")
|
||||||
assertFileExists("build/classes/main/example/AncestorClassGenerated.class")
|
assertFileExists("build/classes/main/example/AncestorClassGenerated.class")
|
||||||
}
|
}
|
||||||
@@ -132,7 +132,7 @@ class Kapt2IT: BaseGradleIT() {
|
|||||||
project.build("compileReleaseSources", options = options) {
|
project.build("compileReleaseSources", options = options) {
|
||||||
assertSuccessful()
|
assertSuccessful()
|
||||||
assertKaptSuccessful()
|
assertKaptSuccessful()
|
||||||
assertFileExists("app/build/generated/source/kapt2/release/org/example/kotlin/butterknife/SimpleActivity\$\$ViewBinder.java")
|
assertFileExists("app/build/generated/source/kapt/release/org/example/kotlin/butterknife/SimpleActivity\$\$ViewBinder.java")
|
||||||
assertFileExists("app/build/intermediates/classes/release/org/example/kotlin/butterknife/SimpleActivity\$\$ViewBinder.class")
|
assertFileExists("app/build/intermediates/classes/release/org/example/kotlin/butterknife/SimpleActivity\$\$ViewBinder.class")
|
||||||
assertFileExists("app/build/intermediates/classes/release/org/example/kotlin/butterknife/SimpleAdapter\$ViewHolder.class")
|
assertFileExists("app/build/intermediates/classes/release/org/example/kotlin/butterknife/SimpleAdapter\$ViewHolder.class")
|
||||||
}
|
}
|
||||||
@@ -152,8 +152,8 @@ class Kapt2IT: BaseGradleIT() {
|
|||||||
project.build("compileReleaseSources", options = options) {
|
project.build("compileReleaseSources", options = options) {
|
||||||
assertSuccessful()
|
assertSuccessful()
|
||||||
assertKaptSuccessful()
|
assertKaptSuccessful()
|
||||||
assertFileExists("app/build/generated/source/kapt2/release/com/example/dagger/kotlin/DaggerApplicationComponent.java")
|
assertFileExists("app/build/generated/source/kapt/release/com/example/dagger/kotlin/DaggerApplicationComponent.java")
|
||||||
assertFileExists("app/build/generated/source/kapt2/release/com/example/dagger/kotlin/ui/HomeActivity_MembersInjector.java")
|
assertFileExists("app/build/generated/source/kapt/release/com/example/dagger/kotlin/ui/HomeActivity_MembersInjector.java")
|
||||||
assertFileExists("app/build/intermediates/classes/release/com/example/dagger/kotlin/DaggerApplicationComponent.class")
|
assertFileExists("app/build/intermediates/classes/release/com/example/dagger/kotlin/DaggerApplicationComponent.class")
|
||||||
assertFileExists("app/build/intermediates/classes/release/com/example/dagger/kotlin/AndroidModule.class")
|
assertFileExists("app/build/intermediates/classes/release/com/example/dagger/kotlin/AndroidModule.class")
|
||||||
}
|
}
|
||||||
@@ -167,10 +167,10 @@ class Kapt2IT: BaseGradleIT() {
|
|||||||
project.build("compileReleaseSources", options = options) {
|
project.build("compileReleaseSources", options = options) {
|
||||||
assertSuccessful()
|
assertSuccessful()
|
||||||
assertKaptSuccessful()
|
assertKaptSuccessful()
|
||||||
assertFileExists("app/build/generated/source/kapt2/release/com/raizlabs/android/dbflow/config/GeneratedDatabaseHolder.java")
|
assertFileExists("app/build/generated/source/kapt/release/com/raizlabs/android/dbflow/config/GeneratedDatabaseHolder.java")
|
||||||
assertFileExists("app/build/generated/source/kapt2/release/com/raizlabs/android/dbflow/config/AppDatabaseapp_Database.java")
|
assertFileExists("app/build/generated/source/kapt/release/com/raizlabs/android/dbflow/config/AppDatabaseapp_Database.java")
|
||||||
assertFileExists("app/build/generated/source/kapt2/release/mobi/porquenao/poc/kotlin/core/Item_Table.java")
|
assertFileExists("app/build/generated/source/kapt/release/mobi/porquenao/poc/kotlin/core/Item_Table.java")
|
||||||
assertFileExists("app/build/generated/source/kapt2/release/mobi/porquenao/poc/kotlin/core/Item_Adapter.java")
|
assertFileExists("app/build/generated/source/kapt/release/mobi/porquenao/poc/kotlin/core/Item_Adapter.java")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -182,10 +182,10 @@ class Kapt2IT: BaseGradleIT() {
|
|||||||
project.build("compileReleaseSources", options = options) {
|
project.build("compileReleaseSources", options = options) {
|
||||||
assertSuccessful()
|
assertSuccessful()
|
||||||
assertKaptSuccessful()
|
assertKaptSuccessful()
|
||||||
assertFileExists("build/generated/source/kapt2/release/io/realm/CatRealmProxy.java")
|
assertFileExists("build/generated/source/kapt/release/io/realm/CatRealmProxy.java")
|
||||||
assertFileExists("build/generated/source/kapt2/release/io/realm/CatRealmProxyInterface.java")
|
assertFileExists("build/generated/source/kapt/release/io/realm/CatRealmProxyInterface.java")
|
||||||
assertFileExists("build/generated/source/kapt2/release/io/realm/DefaultRealmModule.java")
|
assertFileExists("build/generated/source/kapt/release/io/realm/DefaultRealmModule.java")
|
||||||
assertFileExists("build/generated/source/kapt2/release/io/realm/DefaultRealmModuleMediator.java")
|
assertFileExists("build/generated/source/kapt/release/io/realm/DefaultRealmModuleMediator.java")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -200,10 +200,10 @@ class Kapt2IT: BaseGradleIT() {
|
|||||||
assertContains(":compileJava")
|
assertContains(":compileJava")
|
||||||
assertFileExists("build/classes/main/example/TestClass.class")
|
assertFileExists("build/classes/main/example/TestClass.class")
|
||||||
|
|
||||||
assertFileExists("build/generated/source/kapt2/main/example/TestClassGenerated.java")
|
assertFileExists("build/generated/source/kapt/main/example/TestClassGenerated.java")
|
||||||
assertFileExists("build/generated/source/kapt2/main/example/SourceAnnotatedTestClassGenerated.java")
|
assertFileExists("build/generated/source/kapt/main/example/SourceAnnotatedTestClassGenerated.java")
|
||||||
assertFileExists("build/generated/source/kapt2/main/example/BinaryAnnotatedTestClassGenerated.java")
|
assertFileExists("build/generated/source/kapt/main/example/BinaryAnnotatedTestClassGenerated.java")
|
||||||
assertFileExists("build/generated/source/kapt2/main/example/RuntimeAnnotatedTestClassGenerated.java")
|
assertFileExists("build/generated/source/kapt/main/example/RuntimeAnnotatedTestClassGenerated.java")
|
||||||
|
|
||||||
assertFileExists("build/classes/main/example/TestClassGenerated.class")
|
assertFileExists("build/classes/main/example/TestClassGenerated.class")
|
||||||
assertFileExists("build/classes/main/example/SourceAnnotatedTestClassGenerated.class")
|
assertFileExists("build/classes/main/example/SourceAnnotatedTestClassGenerated.class")
|
||||||
@@ -220,10 +220,10 @@ class Kapt2IT: BaseGradleIT() {
|
|||||||
assertContains(":compileJava")
|
assertContains(":compileJava")
|
||||||
assertFileExists("build/classes/main/example/TestClass.class")
|
assertFileExists("build/classes/main/example/TestClass.class")
|
||||||
|
|
||||||
assertFileExists("build/generated/source/kapt2/main/example/TestClassGenerated.java")
|
assertFileExists("build/generated/source/kapt/main/example/TestClassGenerated.java")
|
||||||
assertFileExists("build/generated/source/kapt2/main/example/SourceAnnotatedTestClassGenerated.java")
|
assertFileExists("build/generated/source/kapt/main/example/SourceAnnotatedTestClassGenerated.java")
|
||||||
/*!*/ assertNoSuchFile("build/generated/source/kapt2/main/example/BinaryAnnotatedTestClassGenerated.java")
|
/*!*/ assertNoSuchFile("build/generated/source/kapt/main/example/BinaryAnnotatedTestClassGenerated.java")
|
||||||
assertFileExists("build/generated/source/kapt2/main/example/RuntimeAnnotatedTestClassGenerated.java")
|
assertFileExists("build/generated/source/kapt/main/example/RuntimeAnnotatedTestClassGenerated.java")
|
||||||
|
|
||||||
assertFileExists("build/classes/main/example/TestClassGenerated.class")
|
assertFileExists("build/classes/main/example/TestClassGenerated.class")
|
||||||
assertFileExists("build/classes/main/example/SourceAnnotatedTestClassGenerated.class")
|
assertFileExists("build/classes/main/example/SourceAnnotatedTestClassGenerated.class")
|
||||||
+1
@@ -55,6 +55,7 @@ open class KaptTask : AbstractCompile() {
|
|||||||
args.moduleName = kotlinCompileTask.moduleName
|
args.moduleName = kotlinCompileTask.moduleName
|
||||||
args.pluginClasspaths = pluginOptions.classpath.toTypedArray()
|
args.pluginClasspaths = pluginOptions.classpath.toTypedArray()
|
||||||
args.pluginOptions = pluginOptions.arguments.toTypedArray()
|
args.pluginOptions = pluginOptions.arguments.toTypedArray()
|
||||||
|
kotlinCompileTask.friendTaskName?.let { kotlinCompileTask.addFriendPathForTestTask(it, args) }
|
||||||
kotlinCompileTask.parentKotlinOptionsImpl?.updateArguments(args)
|
kotlinCompileTask.parentKotlinOptionsImpl?.updateArguments(args)
|
||||||
KotlinJvmOptionsImpl().updateArguments(args)
|
KotlinJvmOptionsImpl().updateArguments(args)
|
||||||
|
|
||||||
|
|||||||
+1
-7
@@ -159,13 +159,7 @@ open class KotlinCompile : AbstractKotlinCompile<K2JVMCompilerArguments>(), Kotl
|
|||||||
args.loadBuiltInsFromDependencies = true
|
args.loadBuiltInsFromDependencies = true
|
||||||
}
|
}
|
||||||
|
|
||||||
friendTaskName?.let addFriendPathForTestTask@ { friendKotlinTaskName ->
|
friendTaskName?.let { addFriendPathForTestTask(it, args) }
|
||||||
val friendTask = project.getTasksByName(friendKotlinTaskName, /* recursive = */false).firstOrNull() as? KotlinCompile ?: return@addFriendPathForTestTask
|
|
||||||
args.friendPaths = arrayOf(friendTask.javaOutputDir!!.absolutePath)
|
|
||||||
args.moduleName = friendTask.moduleName
|
|
||||||
logger.kotlinDebug("java destination directory for production = ${friendTask.javaOutputDir}")
|
|
||||||
}
|
|
||||||
|
|
||||||
parentKotlinOptionsImpl?.updateArguments(args)
|
parentKotlinOptionsImpl?.updateArguments(args)
|
||||||
kotlinOptionsImpl.updateArguments(args)
|
kotlinOptionsImpl.updateArguments(args)
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user