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

Upgrade to Java 17. #1833

Merged
merged 18 commits into from
Feb 14, 2023
Merged

Upgrade to Java 17. #1833

merged 18 commits into from
Feb 14, 2023

Conversation

cmnbroad
Copy link
Contributor

@cmnbroad cmnbroad commented Oct 4, 2022

Upgrades to Java 17 and gradle 7.5.1. Changes the docker to use eclipse-temurin:17-jdk as a base image (??). Uses https://github.com/openjdk/nashorn (GPL-2.0 license) as a temporary replacement for the deprecated builtin Nashorn script engine until we settle on a permanent replacement.

Als fixes #1840.

@cmnbroad cmnbroad force-pushed the cn_java_17 branch 2 times, most recently from c25c230 to cd7e6b7 Compare October 4, 2022 15:03
build.gradle Outdated
implementation 'org.apache.logging.log4j:log4j-api:2.17.1'
implementation 'org.apache.logging.log4j:log4j-core:2.17.1'

// replacement for jdk nashorn engine GPL-2.0 license
Copy link
Member

Choose a reason for hiding this comment

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

nashorn is gpl with the classpath exception so it shouldn't be an issue

"
As a special exception, the copyright holders of this library give you
permission to link this library with independent modules to produce an
executable, regardless of the license terms of these independent modules,
and to copy and distribute the resulting executable under terms of your
choice, provided that you also meet, for each linked independent module,
the terms and conditions of the license of that module. An independent
module is a module which is not derived from or based on this library. If
you modify this library, you may extend this exception to your version of
the library, but you are not obligated to do so. If you do not wish to do
so, delete this exception statement from your version."

Copy link
Member

Choose a reason for hiding this comment

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

I would remove this note, alternatively amend it to specify that it's GPL with classpath exception so that there is no issue using it with non-gpl software.

implementation 'org.openjdk.nashorn:nashorn-core:15.4'

//NOTE: this dependency spec causes doc gen to fail on FingerPrintChecker since doc gen is not
// a compile time task
compileOnly(googleNio)
Copy link
Member

Choose a reason for hiding this comment

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

Do we know what configuraton javadoc uses by default? I'm sure we can set the javadoc task to use the compile configuration if necessary.

@@ -111,8 +100,14 @@ configurations.all {
}
}

sourceCompatibility = 1.8
targetCompatibility = 1.8
sourceCompatibility = 1.17
Copy link
Member

Choose a reason for hiding this comment

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

We should think about moving to toolchain definitions.

