Skip to content

Commit

Permalink
eliminate shadow JAR (was causing build failures)
Browse files Browse the repository at this point in the history
shadow jars defy intended Java design and are essentially obsolete
instead set up Gradle to run application with the JARs on the classpath
will require changing end-to-end/UI testing to use 'gradle runBackend'
  • Loading branch information
abyrd committed Jan 13, 2023
1 parent 2a41a9d commit 38fd1eb
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
5 changes: 3 additions & 2 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,11 @@ jobs:
run: gradle -q printVersion | head -n1
- name: Build and test
run: gradle build
- name: Ensure shadow JAR is runnable as local backend
# Check that build product is able to start up as a backend server before handing it to end-to-end testing
- name: Ensure backend runnable
run: |
cp analysis.properties.template analysis.properties
gradle testShadowJarRunnable
gradle testRunnable -x test
- name: Publish to GH Packages
# Supply access token to build.gradle (used in publishing.repositories.maven.credentials)
env:
Expand Down
29 changes: 14 additions & 15 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
plugins {
id 'java'
id 'com.github.johnrengelman.shadow' version '6.0.0'
id 'application'
id 'maven-publish'
id 'com.palantir.git-version' version '0.12.3'
}
Expand All @@ -13,8 +13,6 @@ java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(19))
}
// sourceCompatibility = JavaVersion.VERSION_19
// targetCompatibility = JavaVersion.VERSION_19
}

jar {
Expand All @@ -33,10 +31,6 @@ jar {
}
}

shadowJar {
mergeServiceFiles()
}

// Allow reflective access by Kryo to normally closed Java internals.
// This is used for testing equality, but also for building automatic Kryo (de)serializers.
test {
Expand Down Expand Up @@ -81,19 +75,24 @@ task copyDependencies(type: Copy) {
into 'dependencies'
}

application {
applicationDefaultJvmArgs = ['-Xmx4G']
mainClass = 'com.conveyal.analysis.BackendMain'
}

// Run R5 as a local analysis backend with all dependencies on the classpath, without building a shadowJar.
task runBackend (type: JavaExec) {
dependsOn(build)
classpath(sourceSets.main.runtimeClasspath)
main("com.conveyal.analysis.BackendMain")
dependsOn(build)
classpath(sourceSets.main.runtimeClasspath)
main("com.conveyal.analysis.BackendMain")
}

// Start up an analysis local backend from a shaded JAR and ask it to shut down immediately.
// This is used to check in the automated build that the JAR is usable before we keep it.
// Start up an analysis local backend and ask it to shut down immediately.
// This is used to check in the automated build that the JAR is usable in end-to-end tests before we keep it.
// Create a configuration properties file (by copying the template) before running this task.
task testShadowJarRunnable(type: JavaExec) {
dependsOn(shadowJar)
classpath(shadowJar.archiveFile.get())
task testRunnable(type: JavaExec) {
dependsOn(build)
classpath(sourceSets.main.runtimeClasspath)
main("com.conveyal.analysis.BackendMain")
jvmArgs("-Dconveyal.immediate.shutdown=true")
}
Expand Down

0 comments on commit 38fd1eb

Please sign in to comment.