Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update to use Java 17 #1315

Merged
merged 3 commits into from
Sep 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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']
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This test runtime dependency is the engine that runs junit4 tests since gradle seems to assume you're using 5 now.

)
}


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"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name changes are all to satisfy gradle deprecation complaints.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, looks good

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