1
1
plugins {
2
2
id ' java'
3
- id ' com.github.johnrengelman.shadow ' version ' 8.1.0 '
3
+ id ' application '
4
4
id ' maven-publish'
5
5
id ' com.palantir.git-version' version ' 2.0.0'
6
6
}
@@ -10,18 +10,19 @@ group = 'com.conveyal'
10
10
version gitVersion()
11
11
12
12
java {
13
- sourceCompatibility = JavaVersion . VERSION_11
14
- targetCompatibility = JavaVersion . VERSION_11
13
+ toolchain {
14
+ languageVersion. set(JavaLanguageVersion . of(21 ))
15
+ }
15
16
}
16
17
17
18
jar {
18
- // For Java 11 Modules, specify a module name.
19
+ // For Java 11+ Modules, specify a module name.
19
20
// Do not create module-info.java until all our dependencies specify a module name.
20
21
// Main-Class BackendMain will start a local backend.
21
22
// Build-Jdk-Spec mimics a Maven manifest entry that helps us automatically install the right JVM.
22
23
// Implementation-X attributes are needed for ImageIO (used by Geotools) to initialize in some environments.
23
24
manifest {
24
- attributes ' Automatic-Module-Name' : ' com.conveyal.analysis ' ,
25
+ attributes ' Automatic-Module-Name' : ' com.conveyal.r5 ' ,
25
26
' Main-Class' : ' com.conveyal.analysis.BackendMain' ,
26
27
' Build-Jdk-Spec' : targetCompatibility. getMajorVersion(),
27
28
' Implementation-Title' : ' Conveyal Analysis Backend' ,
@@ -30,18 +31,15 @@ jar {
30
31
}
31
32
}
32
33
33
- shadowJar {
34
- mergeServiceFiles()
35
- }
36
-
37
- // Allow reflective access by Kryo to normally closed Java internals.
38
- // This is used for testing equality, but also for building automatic Kryo (de)serializers.
34
+ // Allow reflective access by ObjectDiffer to normally closed Java internals. Used for round-trip testing serialization.
35
+ // IntelliJ seems not to pass these JVM arguments when running tests from within the IDE, so the Kryo serialization
36
+ // tests may only succeed under command line Gradle.
39
37
test {
38
+ useJUnitPlatform()
40
39
jvmArgs = [' --add-opens=java.base/java.io=ALL-UNNAMED' ,
41
40
' --add-opens=java.base/java.time=ALL-UNNAMED' ,
42
41
' --add-opens=java.base/java.time.zone=ALL-UNNAMED' ,
43
42
' --add-opens=java.base/java.lang=ALL-UNNAMED' ]
44
- useJUnitPlatform()
45
43
}
46
44
47
45
// `gradle publish` will upload both shadow and simple JAR to Github Packages
@@ -80,19 +78,25 @@ task copyDependencies(type: Copy) {
80
78
into ' dependencies'
81
79
}
82
80
81
+ application {
82
+ applicationDefaultJvmArgs = [' -Xmx6G' ]
83
+ mainClass = ' com.conveyal.analysis.BackendMain'
84
+ }
85
+
83
86
// Run R5 as a local analysis backend with all dependencies on the classpath, without building a shadowJar.
84
87
task runBackend (type : JavaExec ) {
85
- dependsOn(build)
86
- classpath(sourceSets. main. runtimeClasspath)
87
- mainClass = ' com.conveyal.analysis.BackendMain'
88
+ dependsOn(build)
89
+ maxHeapSize(' 7G' )
90
+ classpath(sourceSets. main. runtimeClasspath)
91
+ mainClass = ' com.conveyal.analysis.BackendMain'
88
92
}
89
93
90
- // Start up an analysis local backend from a shaded JAR and ask it to shut down immediately.
91
- // This is used to check in the automated build that the JAR is usable before we keep it.
94
+ // Start up an analysis local backend and ask it to shut down immediately.
95
+ // This is used to check in the automated build that the JAR is usable in end-to-end tests before we keep it.
92
96
// Create a configuration properties file (by copying the template) before running this task.
93
- task testShadowJarRunnable (type : JavaExec ) {
94
- dependsOn(shadowJar )
95
- classpath(shadowJar . archiveFile . get() )
97
+ task testRunnable (type : JavaExec ) {
98
+ dependsOn(build )
99
+ classpath(sourceSets . main . runtimeClasspath )
96
100
mainClass = ' com.conveyal.analysis.BackendMain'
97
101
jvmArgs(" -Dconveyal.immediate.shutdown=true" )
98
102
}
@@ -116,6 +120,12 @@ task createVersionProperties(dependsOn: processResources) {
116
120
}
117
121
}
118
122
123
+ // Fix inconsistent Gradle behavior (see https://github.com/gradle/gradle/issues/16791)
124
+ // By default JavaExec tasks use the JVM Gradle was launched with, ignoring the project-level toolchain.
125
+ tasks. withType(JavaExec ). configureEach {
126
+ javaLauncher. set(javaToolchains. launcherFor(java. toolchain))
127
+ }
128
+
119
129
classes {
120
130
dependsOn createVersionProperties
121
131
}
@@ -136,10 +146,10 @@ configurations.all {
136
146
137
147
dependencies {
138
148
// Provides our logging API
139
- implementation ' org.slf4j:slf4j-api:1.7.30 '
149
+ implementation ' org.slf4j:slf4j-api:2.0.7 '
140
150
141
151
// Implementation of the logging API
142
- implementation ' ch.qos.logback:logback-classic:1.2.3 '
152
+ implementation ' ch.qos.logback:logback-classic:1.4.11 '
143
153
144
154
// Spark is an HTTP framework built on Jetty. Its name is the same as several other projects.
145
155
implementation (group : ' com.sparkjava' , name : ' spark-core' , version : ' 2.7.2' ) {
@@ -195,9 +205,6 @@ dependencies {
195
205
// Commons IO gives us BOMInputStream for handling UTF-8 Byte Order Marks.
196
206
implementation ' commons-io:commons-io:2.6'
197
207
198
- // Guava provides a lot of functionality, collections, and tools "missing" from the Java standard library.
199
- implementation ' com.google.guava:guava:28.2-jre'
200
-
201
208
// Java 8 rewrite of the Guava cache with asynchronous LoadingCaches. We don't currently use the async
202
209
// capabilities, but Caffeine's LoadingCache syntax is more modern idiomatic Java than Guava's.
203
210
implementation ' com.github.ben-manes.caffeine:caffeine:2.8.1'
@@ -214,15 +221,19 @@ dependencies {
214
221
// Commons Math gives us FastMath, MersenneTwister, and low-discrepancy vector generators.
215
222
implementation ' org.apache.commons:commons-math3:3.0'
216
223
217
- // Provides some shared serializers for Kryo. Introduces transitive dependencies on Guava, Trove, and Kryo .
224
+ // Provides some Kryo serializers for Guava and Trove collecitons .
218
225
// Also provides classes for testing that a round trip through serialization reproduces the same network.
219
226
// This is an external dependency (not merged into backend) because it's also used by OTP2.
220
- // TODO arguably we should declare non-transitive dependencies on Guava, Trove, and Kryo since we use them directly
221
- implementation ' com.conveyal:kryo-tools:1.3.0'
227
+ implementation ' com.conveyal:kryo-tools:1.6.0'
222
228
229
+ // Ensure the versions of the next three dependencies match the transitive dependencies of kryo-tools.
230
+ implementation ' com.esotericsoftware:kryo:5.5.0'
231
+ // Guava provides a lot of functionality, collections, and tools "missing" from the Java standard library.
232
+ implementation ' com.google.guava:guava:32.1.2-jre'
223
233
// Trove supplies very efficient collections of primitive data types for Java.
224
234
implementation ' net.sf.trove4j:trove4j:3.0.3'
225
235
236
+
226
237
// TODO eliminate custom Conveyal geojson library, use Geotools?
227
238
implementation ' com.conveyal:jackson2-geojson:0.9'
228
239
@@ -245,8 +256,7 @@ dependencies {
245
256
// //// Test-only dependencies //////
246
257
247
258
// Java unit testing framework.
248
- testImplementation(platform(' org.junit:junit-bom:5.7.0' ))
249
- testImplementation(' org.junit.jupiter:junit-jupiter' )
259
+ testImplementation(' org.junit.jupiter:junit-jupiter:5.9.2' )
250
260
251
261
// Chart drawing library for examining travel time distributions when crafting tests.
252
262
// Although rarely used it should be low-impact: it is a test-only dependency with no transitive dependenices.
0 commit comments