@@ -10,7 +8,7 @@ buildscript {

plugins {
id "java"
Copy link
Member

Choose a reason for hiding this comment

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

We might want to migrate to java-library instead of plain java so we support the API configuration.

build.gradle Outdated

run {
jvmArgs = [
'--add-opens', 'java.base/java.io=ALL-UNNAMED'
Copy link
Member

Choose a reason for hiding this comment

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

What in picard is requiring this? Is there any way we can avoid it? I feel like this requirement is going to cause a ton of confusion for picard users.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

MergeBamAlignmentTest - I've changed it now so its only for test tasks.

Copy link
Member

Choose a reason for hiding this comment

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

Seems fine for tests.

README.md Outdated
@@ -17,8 +17,7 @@ Picard is implemented using the HTSJDK Java library [HTSJDK][1] to support
accessing file formats that are commonly used for high-throughput
sequencing data such as [SAM][2] and [VCF][3].

Picard now builds and passes tests under Java 11. This should be considered to be a *Beta* feature.
As of version 2.0.1 (Nov. 2015) Picard requires Java 1.8 (jdk8u66). The last version to support Java 1.7 was release 1.141.
As of version 3.0 (Nov. 2022) Picard requires Java 1.17.
Copy link
Member

Choose a reason for hiding this comment

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

We need to remember to bump this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Wow, that is way off.

@cmnbroad cmnbroad marked this pull request as ready for review February 7, 2023 17:30
Copy link
Member

@lbergelson lbergelson left a comment

Choose a reason for hiding this comment

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

@cmnbroad A few minor issues plus a lot of rambling about how we can improve the gradle file in the future. Good to merge when the comments are resolved!

experimental: [false]
run_barclay_tests: [true, false]
# include:
# - java: 17
# experimental: true
fail-fast: false
Copy link
Member

Choose a reason for hiding this comment

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

This is my doing, but I noticed because of your change below, can we switch the java installation to temurin instead of `adopt?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done.

throw new GradleException(
"Java 8 or later is required to build Picard, but ${JavaVersion.current()} was found. "
+ "$buildPrerequisitesMessage")
if (!JavaVersion.current().equals(JavaVersion.VERSION_17)) {
Copy link
Member

Choose a reason for hiding this comment

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

Much simpler now. It will be even simpler when we switch to toolchains.

@@ -68,40 +60,37 @@ ensureBuildPrerequisites(buildPrerequisitesMessage)
final htsjdkVersion = System.getProperty('htsjdk.version', '3.0.1')
final googleNio = 'com.google.cloud:google-cloud-nio:0.123.25'

// Get the jdk files we need to run javaDoc. We need to use these during compile, testCompile,
// test execution, and gatkDoc generation, but we don't want them as part of the runtime
// classpath and we don't want to redistribute them in the uber jar.
Copy link
Member

Choose a reason for hiding this comment

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

yay

build.gradle Outdated
implementation 'org.apache.logging.log4j:log4j-api:2.17.1'
implementation 'org.apache.logging.log4j:log4j-core:2.17.1'

// replacement for jdk nashorn engine GPL-2.0 license
Copy link
Member

Choose a reason for hiding this comment

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

I would remove this note, alternatively amend it to specify that it's GPL with classpath exception so that there is no issue using it with non-gpl software.

build.gradle Outdated

run {
jvmArgs = [
'--add-opens', 'java.base/java.io=ALL-UNNAMED'
Copy link
Member

Choose a reason for hiding this comment

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

Seems fine for tests.

build.gradle Outdated
password = project.findProperty("sonatypePassword")
}
}
maven {
Copy link
Member

Choose a reason for hiding this comment

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

Does this work? In gatk / htsjdk we do this:


    repositories {
        maven {
            credentials {
                username = isRelease ? project.findProperty("sonatypeUsername") : System.env.ARTIFACTORY_USERNAME
                password = isRelease ? project.findProperty("sonatypePassword") : System.env.ARTIFACTORY_PASSWORD
            }
            def release = "https://oss.sonatype.org/service/local/staging/deploy/maven2/"
            def snapshot = "https://broadinstitute.jfrog.io/broadinstitute/libs-snapshot-local/"
            url = isRelease ? release : snapshot
        }
    }

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'll give it a test and see what happens.


// Run javadoc in the current JVM with the custom doclet, and make sure it succeeds (this is a smoke test;
// we just want to make sure it doesn't blow up).
ToolProvider jdProvider = null;
Copy link
Member

Choose a reason for hiding this comment

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

Would it be cleaner to use ToolProvider.findFirst("javadoc")?

ToolProvider jdProvider = ToolProvider.findFirst("javadoc")
                .orElseThrow(() ->  new IllegalStateException("Can't find javadoc tool"));
``` ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, better. I need to remember to do this in GATK as well.

/**
* Entry point for manually running the picardDoc process on a subset of packages from within picard.
*/
private static String[] docTestPackages = {
Copy link
Member

Choose a reason for hiding this comment

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

We could probably fix this issue by re-arranging some things but lets not do it now.

"picard.metrics"
};

// suppress deprecation warning on Java 11 since we're using deprecated javadoc APIs
Copy link
Member

Choose a reason for hiding this comment

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

This note is out of date now?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Assert. assertEquals(retCode, 0);

final File outputDir = docTestTarget.toFile();
final Set pathNames = new HashSet<>(Arrays.stream(outputDir.list()).toList());
Copy link
Member

Choose a reason for hiding this comment

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

Set -> Set<String>

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

Copy link
Member

@lbergelson lbergelson left a comment

Choose a reason for hiding this comment

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

@cmnbroad Changes look good to me.

@lbergelson lbergelson merged commit 1944ab2 into master Feb 14, 2023
@lbergelson lbergelson deleted the cn_java_17 branch February 14, 2023 18:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

testBamToBfq output changed when switching from OpenJDK11 to OpenJDK17
2 participants