Skip to content

Commit

Permalink
Fix publishing for post-bintray.
Browse files Browse the repository at this point in the history
  • Loading branch information
nedtwigg committed Apr 9, 2021
1 parent e05b77f commit 1d521aa
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 45 deletions.
10 changes: 0 additions & 10 deletions RELEASE_CHECKLIST.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,3 @@ We now do this automatically in CI.
- `mvn spotless:apply -U`
- might take a while for mavencentral to update, the `-U` flag above ensures that it tries again rather than caching a failure
- [ ] Comment on all released PRs / issues

## Stuck release

Sometimes a release gets stuck. The fix:

- sync mavencentral manually at bintray.com
- `./gradlew :plugin-gradle:publishPlugins -Prelease=true` if it was a gradle plugin fail
- update `CHANGES.md` manually
- `./gradlew spotlessApply`
- commit, tag, push
5 changes: 3 additions & 2 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ plugins {
id 'com.diffplug.eclipse.resourcefilters' version '3.27.0'
// https://plugins.gradle.org/plugin/com.gradle.plugin-publish
id 'com.gradle.plugin-publish' version '0.14.0' apply false
// https://github.com/bintray/gradle-bintray-plugin/releases
id 'com.jfrog.bintray' version '1.8.5' apply false
// https://github.com/gradle-nexus/publish-plugin/releases
id 'io.github.gradle-nexus.publish-plugin' version '1.0.0' apply false
// https://github.com/mnlipp/jdrupes-mdoclet/releases
id 'org.jdrupes.mdoclet' version '1.0.10' apply false
// https://github.com/spotbugs/spotbugs-gradle-plugin/releases
Expand All @@ -15,6 +15,7 @@ plugins {
id "com.diffplug.spotless-changelog" version "2.1.0" apply false
}

apply from: rootProject.file('gradle/java-publish.gradle')
apply from: rootProject.file('gradle/changelog.gradle')
allprojects {
apply from: rootProject.file('gradle/spotless.gradle')
Expand Down
61 changes: 28 additions & 33 deletions gradle/java-publish.gradle
Original file line number Diff line number Diff line change
@@ -1,8 +1,29 @@

if (project.parent == null) {
// it's the root project
apply plugin: 'io.github.gradle-nexus.publish-plugin'
nexusPublishing {
repositories {
sonatype {
username = System.env['nexus_user']
password = System.env['nexus_pass']
}
}
}
def initTask = tasks.named('initializeSonatypeStagingRepository')
allprojects {
initTask.configure {
shouldRunAfter(tasks.withType(Sign))
}
}
return
}

///////////
// MAVEN //
///////////
apply plugin: 'maven-publish'
apply plugin: 'com.jfrog.bintray'
apply plugin: 'signing'

task sourcesJar(type: Jar) {
classifier = 'sources'
Expand Down Expand Up @@ -138,36 +159,11 @@ model {
}

if (!version.endsWith('-SNAPSHOT')) {
// upload releases to bintray and then mavenCentral
bintray {
user = System.env['bintray_user']
key = System.env['bintray_pass']
publications = [
'pluginMaven'
]
publish = true
pkg {
repo = 'opensource'
name = project.ext.artifactId
userOrg = project.org
version {
name = project.version
mavenCentralSync {
user = System.env['nexus_user']
password = System.env['nexus_pass']
}
}
}
signing {
useInMemoryPgpKeys(System.env['gpg_key'], System.env['gpg_passphrase'])
sign(publishing.publications)
}

publish.dependsOn(bintrayUpload)
bintrayUpload.dependsOn([
'generatePomFileForPluginMavenPublication',
jar,
sourcesJar,
javadocJar
])

// find the project with the changelog (this project for plugins, root project for libs)
def changelogTasks = (tasks.names.contains('changelogBump') ? project : rootProject).tasks

Expand All @@ -177,10 +173,9 @@ if (!version.endsWith('-SNAPSHOT')) {
}
// ensures that changelog bump and push only happens if the publish was successful
changelogTasks.named('changelogBump').configure {
dependsOn tasks.named('bintrayUpload')
// only the root project has bintrayPublish, and it finalizes all bintrayUpload tasks
// https://github.com/bintray/gradle-bintray-plugin/blob/3fe02dfdae3e807afba57e0140a0d4c2424674e1/src/main/groovy/com/jfrog/bintray/gradle/ProjectsEvaluatedBuildListener.groovy#L37-L41
dependsOn rootProject.tasks.named('bintrayPublish')
String pubName = plugins.hasPlugin('java-gradle-plugin') ? 'PluginMaven' : 'MavenJava'
dependsOn tasks.named("publish${pubName}PublicationToSonatypeRepository")
dependsOn rootProject.tasks.named('closeAndReleaseSonatypeStagingRepository')
// if we have a gradle plugin, we need to push it up to the plugin portal too
if (tasks.names.contains('publishPlugins')) {
dependsOn tasks.named('publishPlugins')
Expand Down

0 comments on commit 1d521aa

Please sign in to comment.