Skip to content

Commit b368cac

Browse files
nebhalerobertroeser
authored andcommitted
Gradle Improvements (#475)
This change contributes some improvements to the Gradle build. The most significant change is the introduction of the io.spring.dependency- management plugin. Don't let the name fool you, while this plugin was created for the Spring teams, it's generally applicable for all users of Gradle. This plugin allows you to define a dependencyManagement section (equivalent of the Maven construct of the same name). The information about the dependencies in that section is then used by each subproject to include dependencies without needing to specify a version number. This solves the problem of keeping groups of dependencies in sync with one another across projects and centralizes all the versions into a single location that can be quickly updated when necessary. dependencyManagement { dependencies { dependency 'junit:junit:4.12' } } dependencies { testImplementation 'junit:junit' } The second important change is the update of projects so that they now use the Gradle 'java-library' plugin instead of the 'java' plugin. This plugin is more modern, is considered idiomatic and allows much more control of the dependencies that a library exposes in it's POM as compile-time dependencies. Next, the build now minimizes the collection of artifacts that are published to Artifactory and Bintray repositories. Specifically, it ensures that the 'rsocket-examples' and 'rsocket-test' JARs are not published with the rest of the globally useful artifacts. The Artifactory and Bintray configurations have been split out into separate build scripts. This modularity encapsulates each publishing location's configuration and isolates it from the other. It also has the side-benefit of removing noise from the main build script which is much more focused on compiling code and creating JARs. At this time, I'm pretty confident in the configuration of the Artifactory, Bintray, and Maven Central configurations, but only actual publication to each will be able to verify that there were no regressions. Finally, dependencies were updated and Gradle configuration was streamlined (removing redundant declaration of defaults) to generally speed up and shrink the build.
1 parent d2732d8 commit b368cac

File tree

15 files changed

+318
-219
lines changed

15 files changed

+318
-219
lines changed

artifactory.gradle

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* Copyright 2015-2018 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
if (project.hasProperty('bintrayUser') && project.hasProperty('bintrayKey')) {
18+
artifactory {
19+
publish {
20+
contextUrl = 'https://oss.jfrog.org'
21+
22+
repository {
23+
repoKey = 'oss-snapshot-local'
24+
25+
// Credentials for oss.jfrog.org are a user's Bintray credentials
26+
username = project.property('bintrayUser')
27+
password = project.property('bintrayKey')
28+
}
29+
}
30+
}
31+
32+
subprojects {
33+
plugins.withId('com.jfrog.artifactory') {
34+
artifactoryPublish {
35+
publications('maven')
36+
}
37+
}
38+
}
39+
}

bintray.gradle

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/*
2+
* Copyright 2015-2018 the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
if (project.hasProperty('bintrayUser') && project.hasProperty('bintrayKey') &&
18+
project.hasProperty('sonatypeUser') && project.hasProperty('sonatypePassword')) {
19+
20+
bintray {
21+
user = project.property('bintrayUser')
22+
key = project.property('bintrayKey')
23+
24+
publish = true
25+
26+
pkg {
27+
repo = 'RSocket'
28+
name = 'rsocket-java'
29+
licenses = ['Apache-2.0']
30+
31+
issueTrackerUrl = 'https://github.com/rsocket/rsocket-java/issues'
32+
websiteUrl = 'https://github.com/rsocket/rsocket-java'
33+
vcsUrl = 'https://github.com/rsocket/rsocket-java.git'
34+
35+
githubRepo = 'rsocket/rsocket-java' //Optional Github repository
36+
githubReleaseNotesFile = 'README.md' //Optional Github readme file
37+
38+
version {
39+
name = project.version
40+
released = new Date()
41+
vcsTag = "v${project.version}"
42+
43+
gpg {
44+
sign = true
45+
}
46+
47+
mavenCentralSync {
48+
user = project.property('sonatypeUser')
49+
password = project.property('sonatypePassword')
50+
}
51+
}
52+
}
53+
}
54+
55+
subprojects {
56+
plugins.withId('com.jfrog.bintray') {
57+
bintray {
58+
publications('maven')
59+
}
60+
}
61+
}
62+
}

build.gradle

Lines changed: 73 additions & 126 deletions
Original file line numberDiff line numberDiff line change
@@ -15,159 +15,106 @@
1515
*/
1616

1717
plugins {
18-
id 'com.gradle.build-scan' version '1.9' // declare before any other plugin
18+
id 'com.gradle.build-scan' version '1.12.1'
1919

20+
id 'com.github.johnrengelman.shadow' version '2.0.2' apply false
2021
id 'com.github.sherter.google-java-format' version '0.6'
21-
id 'com.github.johnrengelman.shadow' version '2.0.1' apply false
22-
id 'me.champeau.gradle.jmh' version '0.4.4' apply false
23-
id 'io.morethan.jmhreport' version '0.6.2.1' apply false
24-
25-
id 'com.jfrog.artifactory' version '4.5.2'
26-
id 'com.jfrog.bintray' version '1.7.3'
22+
id 'com.jfrog.artifactory' version '4.7.0'
23+
id 'com.jfrog.bintray' version '1.8.0'
24+
id 'me.champeau.gradle.jmh' version '0.4.5' apply false
25+
id 'io.spring.dependency-management' version '1.0.4.RELEASE' apply false
26+
id 'io.morethan.jmhreport' version '0.7.0' apply false
2727
}
2828

29-
repositories {
30-
jcenter()
29+
allprojects {
30+
version '0.10.0.BUILD-SNAPSHOT'
3131
}
3232

33-
description = 'RSocket: stream oriented messaging passing with Reactive Stream semantics.'
34-
35-
buildScan { licenseAgreementUrl = 'https://gradle.com/terms-of-service'; licenseAgree = 'yes' }
33+
subprojects {
34+
apply plugin: 'io.spring.dependency-management'
3635

37-
googleJavaFormat {
38-
toolVersion = '1.4'
39-
}
36+
dependencyManagement {
37+
imports {
38+
// TODO: Upgrade to latest version
39+
mavenBom 'io.projectreactor:reactor-bom:Bismuth-SR6'
40+
}
4041

41-
subprojects {
42-
apply plugin: 'java'
43-
apply plugin: 'maven'
44-
apply plugin: 'maven-publish'
45-
apply plugin: 'com.jfrog.bintray'
46-
apply plugin: 'com.jfrog.artifactory'
47-
48-
group = 'io.rsocket'
49-
version = mavenversion
50-
51-
compileJava {
52-
sourceCompatibility = 1.8
53-
targetCompatibility = 1.8
54-
options.compilerArgs << '-Xlint:all,-overloads,-rawtypes,-unchecked'
55-
}
42+
dependencies {
43+
dependency 'com.google.code.findbugs:jsr305:3.0.2'
44+
dependency 'com.netflix.spectator:spectator-api:0.63.0'
45+
dependency 'io.netty:netty-buffer:4.1.21.Final'
46+
dependency 'junit:junit:4.12'
47+
dependency 'io.aeron:aeron-all:1.4.1'
48+
dependency 'org.hamcrest:hamcrest-library:1.3'
49+
dependency 'org.hdrhistogram:HdrHistogram:2.1.10'
50+
dependency 'org.mockito:mockito-core:2.16.0'
51+
dependency 'org.openjdk.jmh:jmh-core:1.20'
52+
53+
dependencySet(group: 'org.openjdk.jmh', version: '1.20') {
54+
entry 'jmh-core'
55+
entry 'jmh-generator-annprocess'
56+
}
5657

57-
// custom tasks for creating source/javadoc jars
58-
task sourcesJar(type: Jar, dependsOn: classes) {
59-
classifier = 'sources'
60-
from sourceSets.main.allSource
58+
dependencySet(group: 'org.slf4j', version: '1.7.25') {
59+
entry 'slf4j-api'
60+
entry 'slf4j-nop'
61+
}
62+
}
6163
}
6264

63-
task javadocJar(type: Jar, dependsOn: javadoc) {
64-
classifier = 'javadoc'
65-
from javadoc.destinationDir
65+
repositories {
66+
mavenCentral()
6667
}
6768

68-
tasks.bintrayUpload.dependsOn tasks.jar, tasks.sourcesJar, tasks.javadocJar
69+
plugins.withType(JavaPlugin) {
70+
compileJava {
71+
sourceCompatibility = 1.8
6972

70-
// add javadoc/source jar tasks as artifacts
71-
artifacts {
72-
archives sourcesJar, javadocJar, jar
73+
// TODO: Cleanup warnings so no need to exclude
74+
options.compilerArgs << '-Xlint:all,-overloads,-rawtypes,-unchecked'
75+
}
7376
}
7477

75-
repositories {
76-
jcenter()
77-
}
78+
plugins.withType(JavaLibraryPlugin) {
79+
task sourcesJar(type: Jar) {
80+
classifier 'sources'
81+
from sourceSets.main.allJava
82+
}
7883

79-
dependencies {
80-
compile "io.projectreactor:reactor-core:3.1.3.RELEASE"
81-
compile "io.netty:netty-buffer:4.1.20.Final"
82-
compile "org.slf4j:slf4j-api:1.7.25"
83-
compile "com.google.code.findbugs:jsr305:3.0.2"
84-
85-
testCompile "junit:junit:4.12"
86-
testCompile "org.mockito:mockito-core:2.10.0"
87-
testCompile "org.hamcrest:hamcrest-library:1.3"
88-
testCompile "org.slf4j:slf4j-log4j12:1.7.25"
89-
testCompile "io.projectreactor:reactor-test:3.1.3.RELEASE"
84+
task javadocJar(type: Jar, dependsOn: javadoc) {
85+
classifier 'javadoc'
86+
from javadoc.destinationDir
87+
}
9088
}
9189

92-
publishing {
93-
publications {
94-
mavenJava(MavenPublication) {
95-
from components.java
90+
plugins.withType(MavenPublishPlugin) {
91+
publishing {
92+
publications {
93+
maven(MavenPublication) {
94+
groupId 'io.rsocket'
9695

97-
artifact sourcesJar {
98-
classifier "sources"
99-
}
96+
from components.java
10097

101-
artifact javadocJar {
102-
classifier "javadoc"
98+
artifact sourcesJar
99+
artifact javadocJar
103100
}
104101
}
105102
}
106103
}
104+
}
107105

108-
artifactory {
109-
publish {
110-
contextUrl = 'https://oss.jfrog.org'
111-
112-
repository {
113-
repoKey = 'oss-snapshot-local' //The Artifactory repository key to publish to
114-
//when using oss.jfrog.org the credentials are from Bintray. For local build we expect them to be found in
115-
//~/.gradle/gradle.properties, otherwise to be set in the build server
116-
// Conditionalize for the users who don't have bintray credentials setup
117-
if (project.hasProperty('bintrayUser')) {
118-
username = project.property('bintrayUser')
119-
password = project.property('bintrayKey')
120-
}
121-
}
122-
123-
publications('mavenJava')
106+
apply from: 'artifactory.gradle'
107+
apply from: 'bintray.gradle'
124108

125-
defaults {
126-
// Reference to Gradle publications defined in the build script.
127-
// This is how we tell the Artifactory Plugin which artifacts should be
128-
// published to Artifactory.
129-
publications('mavenJava')
130-
publishArtifacts = true
131-
}
132-
}
133-
}
109+
buildScan {
110+
termsOfServiceUrl = 'https://gradle.com/terms-of-service'
111+
termsOfServiceAgree = 'yes'
112+
}
134113

135-
artifactoryPublish {
136-
dependsOn jar
137-
}
114+
googleJavaFormat {
115+
toolVersion = '1.5'
116+
}
138117

139-
bintray {
140-
if (project.hasProperty('bintrayUser')) {
141-
user = project.property('bintrayUser')
142-
key = project.property('bintrayKey')
143-
}
144-
publications = ['mavenJava']
145-
dryRun = false
146-
publish = true
147-
override = false
148-
pkg {
149-
repo = 'RSocket'
150-
name = 'rsocket-java'
151-
desc = 'RSocket'
152-
websiteUrl = 'https://github.com/rsocket/rsocket-java'
153-
issueTrackerUrl = 'https://github.com/rsocket/rsocket-java'
154-
vcsUrl = 'https://github.com/rsocket/rsocket-java.git'
155-
licenses = ['Apache-2.0']
156-
githubRepo = 'rsocket/rsocket-java' //Optional Github repository
157-
githubReleaseNotesFile = 'README.md' //Optional Github readme file
158-
if (project.hasProperty('sonatypeUsername') && project.hasProperty('sonatypePassword')) {
159-
def sonatypeUsername = project.property('sonatypeUsername')
160-
def sonatypePassword = project.property('sonatypePassword')
161-
version {
162-
name = "v${project.version}"
163-
vcsTag = "${project.version}"
164-
mavenCentralSync {
165-
sync = false
166-
user = sonatypeUsername
167-
password = sonatypePassword
168-
}
169-
}
170-
}
171-
}
172-
}
118+
repositories {
119+
mavenCentral()
173120
}

gradle.properties

Lines changed: 0 additions & 19 deletions
This file was deleted.
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.6-all.zip
34
zipStoreBase=GRADLE_USER_HOME
45
zipStorePath=wrapper/dists
5-
distributionUrl=https\://services.gradle.org/distributions/gradle-4.2.1-all.zip

0 commit comments

Comments
 (0)