From 8b17a42866ace3a82f258beb97b536d8cdecaeac Mon Sep 17 00:00:00 2001 From: Yahor Berdnikau Date: Tue, 24 May 2022 14:32:23 +0200 Subject: [PATCH] Fix main Gradle plugins variants were published unshadowed The problem comes from "com.gradle.plugin-publish" plugin. It asks to run 'jar' task even if this tasks outputs are removed from artifacts. As 'jar' and shadow 'embeddedJar' tasks outputs has the same name and 'jar' task runs after shadow one - this leads to jar file overwrite. And eventually publishing unshadowed artifact. --- .../kotlin/gradle-plugin-common-configuration.gradle.kts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/buildSrc/src/main/kotlin/gradle-plugin-common-configuration.gradle.kts b/buildSrc/src/main/kotlin/gradle-plugin-common-configuration.gradle.kts index 3251c120ae1..874532d5718 100644 --- a/buildSrc/src/main/kotlin/gradle-plugin-common-configuration.gradle.kts +++ b/buildSrc/src/main/kotlin/gradle-plugin-common-configuration.gradle.kts @@ -46,6 +46,14 @@ tasks { val commonSourceSet = createGradleCommonSourceSet() reconfigureMainSourcesSetForGradlePlugin(commonSourceSet) publishShadowedJar(sourceSets[SourceSet.MAIN_SOURCE_SET_NAME], commonSourceSet) + +// Disabling this task, so "com.gradle.plugin-publish" will not publish unshadowed jar into Gradle Plugin Portal +// Without it 'jar' task is asked to run by "com.gradle.plugin-publish" even if artifacts are removed. The problem +// is that 'jar' task runs after shadow task plus their outputs has the same name leading to '.jar' file overwrite. +tasks.named("jar") { + enabled = false +} + if (!kotlinBuildProperties.isInJpsBuildIdeaSync) { // Used for Gradle 7.0+ versions val gradle70SourceSet = createGradlePluginVariant(