Stop removing JavaCompile tasks from project.tasks in common modules

When the JavaCompile tasks were removed from a common project, some of
the dependencies on them remained. This could lead to an error during
dependencies resolution, such as the one in KT-23092. To an even greater
confusion, the remaining dependencies anyway led to the task being
added to the task graph.

Issue #KT-23092 Fixed
This commit is contained in:
Sergey Igushkin
2018-03-29 20:11:18 +03:00
parent 2b41a0d30e
commit 1596d7b636
2 changed files with 20 additions and 2 deletions
@@ -236,4 +236,24 @@ class MultiplatformGradleIT : BaseGradleIT() {
assertFileExists(kotlinClassesDir(subproject = "lib") + "META-INF/$moduleName.kotlin_module")
}
}
@Test
fun testKt23092() = with(Project("multiplatformProject")) {
setupWorkingDir()
val successMarker = "Found JavaCompile task:"
gradleBuildScript("lib").appendText("\n" + """
afterEvaluate {
println('$successMarker ' + tasks.getByName('compileJava').path)
println('$successMarker ' + tasks.getByName('compileTestJava').path)
}
""".trimIndent()
)
build(":lib:tasks") {
assertSuccessful()
assertContains("$successMarker :lib:compileJava")
assertContains("$successMarker :lib:compileTestJava")
}
}
}
@@ -356,8 +356,6 @@ internal class KotlinCommonSourceSetProcessor(
project.tasks.findByName(sourceSet.classesTaskName)!!.dependsOn(kotlinTask)
// can be missing (e.g. in case of tests)
project.tasks.findByName(sourceSet.jarTaskName)?.dependsOn(kotlinTask)
val javaTask = project.tasks.findByName(sourceSet.compileJavaTaskName)
project.tasks.remove(javaTask)
appliedPlugins
.flatMap { it.getSubpluginKotlinTasks(project, kotlinTask) }