Do not force dependency resolution when configuring kapt with stabs
#KT-12776 fixed
This commit is contained in:
+1
-5
@@ -111,12 +111,8 @@ private fun Project.createKotlinAfterJavaTask(
|
|||||||
this
|
this
|
||||||
}
|
}
|
||||||
|
|
||||||
getAllTasks(false)
|
|
||||||
.flatMap { it.value }
|
|
||||||
.filter { javaTask in it.taskDependencies.getDependencies(it) }
|
|
||||||
.forEach { it.dependsOn(kotlinAfterJavaTask) }
|
|
||||||
|
|
||||||
kotlinAfterJavaTask.dependsOn(javaTask)
|
kotlinAfterJavaTask.dependsOn(javaTask)
|
||||||
|
javaTask.finalizedByIfNotFailed(kotlinAfterJavaTask)
|
||||||
|
|
||||||
kotlinAfterJavaTask.extensions.extraProperties.set("defaultModuleName", "${project.name}-${kotlinTask.name}")
|
kotlinAfterJavaTask.extensions.extraProperties.set("defaultModuleName", "${project.name}-${kotlinTask.name}")
|
||||||
if (kotlinOptions != null) {
|
if (kotlinOptions != null) {
|
||||||
|
|||||||
+2
-9
@@ -512,15 +512,8 @@ private fun createSyncOutputTask(
|
|||||||
kotlinAfterJavaTask?.javaOutputDir = javaDir
|
kotlinAfterJavaTask?.javaOutputDir = javaDir
|
||||||
|
|
||||||
// copying should be executed after a latter task
|
// copying should be executed after a latter task
|
||||||
if (kotlinAfterJavaTask != null) {
|
val previousTask = kotlinAfterJavaTask ?: javaTask
|
||||||
// finalizer tasks get executed even if finalizing task has failed;
|
previousTask.finalizedByIfNotFailed(syncTask)
|
||||||
// we want to avoid copying classes if kotlin compilation has failed
|
|
||||||
syncTask.onlyIf { kotlinAfterJavaTask.state.failure == null }
|
|
||||||
kotlinAfterJavaTask.finalizedBy(syncTask)
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
javaTask.finalizedBy(syncTask)
|
|
||||||
}
|
|
||||||
|
|
||||||
project.logger.kotlinDebug { "Created task ${syncTask.path} to copy kotlin classes from $kotlinDir to $javaDir" }
|
project.logger.kotlinDebug { "Created task ${syncTask.path} to copy kotlin classes from $kotlinDir to $javaDir" }
|
||||||
}
|
}
|
||||||
|
|||||||
+7
@@ -1,5 +1,6 @@
|
|||||||
package org.jetbrains.kotlin.gradle.plugin
|
package org.jetbrains.kotlin.gradle.plugin
|
||||||
|
|
||||||
|
import org.gradle.api.Task
|
||||||
import org.gradle.api.file.FileCollection
|
import org.gradle.api.file.FileCollection
|
||||||
import org.gradle.api.internal.AbstractTask
|
import org.gradle.api.internal.AbstractTask
|
||||||
import org.gradle.api.tasks.compile.AbstractCompile
|
import org.gradle.api.tasks.compile.AbstractCompile
|
||||||
@@ -51,6 +52,12 @@ internal fun AbstractCompile.appendClasspathDynamically(file: File) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Extends finalizedBy clause so that finalizing task does not run if finalized task failed
|
||||||
|
internal fun Task.finalizedByIfNotFailed(finalizer: Task) {
|
||||||
|
finalizer.onlyIf { this@finalizedByIfNotFailed.state.failure == null }
|
||||||
|
this.finalizedBy(finalizer)
|
||||||
|
}
|
||||||
|
|
||||||
internal var AbstractTask.anyClassesCompiled: Boolean? by TaskPropertyDelegate("anyClassesCompiled")
|
internal var AbstractTask.anyClassesCompiled: Boolean? by TaskPropertyDelegate("anyClassesCompiled")
|
||||||
internal var AbstractTask.friendTaskName: String? by TaskPropertyDelegate("friendTaskName")
|
internal var AbstractTask.friendTaskName: String? by TaskPropertyDelegate("friendTaskName")
|
||||||
internal var AbstractTask.javaOutputDir: File? by TaskPropertyDelegate("javaOutputDir")
|
internal var AbstractTask.javaOutputDir: File? by TaskPropertyDelegate("javaOutputDir")
|
||||||
|
|||||||
+10
@@ -161,4 +161,14 @@ fun getSomething() = 10
|
|||||||
assertSuccessful()
|
assertSuccessful()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
fun testAndroidKaptChangingDependencies() {
|
||||||
|
val project = Project("AndroidKaptChangingDependencies", gradleVersion)
|
||||||
|
|
||||||
|
project.build("build") {
|
||||||
|
assertSuccessful()
|
||||||
|
assertNotContains("Changed dependencies of configuration .+ after it has been included in dependency resolution".toRegex())
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
+4
@@ -146,6 +146,10 @@ abstract class BaseGradleIT {
|
|||||||
return this
|
return this
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun CompiledProject.assertNotContains(regex: Regex) {
|
||||||
|
assertNull(regex.find(output), "Output should not contain '$regex'")
|
||||||
|
}
|
||||||
|
|
||||||
fun CompiledProject.fileInWorkingDir(path: String) = File(File(workingDir, project.projectName), path)
|
fun CompiledProject.fileInWorkingDir(path: String) = File(File(workingDir, project.projectName), path)
|
||||||
|
|
||||||
fun CompiledProject.assertReportExists(pathToReport: String = ""): CompiledProject {
|
fun CompiledProject.assertReportExists(pathToReport: String = ""): CompiledProject {
|
||||||
|
|||||||
+32
@@ -0,0 +1,32 @@
|
|||||||
|
apply plugin: 'android-sdk-manager'
|
||||||
|
apply plugin: 'com.android.application'
|
||||||
|
apply plugin: 'kotlin-android'
|
||||||
|
|
||||||
|
android {
|
||||||
|
compileSdkVersion 23
|
||||||
|
buildToolsVersion "23.0.1"
|
||||||
|
|
||||||
|
defaultConfig {
|
||||||
|
applicationId "com.example.kapt"
|
||||||
|
minSdkVersion 19
|
||||||
|
targetSdkVersion 23
|
||||||
|
versionCode 1
|
||||||
|
versionName "1.0"
|
||||||
|
}
|
||||||
|
sourceSets {
|
||||||
|
main.java.srcDirs += 'src/main/kotlin'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
compile project(':lib-b')
|
||||||
|
kapt "com.squareup.dagger:dagger-compiler:$dagger_version"
|
||||||
|
}
|
||||||
|
|
||||||
|
kapt {
|
||||||
|
generateStubs = true
|
||||||
|
}
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
mavenCentral()
|
||||||
|
}
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.kapt">
|
||||||
|
<application />
|
||||||
|
</manifest>
|
||||||
+22
@@ -0,0 +1,22 @@
|
|||||||
|
buildscript {
|
||||||
|
ext.kotlin_version = '1.1-SNAPSHOT'
|
||||||
|
ext.support_lib_version = '23.1.1'
|
||||||
|
ext.dagger_version = '1.2.5'
|
||||||
|
|
||||||
|
repositories {
|
||||||
|
maven { url 'file://' + pathToKotlinPlugin }
|
||||||
|
jcenter()
|
||||||
|
}
|
||||||
|
dependencies {
|
||||||
|
classpath "com.android.tools.build:gradle:$androidToolsVersion"
|
||||||
|
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||||
|
classpath "com.jakewharton.sdkmanager:gradle-plugin:0.12.+"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
allprojects {
|
||||||
|
repositories {
|
||||||
|
maven { url 'file://' + pathToKotlinPlugin }
|
||||||
|
jcenter()
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
org.gradle.jvmargs=-ea -XX:MaxPermSize=512m
|
||||||
+24
@@ -0,0 +1,24 @@
|
|||||||
|
apply plugin: 'android-sdk-manager'
|
||||||
|
apply plugin: 'com.android.library'
|
||||||
|
apply plugin: 'kotlin-android'
|
||||||
|
|
||||||
|
android {
|
||||||
|
compileSdkVersion 23
|
||||||
|
buildToolsVersion "23.0.1"
|
||||||
|
|
||||||
|
defaultConfig {
|
||||||
|
minSdkVersion 19
|
||||||
|
targetSdkVersion 23
|
||||||
|
versionCode 1
|
||||||
|
versionName "1.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
compile "com.android.support:appcompat-v7:$support_lib_version"
|
||||||
|
kapt "com.squareup.dagger:dagger-compiler:$dagger_version"
|
||||||
|
}
|
||||||
|
|
||||||
|
kapt {
|
||||||
|
generateStubs = true
|
||||||
|
}
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
<manifest package="com.example.liba">
|
||||||
|
<application />
|
||||||
|
</manifest>
|
||||||
+24
@@ -0,0 +1,24 @@
|
|||||||
|
apply plugin: 'android-sdk-manager'
|
||||||
|
apply plugin: 'com.android.library'
|
||||||
|
apply plugin: 'kotlin-android'
|
||||||
|
|
||||||
|
android {
|
||||||
|
compileSdkVersion 23
|
||||||
|
buildToolsVersion "23.0.1"
|
||||||
|
|
||||||
|
defaultConfig {
|
||||||
|
minSdkVersion 19
|
||||||
|
targetSdkVersion 23
|
||||||
|
versionCode 1
|
||||||
|
versionName "1.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
compile project(':lib-a')
|
||||||
|
kapt "com.squareup.dagger:dagger-compiler:$dagger_version"
|
||||||
|
}
|
||||||
|
|
||||||
|
kapt {
|
||||||
|
generateStubs = true
|
||||||
|
}
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
<manifest package="com.example.libb">
|
||||||
|
<application />
|
||||||
|
</manifest>
|
||||||
+1
@@ -0,0 +1 @@
|
|||||||
|
include ':app', ':lib-a', ':lib-b'
|
||||||
Reference in New Issue
Block a user