[Gradle] Do not register compilation outputs in clean task
Calculations of compilation outputs implicitly requires compile task configuration to execute `clean` task. This implicit configuration works unstable in parallel builds. We probably fine with the fact that outputs that are configured to be outside of build directory will not be cleaned by `clean` task #KT-48046 Fixed
This commit is contained in:
committed by
Space
parent
f0aba5e892
commit
a0e6fb03f0
-31
@@ -1416,37 +1416,6 @@ class NewMultiplatformIT : BaseGradleIT() {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
fun testStaleOutputCleanup() = with(Project("new-mpp-lib-with-tests", gradleVersion)) {
|
||||
setupWorkingDir()
|
||||
// Check that output directories of Kotlin compilations are registered for Gradle stale outputs cleanup.
|
||||
// One way to check that is to run a Gradle build with no Gradle history (no .gradle directory) and see that the compilation
|
||||
// output directories are cleaned up, even those outside the project's buildDir
|
||||
|
||||
gradleBuildScript().appendText(
|
||||
"\n" + """
|
||||
kotlin.targets.js.compilations.main.output.classesDirs.from("foo") // should affect Gradle's behavior wrt stale output cleanup
|
||||
task('foo') {
|
||||
outputs.dir("foo")
|
||||
doFirst {
|
||||
println 'hello'
|
||||
file("foo/2.txt").text = System.currentTimeMillis()
|
||||
}
|
||||
}
|
||||
""".trimIndent()
|
||||
)
|
||||
|
||||
val staleFilePath = "foo/1.txt"
|
||||
projectDir.resolve(staleFilePath).run { parentFile.mkdirs(); createNewFile() }
|
||||
|
||||
build("foo") {
|
||||
assertSuccessful()
|
||||
assertNoSuchFile(staleFilePath)
|
||||
assertFileExists("foo/2.txt")
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testDefaultSourceSetsDsl() = with(Project("sample-lib", gradleVersion, "new-mpp-lib-and-app")) {
|
||||
setupWorkingDir()
|
||||
|
||||
-7
@@ -71,12 +71,6 @@ abstract class AbstractKotlinTargetConfigurator<KotlinTargetType : KotlinTarget>
|
||||
protected val createTestCompilation: Boolean
|
||||
) : KotlinTargetConfigurator<KotlinTargetType> {
|
||||
|
||||
private fun Project.registerOutputsForStaleOutputCleanup(kotlinCompilation: KotlinCompilation<*>) {
|
||||
tasks.withType<Delete>().named(LifecycleBasePlugin.CLEAN_TASK_NAME).configure { cleanTask ->
|
||||
cleanTask.delete(kotlinCompilation.output.allOutputs)
|
||||
}
|
||||
}
|
||||
|
||||
protected open fun setupCompilationDependencyFiles(compilation: KotlinCompilation<KotlinCommonOptions>) {
|
||||
val project = compilation.target.project
|
||||
|
||||
@@ -91,7 +85,6 @@ abstract class AbstractKotlinTargetConfigurator<KotlinTargetType : KotlinTarget>
|
||||
val main = target.compilations.create(KotlinCompilation.MAIN_COMPILATION_NAME)
|
||||
|
||||
target.compilations.all {
|
||||
project.registerOutputsForStaleOutputCleanup(it)
|
||||
setupCompilationDependencyFiles(it)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user