IC: add destination dir to start of classpath instead of end
Otherwise IC fails when a project declares a class with the same name as in one of its dependencies. The issue is relevant only for non-JPS IC (Gradle, Maven, etc.), but I added the test for JPS too. #KT-20516 fixed
This commit is contained in:
+3
-1
@@ -314,7 +314,9 @@ class IncrementalJvmCompilerRunner(
|
||||
override fun preBuildHook(args: K2JVMCompilerArguments, compilationMode: CompilationMode) {
|
||||
when (compilationMode) {
|
||||
is CompilationMode.Incremental -> {
|
||||
args.classpathAsList += args.destinationAsFile.apply { mkdirs() }
|
||||
val destinationDir = args.destinationAsFile
|
||||
destinationDir.mkdirs()
|
||||
args.classpathAsList = listOf(destinationDir) + args.classpathAsList
|
||||
}
|
||||
is CompilationMode.Rebuild -> {
|
||||
// there is no point in updating annotation file since all files will be compiled anyway
|
||||
|
||||
+6
@@ -117,6 +117,12 @@ public class IncrementalJpsTestGenerated extends AbstractIncrementalJpsTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("duplicatedClass")
|
||||
public void testDuplicatedClass() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/multiModule/duplicatedClass/");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("exportedDependency")
|
||||
public void testExportedDependency() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("jps-plugin/testData/incremental/multiModule/exportedDependency/");
|
||||
|
||||
@@ -0,0 +1,17 @@
|
||||
================ Step #1 =================
|
||||
|
||||
Building module1
|
||||
Exit code: NOTHING_DONE
|
||||
------------------------------------------
|
||||
Building module2
|
||||
Cleaning output files:
|
||||
out/production/module2/META-INF/module2.kotlin_module
|
||||
out/production/module2/UseAKt.class
|
||||
out/production/module2/UseUtilsKt.class
|
||||
End of files
|
||||
Compiling files:
|
||||
module2/src/useA.kt
|
||||
module2/src/useUtils.kt
|
||||
End of files
|
||||
Exit code: OK
|
||||
------------------------------------------
|
||||
@@ -0,0 +1,2 @@
|
||||
module1->
|
||||
module2->module1
|
||||
@@ -0,0 +1,3 @@
|
||||
class A {
|
||||
fun fizz() {}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fun other1() {
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
fun fizz() {}
|
||||
@@ -0,0 +1,3 @@
|
||||
class A {
|
||||
fun buzz() {}
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
fun other2() {
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fun useA() {
|
||||
A().buzz()
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun useUtils() {
|
||||
buzz()
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
fun buzz() {}
|
||||
+15
@@ -22,6 +22,21 @@ class IncrementalCompilationMultiProjectIT : BaseGradleIT() {
|
||||
override fun defaultBuildOptions(): BuildOptions =
|
||||
super.defaultBuildOptions().copy(withDaemon = true, incremental = true)
|
||||
|
||||
@Test
|
||||
fun testDuplicatedClass() {
|
||||
val project = Project("duplicatedClass")
|
||||
project.build("build") {
|
||||
assertSuccessful()
|
||||
}
|
||||
|
||||
val usagesFiles = listOf("useBuzz.kt", "useA.kt").map { project.projectFile(it) }
|
||||
usagesFiles.forEach { file -> file.modify { "$it\n " } }
|
||||
|
||||
project.build("build") {
|
||||
assertSuccessful()
|
||||
assertCompiledKotlinSources(project.relativize(usagesFiles))
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testMoveFunctionFromLib() {
|
||||
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
apply plugin: 'kotlin'
|
||||
|
||||
dependencies {
|
||||
compile project(':lib')
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
class A {
|
||||
fun buzz() {}
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun useA(a: A) {
|
||||
A().buzz()
|
||||
}
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
fun useBuzz() {
|
||||
buzz()
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
fun buzz() {}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
buildscript {
|
||||
repositories {
|
||||
mavenLocal()
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
|
||||
}
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
apply plugin: 'kotlin'
|
||||
+3
@@ -0,0 +1,3 @@
|
||||
class A {
|
||||
fun fizz() {}
|
||||
}
|
||||
+1
@@ -0,0 +1 @@
|
||||
fun fizz() {}
|
||||
+1
@@ -0,0 +1 @@
|
||||
include ':lib', ':app'
|
||||
+2
@@ -19,6 +19,8 @@ package org.jetbrains.kotlin.incremental
|
||||
import org.gradle.api.Project
|
||||
import java.io.File
|
||||
|
||||
// todo: Move all files under org.jetbrains.kotlin.gradle package to avoid class clash (KT-18621, KT-20516)
|
||||
|
||||
internal fun File.isJavaFile() =
|
||||
extension.equals("java", ignoreCase = true)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user