Skip to content

Commit 11ebae9

Browse files
author
Harrison Cole
committed
Modernise gradle build configuration.
1 parent 9e593c5 commit 11ebae9

File tree

1 file changed

+50
-36
lines changed

1 file changed

+50
-36
lines changed

build.gradle

Lines changed: 50 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,13 @@ import java.text.SimpleDateFormat
33
plugins {
44
id 'java'
55
id 'java-library'
6+
id 'jvm-test-suite'
67
id 'maven-publish'
78
id 'signing'
8-
id "biz.aQute.bnd.builder" version "6.2.0"
9-
id "io.github.gradle-nexus.publish-plugin" version "1.0.0"
9+
id 'groovy'
10+
id 'biz.aQute.bnd.builder' version '6.2.0'
11+
id 'io.github.gradle-nexus.publish-plugin' version '1.0.0'
12+
id 'com.github.ben-manes.versions' version '0.51.0'
1013
}
1114

1215
java {
@@ -53,60 +56,65 @@ repositories {
5356
mavenLocal()
5457
}
5558

56-
apply plugin: 'groovy'
57-
5859
jar {
5960
manifest {
6061
attributes('Automatic-Module-Name': 'org.dataloader',
61-
'-exportcontents': 'org.dataloader.*',
62-
'-removeheaders': 'Private-Package')
62+
'-exportcontents': 'org.dataloader.*',
63+
'-removeheaders': 'Private-Package')
6364
}
6465
}
6566

66-
def slf4jVersion = '1.7.30'
67-
def reactiveStreamsVersion = '1.0.3'
68-
6967
dependencies {
70-
api 'org.slf4j:slf4j-api:' + slf4jVersion
71-
api 'org.reactivestreams:reactive-streams:' + reactiveStreamsVersion
72-
73-
testImplementation 'org.slf4j:slf4j-simple:' + slf4jVersion
74-
testImplementation 'org.awaitility:awaitility:2.0.0'
75-
testImplementation "org.hamcrest:hamcrest:2.2"
76-
testImplementation 'io.projectreactor:reactor-core:3.6.6'
77-
testImplementation 'com.github.ben-manes.caffeine:caffeine:2.9.0'
78-
testImplementation platform('org.junit:junit-bom:5.10.2')
79-
testImplementation 'org.junit.jupiter:junit-jupiter-api'
80-
testImplementation 'org.junit.jupiter:junit-jupiter-params'
81-
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine'
82-
testImplementation 'io.projectreactor:reactor-core:3.6.6'
68+
api "org.slf4j:slf4j-api:$slf4j_version"
69+
api "org.reactivestreams:reactive-streams:$reactive_streams_version"
8370
}
8471

8572
task sourcesJar(type: Jar) {
8673
dependsOn classes
87-
classifier 'sources'
74+
archiveClassifier.set('sources')
8875
from sourceSets.main.allSource
8976
}
9077

91-
task javadocJar(type: Jar, dependsOn: javadoc) {
92-
classifier = 'javadoc'
93-
from javadoc.destinationDir
94-
}
95-
9678
javadoc {
9779
options.encoding = 'UTF-8'
9880
}
9981

82+
task javadocJar(type: Jar, dependsOn: javadoc) {
83+
archiveClassifier.set('javadoc')
84+
from javadoc.destinationDir
85+
}
86+
10087
artifacts {
10188
archives sourcesJar
10289
archives javadocJar
10390
}
10491

105-
test {
106-
testLogging {
107-
exceptionFormat = 'full'
92+
testing {
93+
suites {
94+
test {
95+
useJUnitJupiter(junit_version)
96+
dependencies {
97+
// Testing dependencies
98+
implementation platform("org.junit:junit-bom:$junit_version")
99+
implementation 'org.junit.jupiter:junit-jupiter-api'
100+
implementation 'org.junit.jupiter:junit-jupiter-params'
101+
implementation 'org.junit.jupiter:junit-jupiter-engine'
102+
implementation "org.slf4j:slf4j-simple:$slf4j_version"
103+
implementation "org.awaitility:awaitility:$awaitility_version"
104+
implementation "org.hamcrest:hamcrest:$hamcrest_version"
105+
implementation "io.projectreactor:reactor-core:$reactor_core_version"
106+
implementation "com.github.ben-manes.caffeine:caffeine:$caffeine_version"
107+
}
108+
109+
targets.configureEach {
110+
testTask.configure {
111+
testLogging {
112+
exceptionFormat = 'full'
113+
}
114+
}
115+
}
116+
}
108117
}
109-
useJUnitPlatform()
110118
}
111119

112120
publishing {
@@ -180,9 +188,15 @@ tasks.withType(PublishToMavenRepository) {
180188
dependsOn build
181189
}
182190

183-
184-
task myWrapper(type: Wrapper) {
185-
gradleVersion = '6.6.1'
186-
distributionUrl = "https://services.gradle.org/distributions/gradle-${gradleVersion}-all.zip"
191+
def isNonStable = { String version ->
192+
def stableKeyword = ['RELEASE', 'FINAL', 'GA'].any { it -> version.toUpperCase().contains(it) }
193+
def regex = /^[0-9,.v-]+(-r)?$/
194+
return !stableKeyword && !(version ==~ regex)
187195
}
188196

197+
// https://github.com/ben-manes/gradle-versions-plugin
198+
tasks.named("dependencyUpdates").configure {
199+
rejectVersionIf {
200+
isNonStable(it.candidate.version)
201+
}
202+
}

0 commit comments

Comments
 (0)