diff --git a/buildSrc/src/main/kotlin/GradleCommon.kt b/buildSrc/src/main/kotlin/GradleCommon.kt index b9db1eb649b..b9f9a6f7d65 100644 --- a/buildSrc/src/main/kotlin/GradleCommon.kt +++ b/buildSrc/src/main/kotlin/GradleCommon.kt @@ -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 diff --git a/buildSrc/src/main/kotlin/embeddable.kt b/buildSrc/src/main/kotlin/embeddable.kt index c3384b46efa..a309df08ca3 100644 --- a/buildSrc/src/main/kotlin/embeddable.kt +++ b/buildSrc/src/main/kotlin/embeddable.kt @@ -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()