From b145d9d7ec1b7cf2fcf0284cb988f225135a0f96 Mon Sep 17 00:00:00 2001 From: John Engelman Date: Mon, 26 Apr 2021 15:51:40 -0500 Subject: [PATCH] publish: configure gradle publishing artifact per workaround. --- gradle/dependencies.gradle | 1 + gradle/publish.gradle | 30 +++++++++++++++++++++++++++++- 2 files changed, 30 insertions(+), 1 deletion(-) diff --git a/gradle/dependencies.gradle b/gradle/dependencies.gradle index 6972d7308..98e132f77 100644 --- a/gradle/dependencies.gradle +++ b/gradle/dependencies.gradle @@ -4,6 +4,7 @@ dependencies { shadow gradleApi() shadow 'org.codehaus.groovy:groovy-backports-compat23:3.0.7' + implementation "com.gradle.publish:plugin-publish-plugin:0.14.0" implementation 'org.jdom:jdom2:2.0.6' implementation 'org.ow2.asm:asm:9.1' implementation 'org.ow2.asm:asm-commons:9.1' diff --git a/gradle/publish.gradle b/gradle/publish.gradle index 54e3027b2..438513ac5 100644 --- a/gradle/publish.gradle +++ b/gradle/publish.gradle @@ -56,7 +56,7 @@ artifactory { repoKey = 'oss-snapshot-local' } defaults { - publications 'plugin' + publications 'pluginMaven' } } } @@ -116,6 +116,34 @@ bintray { } } +// Workaround for configuring the artifact that publish-plugins uses: https://github.com/JLLeitschuh/ktlint-gradle/blob/master/plugin/build.gradle.kts +// Need to move publishing configuration into afterEvaluate {} +// to override changes done by "com.gradle.plugin-publish" plugin in afterEvaluate {} block +// See PublishPlugin class for details +afterEvaluate { + publishing { + publications { + withType(MavenPublication) { + // Special workaround to publish shadow jar instead of normal one. Name to override peeked here: + // https://github.com/gradle/gradle/blob/master/subprojects/plugin-development/src/main/java/org/gradle/plugin/devel/plugins/MavenPluginPublishPlugin.java#L73 + if (name == "pluginMaven") { + setArtifacts([ + tasks.shadowJar, + tasks.sourcesJar, + tasks.javadocJar + ]) + } + } + } + } +} + +tasks.whenTaskAdded { + if (name == "publishPluginJar" || name == "generateMetadataFileForPluginMavenPublication") { + dependsOn(tasks.named("shadowJar")) + } +} + pluginBundle { website = 'https://github.com/johnrengelman/shadow' vcsUrl = 'https://github.com/johnrengelman/shadow'