Skip to content

Commit 11b50a5

Browse files
Modernize gradle plugin block, change maven to maven-publish (#7219)
* Modernize gradle plugin block, change maven to maven-publish Move gradle plugins to block at top of file per gradle recommendations. Change deprecated maven plugin to maven-publish as in Gradle 7.0 it will be removed. Several other minor updates to gradle file including, removing semi-colons, changing println to use built-in logger. * Updated gauva to correct version
1 parent c38ea99 commit 11b50a5

File tree

1 file changed

+42
-79
lines changed

1 file changed

+42
-79
lines changed

build.gradle

+42-79
Original file line numberDiff line numberDiff line change
@@ -1,72 +1,47 @@
1-
buildscript {
1+
plugins {
2+
id("java-library")
3+
id("checkstyle")
4+
id("eclipse")
5+
id("jacoco")
6+
id("maven-publish")
7+
id("ru.vyarus.animalsniffer") version "1.5.3"
8+
id("me.champeau.gradle.jmh") version "0.5.3"
9+
id("com.github.hierynomus.license") version "0.15.0"
10+
id("com.jfrog.artifactory") version "4.21.0"
11+
id("biz.aQute.bnd.builder") version "5.3.0"
12+
id("com.vanniktech.maven.publish") version "0.14.2"
13+
}
214

3-
// Dependency versions
4-
// ---------------------------------------
5-
ext {
15+
ext {
616
reactiveStreamsVersion = "1.0.3"
717
junitVersion = "4.13.2"
818
testNgVersion = "7.3.0"
919
mockitoVersion = "3.8.0"
1020
jmhLibVersion = "1.21"
11-
jmhGradleVersion = "0.5.3"
1221
guavaVersion = "30.1.1-jre"
1322
jacocoVersion = "0.8.4"
14-
animalSnifferVersion = "1.5.3"
15-
licenseVersion = "0.15.0"
16-
jfrogExtractorVersion = "4.21.0"
17-
bndVersion = "5.3.0"
1823
checkstyleVersion = "8.41"
19-
vanniktechPublishPlugin = "0.14.2"
20-
}
21-
22-
// --------------------------------------
23-
24-
repositories {
25-
mavenCentral()
26-
gradlePluginPortal()
27-
}
28-
dependencies {
29-
classpath "ru.vyarus:gradle-animalsniffer-plugin:$animalSnifferVersion"
30-
classpath "gradle.plugin.com.hierynomus.gradle.plugins:license-gradle-plugin:$licenseVersion"
31-
classpath "me.champeau.gradle:jmh-gradle-plugin:$jmhGradleVersion"
32-
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:$jfrogExtractorVersion"
33-
classpath "biz.aQute.bnd:biz.aQute.bnd.gradle:$bndVersion"
34-
classpath "com.vanniktech:gradle-maven-publish-plugin:$vanniktechPublishPlugin"
35-
}
3624
}
3725

38-
group = "io.reactivex.rxjava3"
39-
ext.githubProjectName = "rxjava"
40-
41-
def releaseTag = System.getenv("BUILD_TAG");
26+
def releaseTag = System.getenv("BUILD_TAG")
4227
if (releaseTag != null && !releaseTag.isEmpty()) {
4328
if (releaseTag.startsWith("v")) {
44-
releaseTag = releaseTag.substring(1);
29+
releaseTag = releaseTag.substring(1)
4530
}
46-
project.setProperty("VERSION_NAME" , releaseTag);
31+
project.setProperty("VERSION_NAME" , releaseTag)
4732

48-
println("Releasing with version " + version);
33+
logger.info("Releasing with version: {}", version)
4934
}
5035

36+
group = "io.reactivex.rxjava3"
5137
version = project.properties["VERSION_NAME"]
52-
5338
description = "RxJava: Reactive Extensions for the JVM – a library for composing asynchronous and event-based programs using observable sequences for the Java VM."
5439

55-
apply plugin: "java-library"
56-
apply plugin: "checkstyle"
57-
apply plugin: "jacoco"
58-
apply plugin: "ru.vyarus.animalsniffer"
59-
apply plugin: "maven"
60-
apply plugin: "me.champeau.gradle.jmh"
61-
apply plugin: "com.github.hierynomus.license"
62-
apply plugin: "com.jfrog.artifactory"
63-
apply plugin: "eclipse"
64-
6540
sourceCompatibility = JavaVersion.VERSION_1_8
6641
targetCompatibility = JavaVersion.VERSION_1_8
6742

6843
repositories {
69-
mavenCentral()
44+
mavenCentral()
7045
}
7146

7247
dependencies {
@@ -84,7 +59,7 @@ dependencies {
8459
}
8560

8661
tasks.withType(JavaCompile) {
87-
options.compilerArgs << "-parameters";
62+
options.compilerArgs << "-parameters"
8863
}
8964

9065
javadoc {
@@ -100,7 +75,7 @@ javadoc {
10075
options.addStringOption("top").value = ""
10176
options.addStringOption("doctitle").value = ""
10277
options.addStringOption("header").value = ""
103-
options.stylesheetFile = new File(projectDir, "gradle/stylesheet.css");
78+
options.stylesheetFile = rootProject.file("gradle/stylesheet.css")
10479

10580
options.links(
10681
"https://docs.oracle.com/javase/8/docs/api/",
@@ -112,19 +87,16 @@ animalsniffer {
11287
annotation = "io.reactivex.rxjava3.internal.util.SuppressAnimalSniffer"
11388
}
11489

115-
apply plugin: 'maven'
116-
117-
apply plugin: 'biz.aQute.bnd.builder'
118-
11990
jar {
120-
bnd ('Bundle-Name': 'rxjava',
121-
'Bundle-Vendor': 'RxJava Contributors',
122-
'Bundle-Description': 'Reactive Extensions for the JVM – a library for composing asynchronous and event-based programs using observable sequences for the Java VM.',
123-
'Import-Package': '!org.junit,!junit.framework,!org.mockito.*,!org.testng.*,*',
124-
'Bundle-DocURL': 'https://github.com/ReactiveX/RxJava',
125-
'Eclipse-ExtensibleAPI': 'true',
126-
'Automatic-Module-Name': 'io.reactivex.rxjava3',
127-
'Export-Package': '!io.reactivex.rxjava3.internal.*, io.reactivex.rxjava3.*'
91+
bnd (
92+
"Bundle-Name": "rxjava",
93+
"Bundle-Vendor": "RxJava Contributors",
94+
"Bundle-Description": "Reactive Extensions for the JVM – a library for composing asynchronous and event-based programs using observable sequences for the Java VM.",
95+
"Import-Package": "!org.junit,!junit.framework,!org.mockito.*,!org.testng.*,*",
96+
"Bundle-DocURL": "https://github.com/ReactiveX/RxJava",
97+
"Eclipse-ExtensibleAPI": "true",
98+
"Automatic-Module-Name": "io.reactivex.rxjava3",
99+
"Export-Package": "!io.reactivex.rxjava3.internal.*, io.reactivex.rxjava3.*"
128100
)
129101
}
130102

@@ -144,14 +116,13 @@ jmh {
144116
jvmArgsAppend = ["-Djmh.separateClasspathJAR=true"]
145117

146118
if (project.hasProperty("jmh")) {
147-
include = ".*" + project.jmh + ".*"
148-
println("JMH: " + include);
119+
include = [".*" + project.jmh + ".*"]
120+
logger.info("JMH: {}", include)
149121
}
150-
151122
}
152123

153124
plugins.withType(EclipsePlugin) {
154-
project.eclipse.classpath.plusConfigurations += [ configurations.jmh ]
125+
project.eclipse.classpath.plusConfigurations += [configurations.jmh]
155126
}
156127

157128
test {
@@ -199,25 +170,21 @@ task testng(type: Test) {
199170
check.dependsOn testng
200171

201172
jacoco {
202-
toolVersion = jacocoVersion // See http://www.eclemma.org/jacoco/.
173+
toolVersion = jacocoVersion
203174
}
204175

205176
task GCandMem(dependsOn: "check") doLast {
206-
print("Memory usage before: ")
207-
println(java.lang.management.ManagementFactory.getMemoryMXBean().getHeapMemoryUsage().getUsed() / 1024.0 / 1024.0)
177+
logger.lifecycle("Memory usage before: {}", java.lang.management.ManagementFactory.getMemoryMXBean().getHeapMemoryUsage().getUsed() / 1024.0 / 1024.0)
208178
System.gc()
209179
Thread.sleep(200)
210-
print("Memory usage: ")
211-
println(java.lang.management.ManagementFactory.getMemoryMXBean().getHeapMemoryUsage().getUsed() / 1024.0 / 1024.0)
180+
logger.lifecycle("Memory usage: {}", java.lang.management.ManagementFactory.getMemoryMXBean().getHeapMemoryUsage().getUsed() / 1024.0 / 1024.0)
212181
}
213182

214183
task GCandMem2(dependsOn: "test") doLast {
215-
print("Memory usage before: ")
216-
println(java.lang.management.ManagementFactory.getMemoryMXBean().getHeapMemoryUsage().getUsed() / 1024.0 / 1024.0)
184+
logger.lifecycle("Memory usage before: {}", java.lang.management.ManagementFactory.getMemoryMXBean().getHeapMemoryUsage().getUsed() / 1024.0 / 1024.0)
217185
System.gc()
218186
Thread.sleep(200)
219-
print("Memory usage: ")
220-
println(java.lang.management.ManagementFactory.getMemoryMXBean().getHeapMemoryUsage().getUsed() / 1024.0 / 1024.0)
187+
logger.lifecycle("Memory usage: {}", java.lang.management.ManagementFactory.getMemoryMXBean().getHeapMemoryUsage().getUsed() / 1024.0 / 1024.0)
221188
}
222189

223190
testng.dependsOn GCandMem2
@@ -258,12 +225,10 @@ def fixPom() {
258225
}
259226

260227
if (rootProject.hasProperty("releaseMode")) {
228+
logger.lifecycle("ReleaseMode: {}", rootProject.releaseMode)
261229

262230
if ("branch".equals(rootProject.releaseMode)) {
263231
// From https://github.com/ReactiveX/RxAndroid/blob/2.x/rxandroid/build.gradle#L94
264-
265-
println("ReleaseMode: " + rootProject.releaseMode);
266-
267232
artifactory {
268233
contextUrl = "https://oss.jfrog.org"
269234

@@ -287,13 +252,11 @@ if (rootProject.hasProperty("releaseMode")) {
287252
}
288253

289254
if ("full".equals(rootProject.releaseMode)) {
290-
apply plugin: "com.vanniktech.maven.publish"
291-
292255
fixPom()
293256

294257
signing {
295-
if (project.hasProperty('SIGNING_PRIVATE_KEY') && project.hasProperty('SIGNING_PASSWORD')) {
296-
useInMemoryPgpKeys(project.getProperty('SIGNING_PRIVATE_KEY'), project.getProperty('SIGNING_PASSWORD'))
258+
if (project.hasProperty("SIGNING_PRIVATE_KEY") && project.hasProperty("SIGNING_PASSWORD")) {
259+
useInMemoryPgpKeys(project.getProperty("SIGNING_PRIVATE_KEY"), project.getProperty("SIGNING_PASSWORD"))
297260
}
298261
}
299262
mavenPublish {

0 commit comments

Comments
 (0)