Skip to content

Commit

Permalink
Update to use Java 17 (#1315)
Browse files Browse the repository at this point in the history
* Update to use Java 17
* change to gradle 8.0.2
* minor changes to support java 17
* remove test module configuration and use gradle test platform instead
* update configuration reference from defalt -> runtimeClasspath, also change some 11's to 17s
* remove broken proguard stuff
  • Loading branch information
lbergelson authored Sep 29, 2023
1 parent 396c7e2 commit 227302e
Show file tree
Hide file tree
Showing 16 changed files with 254 additions and 327 deletions.
13 changes: 7 additions & 6 deletions .github/workflows/gradle_test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,14 @@ jobs:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- name: Set up JDK 11
uses: actions/setup-java@v1
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: 11
java-version: 17
distribution: temurin
- name: Cache Gradle packages
uses: actions/cache@v2
uses: actions/cache@v3
with:
path: |
~/.gradle/caches
Expand All @@ -30,4 +31,4 @@ jobs:
# Restoring these files from a GitHub Actions cache might cause problems for future builds.
run: |
rm -f ~/.gradle/caches/modules-2/modules-2.lock
rm -f ~/.gradle/caches/modules-2/gc.properties
rm -f ~/.gradle/caches/modules-2/gc.properties
100 changes: 32 additions & 68 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -27,26 +27,25 @@ apply plugin: 'application'

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

//import proguard.gradle.ProGuardTask

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

// Build sourceset for ProGuard
buildscript {
repositories {
mavenCentral()
}
dependencies {
[group: 'net.sf.proguard', name: 'proguard-gradle', version: '6.1.1']
classpath 'net.sf.proguard:proguard-gradle:6.1.1'
}
}

repositories {
mavenCentral()
}

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

sourceSets {
main {
resources {
Expand Down Expand Up @@ -128,10 +127,13 @@ dependencies {
)

testImplementation(
[group: 'junit', name: 'junit', version: '4.12'],
[group: 'junit', name: 'junit', version: '4.13'],
[group: 'com.sparkjava', name: 'spark-core', version: '2.2'],
[group: 'org.glassfish.jersey.core', name: 'jersey-common', version: '2.22.4']
)
testRuntimeOnly(
[group: 'org.junit.vintage', name:'junit-vintage-engine', version:'5.8.2']
)
}


Expand Down Expand Up @@ -179,35 +181,7 @@ tasks.withType(Test) {
systemProperties['org.xerial.snappy.tempdir'] = 'build/tmp'
maxHeapSize = '2g'
maxParallelForks = Runtime.runtime.availableProcessors().intdiv(2) ?: 1
}

compileTestJava {
inputs.property("moduleName", moduleName)
doFirst {
options.compilerArgs = [
'--module-path', classpath.asPath,
'--add-modules', 'junit',
'--patch-module', "$moduleName=" + files(sourceSets.test.java.srcDirs).asPath,
]
classpath = files()
}
}

test {
inputs.property("moduleName", moduleName)

doFirst {
jvmArgs = [
'-Dcom.sun.xml.bind.v2.bytecode.ClassTailor.noOptimize',
'--module-path', classpath.asPath,
'--add-modules', 'junit',
'--add-modules', 'ALL-MODULE-PATH',
'--add-reads', "$moduleName=junit",
'@scripts/test_suite.args',
'--patch-module', "$moduleName=" + files(sourceSets.test.java.outputDir, sourceSets.main.output.resourcesDir).asPath,
]
classpath = files()
}
useJUnitPlatform()
}

task createDist(type: Copy, dependsOn: jar) {
Expand All @@ -229,10 +203,11 @@ task createDist(type: Copy, dependsOn: jar) {
}
// Copies all Maven-fetched dependency jars
with copySpec {
from configurations.default {
from configurations.runtimeClasspath {
exclude '**/*log4j*.jar'
}
into "lib"
duplicatesStrategy DuplicatesStrategy.EXCLUDE
}
with copySpec { from("genomes/sizes") {} into "lib/genomes" }

Expand All @@ -244,32 +219,32 @@ tasks.distTar.enabled = false
tasks.startScripts.enabled = false

task createDistZip(type: Zip, dependsOn: createDist) {
archiveName = "IGV_${version}.zip"
archiveFileName = "IGV_${archiveVersion}.zip"
from("${buildDir}/IGV-dist")
into "IGV_${version}"
into "IGV_${archiveVersion}"
}

task createLinuxDistZip(type: Zip, dependsOn: createDist) {
archiveName = "IGV_Linux_${version}.zip"
archiveFileName = "IGV_Linux_${archiveVersion}.zip"
from("${buildDir}/IGV-dist") {
exclude "*.bat"
exclude "*.command"
exclude 'igvtools*'
exclude 'lib/genomes'
}
into "IGV_Linux_${version}"
into "IGV_Linux_${archiveVersion}"
}

task createLinuxWithJavaDistZip(type: Zip, dependsOn: createDist) {
archiveName = "IGV_Linux_${version}_WithJava.zip"
with copySpec { from jdkBundleLinux into "jdk-11" }
archiveFileName = "IGV_Linux_${archiveVersion}_WithJava.zip"
with copySpec { from jdkBundleLinux into "jdk-17" }
from("${buildDir}/IGV-dist") {
exclude "*.bat"
exclude "*.command"
exclude 'igvtools*'
exclude 'lib/genomes'
}
into "IGV_Linux_${version}"
into "IGV_Linux_${archiveVersion}"
doLast {
if (jdkBundleLinux == "") {
throw new GradleException("Required property not set: jdkBundleLinux");
Expand All @@ -278,26 +253,27 @@ task createLinuxWithJavaDistZip(type: Zip, dependsOn: createDist) {
}

task createMacDistZip(type: Zip, dependsOn: createDist) {
archiveName = "IGV_Mac_${version}.zip"
archiveFileName = "IGV_Mac_${archiveVersion}.zip"
from("${buildDir}/IGV-dist") {
exclude "*.bat"
exclude "*_hidpi*"
exclude "igvtools*"
exclude 'lib/genomes'
}
into "IGV_Mac_${version}"

into "IGV_Mac_${archiveVersion}"
}

task createMacWithJavaDistZip(type: Zip, dependsOn: createDist) {
archiveName = "IGV_Mac_${version}_WithJava.zip"
with copySpec { from jdkBundleMac into "jdk-11" }
archiveFileName = "IGV_Mac_${archiveVersion}_WithJava.zip"
with copySpec { from jdkBundleMac into "jdk-17" }
from("${buildDir}/IGV-dist") {
exclude "*.bat"
exclude "*_hidpi*"
exclude "igvtools*"
exclude 'lib/genomes'
}
into "IGV_Mac_${version}"
into "IGV_Mac_${archiveVersion}"
doLast {
if (jdkBundleMac == "") {
throw new GradleException("Required property not set: jdkBundleMac");
Expand Down Expand Up @@ -339,7 +315,7 @@ task createMacAppDist(type: Copy, dependsOn: createDist) {
}

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

doLast {
Expand All @@ -348,8 +324,8 @@ task createMacAppDistZip(type: Zip, dependsOn: createMacAppDist) {
}

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

doLast {
Expand Down Expand Up @@ -383,7 +359,7 @@ task createWinDist(type: Copy, dependsOn: createDist) {
}

task createWinWithJavaDist(type: Copy, dependsOn: createWinDist) {
with copySpec { from jdkBundleWindows into "IGV_${version}/jdk-11" }
with copySpec { from jdkBundleWindows into "IGV_${version}/jdk-17" }
with copySpec {
from("${buildDir}/IGV-WinExe-dist/IGV_${version}") { exclude 'installer.nsi' }
into "IGV_${version}"
Expand Down Expand Up @@ -465,7 +441,8 @@ task fullJar(type: Jar, dependsOn: jar) {
"Application-Name": "IGV",
"Built-By": System.getProperty('user.name'),
"Main-Class": mainClassName,
"Class-Path": configurations.default.collect { it.getName() }.join(' ')

"Class-Path": configurations.runtimeClasspath.collect { it.getName() }.join(' ')
)
}
}
Expand All @@ -475,16 +452,3 @@ task fullJar(type: Jar, dependsOn: jar) {
//if (!makensisCommand == "" && !signcodeCommand == "") {
// dependsOn signWinExeDist
//}

// XXX: META-INF versions support (Java11) seem to clash with proguard at this point in time:
// https://sourceforge.net/p/proguard/bugs/665/
// https://sourceforge.net/p/proguard/discussion/182456/thread/8c56b22dc2/?limit=25
//task myproguard(type: ProGuardTask) {
//// configuration 'proguard.txt'
//
// injars "${buildDir}/IGV-dist/lib"
// outjars "${buildDir}/libs/igv-proguard.jar"
//
// //libraryjars "${buildDir}/IGV-dist/lib", jarfilter:"lib/**.jar(!META-INF/**)"
// //libraryjars "${System.getProperty('java.home')}/lib/rt.jar"
//}
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
3 changes: 2 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.5.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit 227302e

Please sign in to comment.