Skip to content

Commit 1d521aa

Browse files
committed
Fix publishing for post-bintray.
1 parent e05b77f commit 1d521aa

File tree

3 files changed

+31
-45
lines changed

3 files changed

+31
-45
lines changed

RELEASE_CHECKLIST.md

-10
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,3 @@ We now do this automatically in CI.
1414
- `mvn spotless:apply -U`
1515
- might take a while for mavencentral to update, the `-U` flag above ensures that it tries again rather than caching a failure
1616
- [ ] Comment on all released PRs / issues
17-
18-
## Stuck release
19-
20-
Sometimes a release gets stuck. The fix:
21-
22-
- sync mavencentral manually at bintray.com
23-
- `./gradlew :plugin-gradle:publishPlugins -Prelease=true` if it was a gradle plugin fail
24-
- update `CHANGES.md` manually
25-
- `./gradlew spotlessApply`
26-
- commit, tag, push

build.gradle

+3-2
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ plugins {
33
id 'com.diffplug.eclipse.resourcefilters' version '3.27.0'
44
// https://plugins.gradle.org/plugin/com.gradle.plugin-publish
55
id 'com.gradle.plugin-publish' version '0.14.0' apply false
6-
// https://github.com/bintray/gradle-bintray-plugin/releases
7-
id 'com.jfrog.bintray' version '1.8.5' apply false
6+
// https://github.com/gradle-nexus/publish-plugin/releases
7+
id 'io.github.gradle-nexus.publish-plugin' version '1.0.0' apply false
88
// https://github.com/mnlipp/jdrupes-mdoclet/releases
99
id 'org.jdrupes.mdoclet' version '1.0.10' apply false
1010
// https://github.com/spotbugs/spotbugs-gradle-plugin/releases
@@ -15,6 +15,7 @@ plugins {
1515
id "com.diffplug.spotless-changelog" version "2.1.0" apply false
1616
}
1717

18+
apply from: rootProject.file('gradle/java-publish.gradle')
1819
apply from: rootProject.file('gradle/changelog.gradle')
1920
allprojects {
2021
apply from: rootProject.file('gradle/spotless.gradle')

gradle/java-publish.gradle

+28-33
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,29 @@
1+
2+
if (project.parent == null) {
3+
// it's the root project
4+
apply plugin: 'io.github.gradle-nexus.publish-plugin'
5+
nexusPublishing {
6+
repositories {
7+
sonatype {
8+
username = System.env['nexus_user']
9+
password = System.env['nexus_pass']
10+
}
11+
}
12+
}
13+
def initTask = tasks.named('initializeSonatypeStagingRepository')
14+
allprojects {
15+
initTask.configure {
16+
shouldRunAfter(tasks.withType(Sign))
17+
}
18+
}
19+
return
20+
}
21+
122
///////////
223
// MAVEN //
324
///////////
425
apply plugin: 'maven-publish'
5-
apply plugin: 'com.jfrog.bintray'
26+
apply plugin: 'signing'
627

728
task sourcesJar(type: Jar) {
829
classifier = 'sources'
@@ -138,36 +159,11 @@ model {
138159
}
139160

140161
if (!version.endsWith('-SNAPSHOT')) {
141-
// upload releases to bintray and then mavenCentral
142-
bintray {
143-
user = System.env['bintray_user']
144-
key = System.env['bintray_pass']
145-
publications = [
146-
'pluginMaven'
147-
]
148-
publish = true
149-
pkg {
150-
repo = 'opensource'
151-
name = project.ext.artifactId
152-
userOrg = project.org
153-
version {
154-
name = project.version
155-
mavenCentralSync {
156-
user = System.env['nexus_user']
157-
password = System.env['nexus_pass']
158-
}
159-
}
160-
}
162+
signing {
163+
useInMemoryPgpKeys(System.env['gpg_key'], System.env['gpg_passphrase'])
164+
sign(publishing.publications)
161165
}
162166

163-
publish.dependsOn(bintrayUpload)
164-
bintrayUpload.dependsOn([
165-
'generatePomFileForPluginMavenPublication',
166-
jar,
167-
sourcesJar,
168-
javadocJar
169-
])
170-
171167
// find the project with the changelog (this project for plugins, root project for libs)
172168
def changelogTasks = (tasks.names.contains('changelogBump') ? project : rootProject).tasks
173169

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

0 commit comments

Comments
 (0)