Skip to content

Commit

Permalink
Update to Java 21 and gradle 8.10.1 (#1568)
Browse files Browse the repository at this point in the history
* Update to Java 21 and gradle 8.10.1

* Move from Java 17 -> Java 21
* Update from gradle 8.0.2 -> 8.10.1
  * Replace some deprecated gradle code with newer styles
  * Something changed in the module resolution with this update which caused us to not be able to
    resolve automatic modules.
  * Introduced a new gradle plugin which fixes the problem and removed the manual module
    path manipulation we were doing.

* update github actions
  • Loading branch information
lbergelson authored Sep 13, 2024
1 parent e8e38e1 commit e658784
Show file tree
Hide file tree
Showing 6 changed files with 71 additions and 64 deletions.
18 changes: 4 additions & 14 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,10 @@ jobs:

steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '17'
java-version: '21'
distribution: 'temurin'

# Configure Gradle for optimal use in GitHub Actions, including caching of downloaded dependencies.
Expand All @@ -36,16 +36,6 @@ jobs:
- name: Test with Gradle Wrapper
run: ./gradlew test

# NOTE: The Gradle Wrapper is the default and recommended way to run Gradle (https://docs.gradle.org/current/userguide/gradle_wrapper.html).
# If your project does not have the Gradle Wrapper configured, you can use the following configuration to run Gradle with a specified version.
#
# - name: Setup Gradle
# uses: gradle/actions/setup-gradle@417ae3ccd767c252f5661f1ace9f835f9654f2b5 # v3.1.0
# with:
# gradle-version: '8.5'
#
# - name: Build with Gradle 8.5
# run: gradle build

dependency-submission:

Expand All @@ -55,10 +45,10 @@ jobs:

steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: '17'
java-version: '21'
distribution: 'temurin'

# Generates and submits a dependency graph, enabling Dependabot Alerts for all project dependencies.
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ at [http://software.broadinstitute.org/software/igv/download](http://software.br

Builds are executed from the IGV project directory. Files will be created in the 'build' subdirectory.

IGV requires **Java 17** to build and run. Later versions of Java should work but we build and test on **Java 17**.
IGV requires **Java 21** to build and run. Later versions of Java should work but we build and test on **Java 21**.

NOTE: If on a Windows platform use ```./gradlew.bat'``` in the instructions below

Expand Down
109 changes: 63 additions & 46 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,29 +21,34 @@
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.

apply plugin: 'java'
apply plugin: 'maven-publish'
apply plugin: 'application'

import org.apache.tools.ant.filters.ReplaceTokens

mainClassName = 'org.broad.igv.ui.Main'
ext.moduleName = 'org.igv'

buildscript {
repositories {
mavenCentral()
}
}

plugins {
id('java')
id('maven-publish')
id('application')
id("org.gradlex.extra-java-module-info") version("1.8")
}

repositories {
mavenCentral()
mavenLocal()
}

import org.apache.tools.ant.filters.ReplaceTokens

application {
mainClass = 'org.broad.igv.ui.Main'
mainModule = 'org.igv'
}

java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
languageVersion = JavaLanguageVersion.of(21)
}
}

Expand All @@ -56,6 +61,10 @@ sourceSets {
}
}

extraJavaModuleInfo {
deriveAutomaticModuleNamesFromFileNames.set(true)
}

configurations {
implementation {
exclude group: 'com.google.code.findbugs', module: 'annotations'
Expand Down Expand Up @@ -130,12 +139,16 @@ dependencies {
)

testImplementation(
[group: 'junit', name: 'junit', version: '4.13.1'],
[group: 'junit', name: 'junit', version: '4.13.2'],
[group: 'com.sparkjava', name: 'spark-core', version: '2.9.4'],
[group: 'org.glassfish.jersey.core', name: 'jersey-common', version: '2.34']
)
testRuntimeOnly(
[group: 'org.junit.vintage', name:'junit-vintage-engine', version:'5.8.2']
[group: 'org.junit.vintage', name:'junit-vintage-engine', version:'5.8.2'] ,
//required by gradle 9+
//see https://docs.gradle.org/8.10.1/userguide/upgrading_version_8.html#test_framework_implementation_dependencies
[group: 'org.junit.platform', name:'junit-platform-launcher']

)
}

Expand All @@ -160,7 +173,7 @@ jar {
"Permissions": "all-permissions",
"Application-Name": "IGV",
"Built-By": System.getProperty('user.name'),
"Main-Class": mainClassName,
"Main-Class": application.mainClass,
)
}
}
Expand All @@ -169,18 +182,9 @@ tasks.withType(JavaCompile).configureEach {
options.encoding = 'UTF-8'
}

