Skip to content

Commit

Permalink
publish: configure gradle publishing artifact per workaround.
Browse files Browse the repository at this point in the history
  • Loading branch information
John Engelman committed Apr 26, 2021
1 parent b6f074e commit b145d9d
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
1 change: 1 addition & 0 deletions gradle/dependencies.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
30 changes: 29 additions & 1 deletion gradle/publish.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ artifactory {
repoKey = 'oss-snapshot-local'
}
defaults {
publications 'plugin'
publications 'pluginMaven'
}
}
}
Expand Down Expand Up @@ -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'
Expand Down

0 comments on commit b145d9d

Please sign in to comment.