Fix inter-project IC for android->non-android dependency
#KT-24832 fixed
This commit is contained in:
+9
@@ -110,6 +110,15 @@ open class ModulesApiHistoryJvm(protected val modulesInfo: IncrementalModuleInfo
|
||||
}
|
||||
|
||||
class ModulesApiHistoryAndroid(modulesInfo: IncrementalModuleInfo) : ModulesApiHistoryJvm(modulesInfo) {
|
||||
private val delegate = ModulesApiHistoryJvm(modulesInfo)
|
||||
|
||||
override fun historyFilesForChangedFiles(changedFiles: Set<File>): Either<Set<File>> {
|
||||
val historyFromDelegate = delegate.historyFilesForChangedFiles(changedFiles)
|
||||
if (historyFromDelegate is Either.Success<Set<File>>) return historyFromDelegate
|
||||
|
||||
return super.historyFilesForChangedFiles(changedFiles)
|
||||
}
|
||||
|
||||
override fun getBuildHistoryFilesForJar(jar: File): Either<Set<File>> {
|
||||
// Module detection is expensive, so we don't don it for jars outside of project dir
|
||||
if (!projectRootPath.isParentOf(jar)) return Either.Error("Non-project jar is modified $jar")
|
||||
|
||||
+7
-3
@@ -24,8 +24,10 @@ class ModulesApiHistoryAndroidTest {
|
||||
val tmpFolder = TemporaryFolder()
|
||||
|
||||
private lateinit var appRoot: File
|
||||
private lateinit var appKotlinDestination: File
|
||||
private lateinit var appHistory: File
|
||||
private lateinit var libRoot: File
|
||||
private lateinit var libKotlinDestination: File
|
||||
private lateinit var libHistory: File
|
||||
|
||||
private lateinit var androidHistory: ModulesApiHistoryAndroid
|
||||
@@ -36,23 +38,25 @@ class ModulesApiHistoryAndroidTest {
|
||||
|
||||
appRoot = projectRoot.resolve("app")
|
||||
appHistory = appRoot.resolve("build/tmp/kotlin/app_history.bin")
|
||||
appKotlinDestination = appRoot.resolve("build/tmp/kotlin-classes").apply { mkdirs() }
|
||||
val appEntry = IncrementalModuleEntry(":app", "app", appRoot.resolve("build"), appHistory)
|
||||
appRoot.resolve("build/intermediates/classes/meta-inf/").apply {
|
||||
mkdirs();
|
||||
mkdirs()
|
||||
resolve("app.kotlin_module").createNewFile()
|
||||
}
|
||||
|
||||
libRoot = projectRoot.resolve("lib")
|
||||
libHistory = libRoot.resolve("lib/build/tmp/kotlin/lib_history.bin")
|
||||
libKotlinDestination = libRoot.resolve("build/tmp/kotlin-classes").apply { mkdirs() }
|
||||
val libEntry = IncrementalModuleEntry(":lib", "lib", libRoot.resolve("build"), libHistory)
|
||||
libRoot.resolve("build/intermediates/classes/meta-inf/").apply {
|
||||
mkdirs();
|
||||
mkdirs()
|
||||
resolve("lib.kotlin_module").createNewFile()
|
||||
}
|
||||
|
||||
val info = IncrementalModuleInfo(
|
||||
projectRoot = projectRoot,
|
||||
dirToModule = mapOf(appRoot to appEntry, libRoot to libEntry),
|
||||
dirToModule = mapOf(appKotlinDestination to appEntry, libKotlinDestination to libEntry),
|
||||
nameToModules = mapOf("app" to setOf(appEntry), "lib" to setOf(libEntry)),
|
||||
jarToClassListFile = mapOf()
|
||||
)
|
||||
|
||||
+26
@@ -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)
|
||||
|
||||
+23
@@ -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")
|
||||
}
|
||||
+6
@@ -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>
|
||||
+8
@@ -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
|
||||
+10
@@ -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()
|
||||
+9
@@ -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()
|
||||
+9
@@ -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()
|
||||
+19
@@ -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' }
|
||||
}
|
||||
}
|
||||
+20
@@ -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"
|
||||
}
|
||||
+3
@@ -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>
|
||||
+8
@@ -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
|
||||
+9
@@ -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"
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
apply plugin: 'kotlin'
|
||||
|
||||
dependencies {
|
||||
compile "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
|
||||
}
|
||||
+2
@@ -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.
|
||||
+8
@@ -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
|
||||
+13
@@ -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"
|
||||
}
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
include ':app', ':libAndroid', ':libJvmClassesOnly'
|
||||
Reference in New Issue
Block a user