compileJava {
inputs.property("moduleName", moduleName)
doFirst {
options.compilerArgs = [
'--module-path', classpath.asPath,
]
classpath = files()
}
}

tasks.withType(Test) {
systemProperties = System.getProperties()
tasks.withType(Test).configureEach {
systemProperties.clear()
systemProperties.putAll( System.getProperties() )
systemProperties['java.awt.headless'] = 'true'
systemProperties['make.fail'] = 'false'
systemProperties['include.longrunning'] = 'false'
Expand All @@ -191,7 +195,8 @@ tasks.withType(Test) {
useJUnitPlatform()
}

task createDist(type: Copy, dependsOn: jar) {
tasks.register('createDist', Copy) {
dependsOn jar
from("web/IGV_64.png")
from("scripts") {
include '*.bat'
Expand All @@ -204,14 +209,14 @@ task createDist(type: Copy, dependsOn: jar) {
with copySpec {
from("${buildDir}/libs")
from("lib") {
include '*.jar'
include '*.jar'
}
into "lib"
}
// Copies all Maven-fetched dependency jars
with copySpec {
from configurations.runtimeClasspath {
exclude '**/*log4j*.jar'
exclude '**/*log4j*.jar'
}
into "lib"
duplicatesStrategy DuplicatesStrategy.EXCLUDE
Expand All @@ -226,14 +231,16 @@ tasks.distTar.enabled = false
tasks.startScripts.enabled = false

// Create the platform agnostic zip distribution
task createDistZip(type: Zip, dependsOn: createDist) {
tasks.register('createDistZip', Zip) {
dependsOn createDist
archiveFileName = "IGV_${version}.zip"
from("${buildDir}/IGV-dist")
into "IGV_${version}"
}

// Create a linux distribution for IGV , excluding igvtools. Basically identical to generic dist without window and mac scripts
task createLinuxDistZip(type: Zip, dependsOn: createDist) {
tasks.register('createLinuxDistZip', Zip) {
dependsOn createDist
archiveFileName = "IGV_Linux_${version}.zip"
from("${buildDir}/IGV-dist") {
exclude "*.bat"
Expand All @@ -245,9 +252,10 @@ task createLinuxDistZip(type: Zip, dependsOn: createDist) {
}

// Create a linux distrubtion with bundled Java
task createLinuxWithJavaDistZip(type: Zip, dependsOn: createDist) {
tasks.register('createLinuxWithJavaDistZip', Zip) {
dependsOn createDist
archiveFileName = "IGV_Linux_${version}_WithJava.zip"
with copySpec { from jdkBundleLinux into "jdk-17" }
with copySpec { from jdkBundleLinux into "jdk-21" }
from("${buildDir}/IGV-dist") {
exclude "*.bat"
exclude "*.command"
Expand All @@ -262,7 +270,8 @@ task createLinuxWithJavaDistZip(type: Zip, dependsOn: createDist) {
}
}

task createMacDistZip(type: Zip, dependsOn: createDist) {
tasks.register('createMacDistZip', Zip) {
dependsOn createDist
archiveFileName = "IGV_MacApp_${version}.zip"
from("${buildDir}/IGV-dist") {
exclude "*.bat"
Expand All @@ -274,9 +283,10 @@ task createMacDistZip(type: Zip, dependsOn: createDist) {
into "IGV_MacApp_${version}"
}

task createMacWithJavaDistZip(type: Zip, dependsOn: createDist) {
tasks.register('createMacWithJavaDistZip', Zip) {
dependsOn createDist
archiveFileName = "IGV_MacApp_${version}_WithJava.zip"
with copySpec { from jdkBundleMac into "jdk-17" }
with copySpec { from jdkBundleMac into "jdk-21" }
from("${buildDir}/IGV-dist") {
exclude "*.bat"
exclude "*_hidpi*"
Expand All @@ -291,7 +301,8 @@ task createMacWithJavaDistZip(type: Zip, dependsOn: createDist) {
}
}

task createMacAppDist(type: Copy, dependsOn: createDist) {
tasks.register('createMacAppDist', Copy) {
dependsOn createDist
with copySpec {
from("scripts/mac.app") {
exclude "Contents/Info.plist.template"
Expand Down Expand Up @@ -324,18 +335,20 @@ task createMacAppDist(type: Copy, dependsOn: createDist) {
}
}

task createMacAppDistZip(type: Zip, dependsOn: createMacAppDist) {
archiveFileName = "IGV_MacApp_${version}.zip"
tasks.register('createMacAppDistZip', Zip) {
dependsOn createMacAppDist
archiveFileName = "IGV_MacApp_${version}.zip"
from("${buildDir}/IGV-MacApp-dist")

doLast {
//project.exec { commandLine('chmod', '775', createMacAppDistZip.archiveFileName) }
}
}

task createMacAppWithJavaDistZip(type: Zip, dependsOn: createMacAppDist) {
tasks.register('createMacAppWithJavaDistZip', Zip) {
dependsOn createMacAppDist
archiveFileName = "IGV_MacApp_${version}_WithJava.zip"
with copySpec { from jdkBundleMac into "IGV_${version}.app/Contents/jdk-17" }
with copySpec { from jdkBundleMac into "IGV_${version}.app/Contents/jdk-21" }
from("${buildDir}/IGV-MacApp-dist")

doLast {
Expand Down Expand Up @@ -368,8 +381,9 @@ task createWinDist(type: Copy, dependsOn: createDist) {
into "${buildDir}/IGV-WinExe-dist"
}

task createWinWithJavaDist(type: Copy, dependsOn: createWinDist) {
with copySpec { from jdkBundleWindows into "IGV_${version}/jdk-17" }
tasks.register('createWinWithJavaDist', Copy) {
dependsOn createWinDist
with copySpec { from jdkBundleWindows into "IGV_${version}/jdk-21" }
with copySpec {
from("${buildDir}/IGV-WinExe-dist/IGV_${version}") { exclude 'installer.nsi' }
into "IGV_${version}"
Expand All @@ -388,7 +402,8 @@ task createWinWithJavaDist(type: Copy, dependsOn: createWinDist) {
}
}

task createWinExeDist(type: Exec, dependsOn: createWinDist) {
tasks.register('createWinExeDist', Exec) {
dependsOn createWinDist
commandLine(makensisCommand, "-O${buildDir}/tmp/nsis-WithJava-build.log",
"${buildDir}/IGV-WinExe-dist/installer.nsi")
doLast {
Expand All @@ -398,7 +413,8 @@ task createWinExeDist(type: Exec, dependsOn: createWinDist) {
}
}

task createWinWithJavaExeDist(type: Exec, dependsOn: createWinWithJavaDist) {
tasks.register('createWinWithJavaExeDist', Exec) {
dependsOn createWinWithJavaDist
commandLine(makensisCommand, "-O${buildDir}/tmp/nsis-build.log",
"${buildDir}/IGV-WinExe-WithJava-dist/installer.nsi")
doLast {
Expand All @@ -411,7 +427,8 @@ task createWinWithJavaExeDist(type: Exec, dependsOn: createWinWithJavaDist) {
}
}

task signWinExeDist(type: Exec, dependsOn: createWinExeDist) {
tasks.register('signWinExeDist', Exec) {
dependsOn createWinExeDist
standardInput = new ByteArrayInputStream(keyPassword.getBytes());
commandLine(signcodeCommand, "-spc", spcFile, "-v", pvkFile, "-a", "sha512",
"-\$", "commercial", "-n", "IGV ${version}", "-i", "http://www.igv.org/",
Expand Down Expand Up @@ -450,7 +467,7 @@ task fullJar(type: Jar, dependsOn: jar) {
"Permissions": "all-permissions",
"Application-Name": "IGV",
"Built-By": System.getProperty('user.name'),
"Main-Class": mainClassName,
"Main-Class": application.mainClass,

"Class-Path": configurations.runtimeClasspath.collect { it.getName() }.join(' ')
)
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.1-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
4 changes: 2 additions & 2 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -144,15 +144,15 @@ if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
case $MAX_FD in #(
max*)
# In POSIX sh, ulimit -H is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC3045
MAX_FD=$( ulimit -H -n ) ||
warn "Could not query maximum file descriptor limit"
esac
case $MAX_FD in #(
'' | soft) :;; #(
*)
# In POSIX sh, ulimit -n is undefined. That's why the result is checked to see if it worked.
# shellcheck disable=SC3045
# shellcheck disable=SC3045
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down

0 comments on commit e658784

Please sign in to comment.