Build: Workaround deadlock in Gradle

Sometimes Gradle hangs during relocation of compiler plugins because
`compilerDummyJar` configuration is resolved inside ShadowJar's exclude
https://github.com/gradle/gradle/issues/24317
This commit is contained in:
Vyacheslav Gerasimov
2023-03-16 17:54:09 +01:00
parent 3dcac61f7c
commit 5996b41443
2 changed files with 13 additions and 5 deletions
+7 -3
View File
@@ -361,7 +361,8 @@ fun Project.reconfigureMainSourcesSetForGradlePlugin(
if (attributes.keySet() != expectedAttributes) {
error("Wrong set of attributes:\n" +
" Expected: ${expectedAttributes.joinToString(", ")}\n" +
" Actual: ${attributes.keySet().joinToString(", ") { "${it.name}=${attributes.getAttribute(it)}" }}")
" Actual: ${attributes.keySet().joinToString(", ") { "${it.name}=${attributes.getAttribute(it)}" }}"
)
}
javaComponent.addVariantsFromConfiguration(this) {
@@ -523,8 +524,11 @@ fun Project.publishShadowedJar(
// When Gradle traverses the inputs, reject the shaded compiler JAR,
// which leads to the content of that JAR being excluded as well:
val compilerDummyJarConfiguration: FileCollection = project.configurations.getByName("compilerDummyJar")
exclude { it.file == compilerDummyJarConfiguration.singleFile }
exclude {
// Docstring says `file` never returns null, but it does
@Suppress("UNNECESSARY_SAFE_CALL", "SAFE_CALL_WILL_CHANGE_NULLABILITY")
it.file?.name?.startsWith("kotlin-compiler-embeddable") ?: false
}
}
// Removing artifact produced by Jar task
+6 -2
View File
@@ -10,6 +10,7 @@ import org.gradle.api.file.DuplicatesStrategy
import org.gradle.api.file.FileCollection
import org.gradle.api.tasks.TaskProvider
import org.gradle.jvm.tasks.Jar
import org.gradle.kotlin.dsl.exclude
import org.gradle.kotlin.dsl.named
import org.gradle.kotlin.dsl.project
import org.gradle.kotlin.dsl.register
@@ -155,8 +156,11 @@ fun Project.rewriteDepsToShadedJar(
// When Gradle traverses the inputs, reject the shaded compiler JAR,
// which leads to the content of that JAR being excluded as well:
val compilerDummyJarConfiguration: FileCollection = project.configurations.getByName("compilerDummyJar")
exclude { it.file == compilerDummyJarConfiguration.singleFile }
exclude {
// Docstring says `file` never returns null, but it does
@Suppress("UNNECESSARY_SAFE_CALL", "SAFE_CALL_WILL_CHANGE_NULLABILITY")
it.file?.name?.startsWith("kotlin-compiler-embeddable") ?: false
}
archiveClassifier.set("original")
body()