Fix inter-project IC for android->non-android dependency

#KT-24832 fixed
This commit is contained in:
Alexey Tsvetkov
2018-06-22 04:12:25 +03:00
parent 9071a70a44
commit 2065f8e6fe
19 changed files with 195 additions and 3 deletions
@@ -235,6 +235,32 @@ fun getSomething() = 10
}
}
@Test
fun testMultiModuleICNonAndroidModuleIsChanged() {
val project = Project("AndroidIncrementalMultiModule", gradleVersion)
val options = defaultBuildOptions().copy(incremental = true, kotlinDaemonDebugPort = null)
project.build("assembleDebug", options = options) {
assertSuccessful()
}
val libAndroidUtilKt = project.projectDir.getFileByName("libAndroidUtil.kt")
libAndroidUtilKt.modify { it.replace("fun libAndroidUtil(): String", "fun libAndroidUtil(): CharSequence") }
project.build("assembleDebug", options = options) {
assertSuccessful()
val affectedSources = project.projectDir.getFilesByNames("libAndroidUtil.kt", "useLibAndroidUtil.kt")
assertCompiledKotlinSources(project.relativize(affectedSources), weakTesting = false)
}
val libJvmUtilKt = project.projectDir.getFileByName("LibJvmUtil.kt")
libJvmUtilKt.modify { it.replace("fun libJvmUtil(): String", "fun libJvmUtil(): CharSequence") }
project.build("assembleDebug", options = options) {
assertSuccessful()
val affectedSources = project.projectDir.getFilesByNames("LibJvmUtil.kt", "useLibJvmUtil.kt")
assertCompiledKotlinSources(project.relativize(affectedSources), weakTesting = false)
}
}
@Test
fun testIncrementalBuildWithNoChanges() {
val project = Project("AndroidIncrementalSingleModuleProject", gradleVersion)
@@ -0,0 +1,23 @@
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
android {
compileSdkVersion 23
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.example"
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes.release.minifyEnabled = false
lintOptions.abortOnError = false
}
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
compile project(":libJvmClassesOnly")
compile project(":libAndroid")
}
@@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example" >
<application>
<activity android:name=".KotlinActivity"/>
</application>
</manifest>
@@ -0,0 +1,8 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the license/LICENSE.txt file.
*/
package com.example
class AppDummy
@@ -0,0 +1,10 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the license/LICENSE.txt file.
*/
package com.example
import android.app.Activity
open class KotlinActivity : Activity()
@@ -0,0 +1,9 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the license/LICENSE.txt file.
*/
package com.example
fun useLibAndroidUtil() =
libAndroidUtil()
@@ -0,0 +1,9 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the license/LICENSE.txt file.
*/
package com.example
fun useLibJvmUtil() =
LibJvmUtil.libJvmUtil()
@@ -0,0 +1,19 @@
buildscript {
repositories {
mavenLocal()
jcenter()
maven { url 'https://maven.google.com' }
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath('com.android.tools.build:gradle:' + android_tools_version)
}
}
allprojects {
repositories {
mavenLocal()
jcenter()
maven { url 'https://maven.google.com' }
}
}
@@ -0,0 +1,20 @@
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
android {
compileSdkVersion 23
buildToolsVersion "25.0.2"
defaultConfig {
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes.release.minifyEnabled = false
lintOptions.abortOnError = false
}
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
}
@@ -0,0 +1,3 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.lib" >
</manifest>
@@ -0,0 +1,8 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the license/LICENSE.txt file.
*/
package com.example
class LibAndroidDummy
@@ -0,0 +1,9 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the license/LICENSE.txt file.
*/
package com.example
fun libAndroidUtil(): String =
"Hello, World"
@@ -0,0 +1,5 @@
apply plugin: 'kotlin'
dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
}
@@ -0,0 +1,2 @@
Currently it is important that this project does not contain any package parts (classes only),
because kotlin_module is not generated in this case.
@@ -0,0 +1,8 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the license/LICENSE.txt file.
*/
package com.example
class LibJvmDummy
@@ -0,0 +1,13 @@
/*
* Copyright 2010-2018 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license
* that can be found in the license/LICENSE.txt file.
*/
package com.example
class LibJvmUtil {
companion object {
fun libJvmUtil(): String =
"Hello, World"
}
}
@@ -0,0 +1 @@
include ':app', ':libAndroid', ':libJvmClassesOnly'