Skip to content

Commit b145d9d

Browse files
author
John Engelman
committed
publish: configure gradle publishing artifact per workaround.
1 parent b6f074e commit b145d9d

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

gradle/dependencies.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ dependencies {
44
shadow gradleApi()
55
shadow 'org.codehaus.groovy:groovy-backports-compat23:3.0.7'
66

7+
implementation "com.gradle.publish:plugin-publish-plugin:0.14.0"
78
implementation 'org.jdom:jdom2:2.0.6'
89
implementation 'org.ow2.asm:asm:9.1'
910
implementation 'org.ow2.asm:asm-commons:9.1'

gradle/publish.gradle

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ artifactory {
5656
repoKey = 'oss-snapshot-local'
5757
}
5858
defaults {
59-
publications 'plugin'
59+
publications 'pluginMaven'
6060
}
6161
}
6262
}
@@ -116,6 +116,34 @@ bintray {
116116
}
117117
}
118118

119+
// Workaround for configuring the artifact that publish-plugins uses: https://github.com/JLLeitschuh/ktlint-gradle/blob/master/plugin/build.gradle.kts
120+
// Need to move publishing configuration into afterEvaluate {}
121+
// to override changes done by "com.gradle.plugin-publish" plugin in afterEvaluate {} block
122+
// See PublishPlugin class for details
123+
afterEvaluate {
124+
publishing {
125+
publications {
126+
withType(MavenPublication) {
127+
// Special workaround to publish shadow jar instead of normal one. Name to override peeked here:
128+
// https://github.com/gradle/gradle/blob/master/subprojects/plugin-development/src/main/java/org/gradle/plugin/devel/plugins/MavenPluginPublishPlugin.java#L73
129+
if (name == "pluginMaven") {
130+
setArtifacts([
131+
tasks.shadowJar,
132+
tasks.sourcesJar,
133+
tasks.javadocJar
134+
])
135+
}
136+
}
137+
}
138+
}
139+
}
140+
141+
tasks.whenTaskAdded {
142+
if (name == "publishPluginJar" || name == "generateMetadataFileForPluginMavenPublication") {
143+
dependsOn(tasks.named("shadowJar"))
144+
}
145+
}
146+
119147
pluginBundle {
120148
website = 'https://github.com/johnrengelman/shadow'
121149
vcsUrl = 'https://github.com/johnrengelman/shadow'

0 commit comments

Comments
 (0)