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
+
1
22
// /////////
2
23
// MAVEN //
3
24
// /////////
4
25
apply plugin : ' maven-publish'
5
- apply plugin : ' com.jfrog.bintray '
26
+ apply plugin : ' signing '
6
27
7
28
task sourcesJar (type : Jar ) {
8
29
classifier = ' sources'
@@ -138,36 +159,11 @@ model {
138
159
}
139
160
140
161
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)
161
165
}
162
166
163
- publish. dependsOn(bintrayUpload)
164
- bintrayUpload. dependsOn([
165
- ' generatePomFileForPluginMavenPublication' ,
166
- jar,
167
- sourcesJar,
168
- javadocJar
169
- ])
170
-
171
167
// find the project with the changelog (this project for plugins, root project for libs)
172
168
def changelogTasks = (tasks. names. contains(' changelogBump' ) ? project : rootProject). tasks
173
169
@@ -177,10 +173,9 @@ if (!version.endsWith('-SNAPSHOT')) {
177
173
}
178
174
// ensures that changelog bump and push only happens if the publish was successful
179
175
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' )
184
179
// if we have a gradle plugin, we need to push it up to the plugin portal too
185
180
if (tasks. names. contains(' publishPlugins' )) {
186
181
dependsOn tasks. named(' publishPlugins' )
0 commit comments