Skip to content

Commit c4c8d22

Browse files
bclozelStephane Maldini
authored andcommitted
Build refactoring and fixing published POMs (rsocket#696)
* Upgrade to Gradle 5.6.2 Signed-off-by: Brian Clozel <bclozel@pivotal.io> * Do not publish dependency management with POMs Prior to this commit, the POMs and BOM produced by this build would also publish dependency management information for artifacts that are not provided by RSocket. This is problematic since this would provide/enforce opinions about unrelated dependencies such as test and logging dependencies. This commit configures the dependency-management Gradle plugin to not publish dependency management information with the generated POMs. It also uses the java-platform Gradle plugin to produce a proper BOM that does not contain dependencies, publishes dependency management information for RSocket artifacts only, and does not provide any scope opinion about those. This commit also polishes the main build file and: * uses the Netty BOM * upgrades JUnit to its latest version and uses its BOM * refactors the Gradle build files to avoid duplication Signed-off-by: Brian Clozel <bclozel@pivotal.io>
1 parent 47ad4d6 commit c4c8d22

7 files changed

Lines changed: 132 additions & 187 deletions

File tree

build.gradle

Lines changed: 47 additions & 177 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@
1515
*/
1616

1717
plugins {
18-
id 'com.gradle.build-scan' version '1.16'
18+
id 'com.gradle.build-scan' version '2.4.2'
1919

20-
id 'com.github.sherter.google-java-format' version '0.7.1' apply false
20+
id 'com.github.sherter.google-java-format' version '0.8' apply false
2121
id 'com.jfrog.artifactory' version '4.7.3' apply false
2222
id 'com.jfrog.bintray' version '1.8.4' apply false
2323
id 'me.champeau.gradle.jmh' version '0.4.8' apply false
@@ -28,17 +28,18 @@ plugins {
2828
subprojects {
2929
apply plugin: 'io.spring.dependency-management'
3030
apply plugin: 'com.github.sherter.google-java-format'
31-
31+
apply from: "${rootDir}/gradle/publications.gradle"
32+
3233
ext['reactor-bom.version'] = 'Dysprosium-RELEASE'
3334
ext['logback.version'] = '1.2.3'
3435
ext['findbugs.version'] = '3.0.2'
35-
ext['netty.version'] = '4.1.37.Final'
36+
ext['netty-bom.version'] = '4.1.37.Final'
3637
ext['netty-boringssl.version'] = '2.0.25.Final'
3738
ext['hdrhistogram.version'] = '2.1.10'
3839
ext['mockito.version'] = '2.25.1'
3940
ext['slf4j.version'] = '1.7.25'
4041
ext['jmh.version'] = '1.21'
41-
ext['junit.version'] = '5.1.0'
42+
ext['junit.version'] = '5.5.2'
4243
ext['hamcrest.version'] = '1.3'
4344
ext['micrometer.version'] = '1.0.6'
4445
ext['assertj.version'] = '3.11.1'
@@ -48,49 +49,41 @@ subprojects {
4849
}
4950

5051
ext {
51-
if (project.hasProperty('versionSuffix')) {
52-
project.version += project.getProperty('versionSuffix')
53-
}
52+
if (project.hasProperty('versionSuffix')) {
53+
project.version += project.getProperty('versionSuffix')
54+
}
5455
}
5556

5657
dependencyManagement {
5758
imports {
5859
mavenBom "io.projectreactor:reactor-bom:${ext['reactor-bom.version']}"
60+
mavenBom "io.netty:netty-bom:${ext['netty-bom.version']}"
61+
mavenBom "org.junit:junit-bom:${ext['junit.version']}"
5962
}
6063

6164
dependencies {
6265
dependency "ch.qos.logback:logback-classic:${ext['logback.version']}"
6366
dependency "com.google.code.findbugs:jsr305:${ext['findbugs.version']}"
64-
dependency "io.netty:netty-buffer:${ext['netty.version']}"
6567
dependency "io.netty:netty-tcnative-boringssl-static:${ext['netty-boringssl.version']}"
6668
dependency "io.micrometer:micrometer-core:${ext['micrometer.version']}"
6769
dependency "org.assertj:assertj-core:${ext['assertj.version']}"
6870
dependency "org.hdrhistogram:HdrHistogram:${ext['hdrhistogram.version']}"
6971
dependency "org.slf4j:slf4j-api:${ext['slf4j.version']}"
70-
7172
dependencySet(group: 'org.mockito', version: ext['mockito.version']) {
7273
entry 'mockito-junit-jupiter'
7374
entry 'mockito-core'
7475
}
75-
76-
dependencySet(group: 'org.junit.jupiter', version: ext['junit.version']) {
77-
entry 'junit-jupiter-api'
78-
entry 'junit-jupiter-engine'
79-
entry 'junit-jupiter-params'
80-
}
81-
8276
// TODO: Remove after JUnit5 migration
8377
dependency 'junit:junit:4.12'
8478
dependency "org.hamcrest:hamcrest-library:${ext['hamcrest.version']}"
85-
dependencySet(group: 'org.junit.vintage', version: ext['junit.version']) {
86-
entry 'junit-vintage-engine'
87-
}
88-
8979
dependencySet(group: 'org.openjdk.jmh', version: ext['jmh.version']) {
9080
entry 'jmh-core'
9181
entry 'jmh-generator-annprocess'
9282
}
9383
}
84+
generatedPomCustomization {
85+
enabled = false
86+
}
9487
}
9588

9689
repositories {
@@ -101,179 +94,56 @@ subprojects {
10194
}
10295
}
10396

104-
if (project.name != 'rsocket-bom') {
105-
106-
plugins.withType(JavaPlugin) {
107-
compileJava {
108-
sourceCompatibility = 1.8
97+
plugins.withType(JavaPlugin) {
98+
compileJava {
99+
sourceCompatibility = 1.8
109100

110-
// TODO: Cleanup warnings so no need to exclude
111-
options.compilerArgs << '-Xlint:all,-overloads,-rawtypes,-unchecked'
112-
}
113-
114-
javadoc {
115-
options.with {
116-
links 'https://docs.oracle.com/javase/8/docs/api/'
117-
links 'https://projectreactor.io/docs/core/release/api/'
118-
links 'https://netty.io/4.1/api/'
119-
}
120-
}
121-
122-
test {
123-
useJUnitPlatform()
124-
125-
systemProperty "io.netty.leakDetection.level", "ADVANCED"
126-
}
127-
128-
tasks.named("javadoc").configure {
129-
onlyIf { System.getenv('SKIP_RELEASE') != "true" }
130-
}
101+
// TODO: Cleanup warnings so no need to exclude
102+
options.compilerArgs << '-Xlint:all,-overloads,-rawtypes,-unchecked'
131103
}
132104

133-
plugins.withType(JavaLibraryPlugin) {
134-
task sourcesJar(type: Jar) {
135-
classifier 'sources'
136-
from sourceSets.main.allJava
137-
}
138-
139-
task javadocJar(type: Jar, dependsOn: javadoc) {
140-
classifier 'javadoc'
141-
from javadoc.destinationDir
105+
javadoc {
106+
options.with {
107+
links 'https://docs.oracle.com/javase/8/docs/api/'
108+
links 'https://projectreactor.io/docs/core/release/api/'
109+
links 'https://netty.io/4.1/api/'
142110
}
143111
}
144112

145-
plugins.withType(MavenPublishPlugin) {
146-
publishing {
147-
publications {
148-
maven(MavenPublication) {
149-
groupId 'io.rsocket'
150-
151-
from components.java
152-
153-
artifact sourcesJar
154-
artifact javadocJar
155-
156-
pom.withXml {
157-
asNode().':version' + {
158-
resolveStrategy = DELEGATE_FIRST
113+
test {
114+
useJUnitPlatform()
159115

160-
name project.name
161-
description project.description
162-
url 'http://rsocket.io'
163-
164-
licenses {
165-
license {
166-
name 'The Apache Software License, Version 2.0'
167-
url 'http://www.apache.org/license/LICENSE-2.0.txt'
168-
}
169-
}
170-
171-
developers {
172-
developer {
173-
id 'robertroeser'
174-
name 'Robert Roeser'
175-
email 'robert@netifi.com'
176-
}
177-
developer {
178-
id 'rdegnan'
179-
name 'Ryland Degnan'
180-
email 'ryland@netifi.com'
181-
}
182-
developer {
183-
id 'yschimke'
184-
name 'Yuri Schimke'
185-
email 'yuri@schimke.ee'
186-
}
187-
developer {
188-
id 'OlegDokuka'
189-
name 'Oleh Dokuka'
190-
email 'oleh@netifi.com'
191-
}
192-
developer {
193-
id 'mostroverkhov'
194-
name 'Maksym Ostroverkhov'
195-
email 'm.ostroverkhov@gmail.com'
196-
}
197-
}
198-
199-
scm {
200-
connection 'scm:git:https://github.com/rsocket/rsocket-java.git'
201-
developerConnection 'scm:git:https://github.com/rsocket/rsocket-java.git'
202-
url 'https://github.com/rsocket/rsocket-java'
203-
}
204-
}
205-
}
206-
}
207-
}
208-
}
116+
systemProperty "io.netty.leakDetection.level", "ADVANCED"
209117
}
210118

211-
} else {
212-
plugins.withType(MavenPublishPlugin) {
213-
publishing {
214-
publications {
215-
maven(MavenPublication) {
216-
groupId 'io.rsocket'
217-
218-
pom.withXml {
219-
asNode().':version' + {
220-
resolveStrategy = DELEGATE_FIRST
221-
222-
name project.name
223-
description project.description
224-
url 'http://rsocket.io'
119+
tasks.named("javadoc").configure {
120+
onlyIf { System.getenv('SKIP_RELEASE') != "true" }
121+
}
122+
}
225123

226-
licenses {
227-
license {
228-
name 'The Apache Software License, Version 2.0'
229-
url 'http://www.apache.org/license/LICENSE-2.0.txt'
230-
}
231-
}
124+
plugins.withType(JavaLibraryPlugin) {
125+
task sourcesJar(type: Jar) {
126+
classifier 'sources'
127+
from sourceSets.main.allJava
128+
}
232129

233-
developers {
234-
developer {
235-
id 'robertroeser'
236-
name 'Robert Roeser'
237-
email 'robert@netifi.com'
238-
}
239-
developer {
240-
id 'rdegnan'
241-
name 'Ryland Degnan'
242-
email 'ryland@netifi.com'
243-
}
244-
developer {
245-
id 'yschimke'
246-
name 'Yuri Schimke'
247-
email 'yuri@schimke.ee'
248-
}
249-
developer {
250-
id 'OlegDokuka'
251-
name 'Oleh Dokuka'
252-
email 'oleh@netifi.com'
253-
}
254-
developer {
255-
id 'mostroverkhov'
256-
name 'Maksym Ostroverkhov'
257-
email 'm.ostroverkhov@gmail.com'
258-
}
259-
}
130+
task javadocJar(type: Jar, dependsOn: javadoc) {
131+
classifier 'javadoc'
132+
from javadoc.destinationDir
133+
}
260134

261-
scm {
262-
connection 'scm:git:https://github.com/rsocket/rsocket-java.git'
263-
developerConnection 'scm:git:https://github.com/rsocket/rsocket-java.git'
264-
url 'https://github.com/rsocket/rsocket-java'
265-
}
266-
}
267-
}
268-
}
135+
publishing {
136+
publications {
137+
maven(MavenPublication) {
138+
from components.java
139+
artifact sourcesJar
140+
artifact javadocJar
269141
}
270142
}
271143
}
272144
}
273-
}
274145

275-
apply from: 'artifactory.gradle'
276-
apply from: 'bintray.gradle'
146+
}
277147

278148
buildScan {
279149
termsOfServiceUrl = 'https://gradle.com/terms-of-service'
File renamed without changes.

gradle/publications.gradle

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
apply plugin: "maven-publish"
2+
apply from: "${rootDir}/gradle/artifactory.gradle"
3+
apply from: "${rootDir}/gradle/bintray.gradle"
4+
5+
plugins.withType(MavenPublishPlugin) {
6+
publishing {
7+
publications {
8+
maven(MavenPublication) {
9+
pom {
10+
name = project.name
11+
groupId = 'io.rsocket'
12+
description = project.description
13+
url = 'http://rsocket.io'
14+
licenses {
15+
license {
16+
name = "The Apache Software License, Version 2.0"
17+
url = "https://www.apache.org/licenses/LICENSE-2.0.txt"
18+
distribution = "repo"
19+
}
20+
}
21+
developers {
22+
developer {
23+
id = 'robertroeser'
24+
name = 'Robert Roeser'
25+
email = 'robert@netifi.com'
26+
}
27+
developer {
28+
id = 'rdegnan'
29+
name = 'Ryland Degnan'
30+
email = 'ryland@netifi.com'
31+
}
32+
developer {
33+
id = 'yschimke'
34+
name = 'Yuri Schimke'
35+
email = 'yuri@schimke.ee'
36+
}
37+
developer {
38+
id = 'OlegDokuka'
39+
name = 'Oleh Dokuka'
40+
email = 'oleh@netifi.com'
41+
}
42+
developer {
43+
id = 'mostroverkhov'
44+
name = 'Maksym Ostroverkhov'
45+
email = 'm.ostroverkhov@gmail.com'
46+
}
47+
}
48+
scm {
49+
connection = 'scm:git:https://github.com/rsocket/rsocket-java.git'
50+
developerConnection = 'scm:git:https://github.com/rsocket/rsocket-java.git'
51+
url = 'https://github.com/rsocket/rsocket-java'
52+
}
53+
versionMapping {
54+
usage('java-api') {
55+
fromResolutionResult()
56+
}
57+
usage('java-runtime') {
58+
fromResolutionResult()
59+
}
60+
}
61+
}
62+
}
63+
}
64+
}
65+
}

gradle/wrapper/gradle-wrapper.jar

1.8 KB
Binary file not shown.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
distributionBase=GRADLE_USER_HOME
22
distributionPath=wrapper/dists
3-
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.2-bin.zip
3+
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-bin.zip
44
zipStoreBase=GRADLE_USER_HOME
55
zipStorePath=wrapper/dists

0 commit comments

Comments
 (0)