1
- import java.util.*
2
-
3
1
plugins {
4
2
id(" java-library" )
5
3
id(" com.github.johnrengelman.shadow" )
6
4
id(" biz.aQute.bnd.builder" )
7
5
id(" maven-publish" )
8
- id(" com.jfrog.bintray" )
6
+ id(" io.github.gradle-nexus.publish-plugin" )
7
+ id(" signing" )
9
8
id(" com.github.breadmoirai.github-release" )
10
9
id(" com.github.hierynomus.license" )
11
10
id(" pmd" )
@@ -25,25 +24,25 @@ allprojects {
25
24
plugins.apply (" com.github.sgtsilvio.gradle.metadata" )
26
25
27
26
metadata {
28
- moduleName = " com.hivemq.client.mqtt"
29
- readableName = " HiveMQ MQTT Client"
27
+ moduleName.set( " com.hivemq.client.mqtt" )
28
+ readableName.set( " HiveMQ MQTT Client" )
30
29
organization {
31
- name = " HiveMQ and the HiveMQ Community"
32
- url = " https://www.hivemq.com/"
30
+ name.set( " HiveMQ and the HiveMQ Community" )
31
+ url.set( " https://www.hivemq.com/" )
33
32
}
34
33
license {
35
34
apache2()
36
35
}
37
36
developers {
38
37
developer {
39
- id = " SgtSilvio"
40
- name = " Silvio Giebl"
41
- email = " silvio.giebl@hivemq.com"
38
+ id.set( " SgtSilvio" )
39
+ name.set( " Silvio Giebl" )
40
+ email.set( " silvio.giebl@hivemq.com" )
42
41
}
43
42
}
44
43
github {
45
- org = " hivemq"
46
- repo = " hivemq-mqtt-client"
44
+ org.set( " hivemq" )
45
+ repo.set( " hivemq-mqtt-client" )
47
46
pages()
48
47
issues()
49
48
}
@@ -67,12 +66,6 @@ allprojects {
67
66
68
67
/* ******************** dependencies ******************** */
69
68
70
- allprojects {
71
- repositories {
72
- mavenCentral()
73
- }
74
- }
75
-
76
69
dependencies {
77
70
api(" io.reactivex.rxjava2:rxjava:${property(" rxjava.version" )} " )
78
71
api(" org.reactivestreams:reactive-streams:${property(" reactive-streams.version" )} " )
@@ -94,8 +87,8 @@ dependencies {
94
87
95
88
/* ******************** optional dependencies ******************** */
96
89
97
- listOf (" websocket" , " proxy" , " epoll" ).forEach {
98
- java.registerFeature(it ) {
90
+ for (feature in listOf (" websocket" , " proxy" , " epoll" )) {
91
+ java.registerFeature(feature ) {
99
92
usingSourceSet(sourceSets[" main" ])
100
93
}
101
94
}
@@ -120,7 +113,7 @@ allprojects {
120
113
tasks.test {
121
114
useJUnitPlatform()
122
115
maxHeapSize = " 1g"
123
- maxParallelForks = Runtime .getRuntime().availableProcessors()
116
+ maxParallelForks = 1 .coerceAtLeast( Runtime .getRuntime().availableProcessors() / 2 )
124
117
jvmArgs(" -XX:+UseParallelGC" )
125
118
}
126
119
}
@@ -177,12 +170,10 @@ tasks.shadowJar {
177
170
archiveAppendix.set(" shaded" )
178
171
archiveClassifier.set(" " )
179
172
180
- configurations = listOf (project.run {
181
- configurations.create(" shaded" ) {
182
- extendsFrom(configurations[" runtimeClasspath" ])
183
- configurations[" apiElements" ].allDependencies.forEach {
184
- exclude(it.group, it.name)
185
- }
173
+ configurations = listOf (project.configurations.create(" shaded" ) {
174
+ extendsFrom(project.configurations[" runtimeClasspath" ])
175
+ for (apiDependency in project.configurations[" apiElements" ].allDependencies) {
176
+ exclude(apiDependency.group, apiDependency.name)
186
177
}
187
178
})
188
179
@@ -202,8 +193,6 @@ tasks.shadowJar {
202
193
203
194
/* ******************** publishing ******************** */
204
195
205
- apply (" ${rootDir} /gradle/publishing.gradle.kts" )
206
-
207
196
allprojects {
208
197
plugins.withId(" java-library" ) {
209
198
@@ -233,11 +222,11 @@ publishing.publications.register<MavenPublication>("shaded") {
233
222
artifact(tasks[" sourcesJar" ])
234
223
pom.withXml {
235
224
asNode().appendNode(" dependencies" ).apply {
236
- configurations[" apiElements" ].allDependencies.forEach {
225
+ for (apiDependency in configurations[" apiElements" ].allDependencies) {
237
226
appendNode(" dependency" ).apply {
238
- appendNode(" groupId" , it .group)
239
- appendNode(" artifactId" , it .name)
240
- appendNode(" version" , it .version)
227
+ appendNode(" groupId" , apiDependency .group)
228
+ appendNode(" artifactId" , apiDependency .name)
229
+ appendNode(" version" , apiDependency .version)
241
230
appendNode(" scope" , " compile" )
242
231
}
243
232
}
@@ -247,18 +236,14 @@ publishing.publications.register<MavenPublication>("shaded") {
247
236
248
237
allprojects {
249
238
plugins.withId(" maven-publish" ) {
250
- afterEvaluate {
251
- publishing.publications.withType<MavenPublication >().configureEach {
252
- pom.withXml {
253
- (asNode()[" dependencies" ] as groovy.util.NodeList ).forEach { dependencies ->
254
- (dependencies as groovy.util.Node ).children().forEach { dependency ->
255
- val dep = dependency as groovy.util.Node
256
- val optional = dep[" optional" ] as groovy.util.NodeList
257
- val scope = dep[" scope" ] as groovy.util.NodeList
258
- if (! optional.isEmpty() && (optional[0 ] as groovy.util.Node ).text() == " true" ) {
259
- (scope[0 ] as groovy.util.Node ).setValue(" runtime" )
260
- }
261
- }
239
+ publishing.publications.withType<MavenPublication >().configureEach {
240
+ pom.withXml {
241
+ val dependencies = (asNode()[" dependencies" ] as groovy.util.NodeList )[0 ] as groovy.util.Node
242
+ for (dependency in dependencies.children()) {
243
+ dependency as groovy.util.Node
244
+ val optional = dependency[" optional" ] as groovy.util.NodeList
245
+ if (! optional.isEmpty() && (optional[0 ] as groovy.util.Node ).text() == " true" ) {
246
+ ((dependency[" scope" ] as groovy.util.NodeList )[0 ] as groovy.util.Node ).setValue(" runtime" )
262
247
}
263
248
}
264
249
}
@@ -269,56 +254,33 @@ allprojects {
269
254
allprojects {
270
255
plugins.withId(" maven-publish" ) {
271
256
272
- plugins.apply (" com.jfrog.bintray" )
273
-
274
- bintray {
275
- user = " ${rootProject.extra[" bintray_username" ]} "
276
- key = " ${rootProject.extra[" bintray_apiKey" ]} "
277
- publish = true
278
- pkg.apply {
279
- userOrg = " hivemq"
280
- repo = " HiveMQ"
281
- name = " hivemq-mqtt-client"
282
- desc = project.description
283
- websiteUrl = metadata.url
284
- issueTrackerUrl = metadata.issueManagement.url
285
- vcsUrl = metadata.scm.url
286
- setLicenses(metadata.license.shortName)
287
- setLabels(" mqtt" , " mqtt-client" , " iot" , " internet-of-things" , " rxjava2" , " reactive-streams" , " backpressure" )
288
- version.apply {
289
- released = Date ().toString()
290
- vcsTag = " v${project.version} "
291
- gpg.apply {
292
- sign = true
293
- }
294
- }
295
- }
296
- }
297
- afterEvaluate {
298
- bintray.setPublications(* publishing.publications.withType<MavenPublication >().names.toTypedArray())
299
- }
257
+ plugins.apply (" signing" )
300
258
301
- // workaround for publishing gradle module metadata https://github.com/bintray/gradle-bintray-plugin/issues/229
302
- tasks.withType< com.jfrog.bintray.gradle.tasks.BintrayUploadTask > {
303
- doFirst {
304
- publishing.publications.withType<MavenPublication > {
305
- val moduleFile = buildDir.resolve(" publications/$name /module.json" )
306
- if (moduleFile.exists()) {
307
- artifact(moduleFile).extension = " module"
308
- }
309
- }
259
+ signing {
260
+ val signingKey: String? by project
261
+ val signingPassword: String? by project
262
+ useInMemoryPgpKeys(signingKey, signingPassword)
263
+ publishing.publications.configureEach {
264
+ sign(this )
310
265
}
311
266
}
312
267
}
313
268
}
314
269
270
+ nexusPublishing {
271
+ repositories {
272
+ sonatype()
273
+ }
274
+ }
275
+
315
276
githubRelease {
316
- token(" ${rootProject.extra[" github_token" ]} " )
317
- owner.set(metadata.github.org)
318
- repo.set(metadata.github.repo)
277
+ owner.set(metadata.github!! .org.get())
278
+ repo.set(metadata.github!! .repo.get())
319
279
targetCommitish.set(" master" )
320
280
tagName.set(" v${project.version} " )
321
281
releaseName.set(" ${project.version} " )
282
+ val githubToken: String? by project
283
+ token(githubToken)
322
284
}
323
285
324
286
@@ -340,11 +302,12 @@ allprojects {
340
302
341
303
pmd {
342
304
toolVersion = " 5.7.0"
305
+ incrementalAnalysis.set(false )
343
306
}
344
307
}
345
308
}
346
309
347
- apply (" ${ rootDir} /gradle/japicc.gradle.kts" )
310
+ apply (" $rootDir /gradle/japicc.gradle.kts" )
348
311
349
312
350
313
/* ******************** build cache ******************** */
0 commit comments