Skip to content

Commit

Permalink
add shadow jar configuration back to gradle build
Browse files Browse the repository at this point in the history
This started working again, so for consistency with past releases I
built and attached a shadow jar to the v7.0 release on github.
We may want to eventually remove this though: we do not use it in our
workflow but do use the zip distribution and gradle runBackend.
  • Loading branch information
abyrd committed Nov 22, 2023
1 parent 6363b28 commit 1bf792f
Showing 1 changed file with 15 additions and 8 deletions.
23 changes: 15 additions & 8 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ plugins {
id 'application'
id 'maven-publish'
id 'com.palantir.git-version' version '2.0.0'
id 'com.github.johnrengelman.shadow' version '8.1.1'
}

group = 'com.conveyal'
// set version to `git describe --tags --always --first-parent`, plus '.dirty' if local changes are present.
version gitVersion()
version 'v7.0' //gitVersion()

java {
toolchain {
Expand All @@ -19,7 +20,7 @@ jar {
// For Java 11+ Modules, specify a module name.
// Do not create module-info.java until all our dependencies specify a module name.
// Main-Class BackendMain will start a local backend.
// Build-Jdk-Spec mimics a Maven manifest entry that helps us automatically install the right JVM.
// Build-Jdk-Spec mimics a Maven manifest entry that helps us automatically install or select the right JVM.
// Implementation-X attributes are needed for ImageIO (used by Geotools) to initialize in some environments.
manifest {
attributes 'Automatic-Module-Name': 'com.conveyal.r5',
Expand All @@ -31,6 +32,10 @@ jar {
}
}

shadowJar {
mergeServiceFiles()
}

// Allow reflective access by ObjectDiffer to normally closed Java internals. Used for round-trip testing serialization.
// IntelliJ seems not to pass these JVM arguments when running tests from within the IDE, so the Kryo serialization
// tests may only succeed under command line Gradle.
Expand All @@ -42,8 +47,8 @@ test {
'--add-opens=java.base/java.lang=ALL-UNNAMED']
}

// `gradle publish` will upload both shadow and simple JAR to Github Packages
// On GH Actions, GITHUB_ACTOR env variable is supplied without specifying it in action yml.
// Set up publication of jar files to GitHub Packages Maven repository.
// On GitHub Actions, GITHUB_ACTOR env variable is supplied without specifying it in action yml.
publishing {
repositories {
maven {
Expand All @@ -56,10 +61,12 @@ publishing {
}
}
publications {
// The presence of the shadow plugin somehow causes the shadow-jar to also be automatically included in this
// publication. Ideally we want to produce the shadow jar and upload it to S3 as a worker, but only publish the
// much smaller plain JAR without dependencies to Github Packages. On the other hand, we may want to publish
// shadow jars for tagged releases.
// The shadow plugin automatically creates and registers a component called "shadow" for integration with this
// Maven publish plugin. `gradle publish` will then upload both shadow jar and simple jar to Github Packages.
// See https://imperceptiblethoughts.com/shadow/getting-started/#default-java-groovy-tasks
// To run R5 with dependencies, Conveyal does not use shadow jars anymore, only the zip distribution or runBackend.
// For development builds and tests we don't need to produce a shadow jar, only publish the much smaller plain
// jar without dependencies to Github Packages. For now, we continue to attach shadow jars to tagged releases.
gpr(MavenPublication) {
from(components.java)
}
Expand Down

0 comments on commit 1bf792f

Please sign in to comment.