Skip to content

Commit

Permalink
Update Gradle to 8.5 (#1930)
Browse files Browse the repository at this point in the history
* update to use configuration api
* remove no longer relevant bits about the parser settings
* update to automatically configure javadoc/source jars and the toolchain
  • Loading branch information
lbergelson authored Dec 19, 2023
1 parent e7f9a54 commit 5706839
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 59 deletions.
78 changes: 28 additions & 50 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,19 @@ dependencies {
testImplementation 'org.testng:testng:7.7.0'
}

configurations.all {
configurations.configureEach {
resolutionStrategy {
// force the htsjdk version so we don't get a different one transitively
force 'com.github.samtools:htsjdk:' + htsjdkVersion
}
}

java {
sourceCompatibility = 1.17
targetCompatibility = 1.17
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
withJavadocJar()
withSourcesJar()
}

final isRelease = Boolean.getBoolean("release")
Expand All @@ -104,20 +107,9 @@ group = 'com.github.broadinstitute'

defaultTasks 'all'

task all(dependsOn: ['jar', 'distZip', 'javadoc', 'shadowJar', 'currentJar', 'picardDoc'])

// Source file names for the picard command line properties file. We select and include only one of
// these two files in each jar, renamed to "picardCmdLine.properties", depending on which parser we
// want enabled.
final String legacySourcePropertyFile = 'legacyParserProperties.properties'
final String barclaySourcePropertyFile = 'barclayParserProperties.properties'

// Target name/location for the picard command line properties file; one of the above source
// files will be included at this path/location for runtime access
final String picardTargetPropertiesPath = 'picard'
final String picardTargetPropertyFile = 'picardCmdLine.properties'
tasks.register('all') { dependsOn 'jar', 'distZip', 'javadoc', 'shadowJar', 'currentJar', 'picardDoc' }

tasks.withType(Jar){
tasks.withType(Jar).configureEach {
manifest {
attributes 'Main-Class': 'picard.cmdline.PicardCommandLine',
'Implementation-Title': 'Picard',
Expand All @@ -128,7 +120,7 @@ tasks.withType(Jar){
}
}

tasks.withType(Javadoc) {
tasks.withType(Javadoc).configureEach {
// do this for all javadoc tasks, including gatkDoc
options.addStringOption('Xdoclint:none')
}
Expand All @@ -138,7 +130,8 @@ javadoc {
}

// Generate Picard Online Doc
task picardDoc(type: Javadoc, dependsOn: ['cleanPicardDoc', classes]) {
tasks.register('picardDoc', Javadoc) {
dependsOn 'cleanPicardDoc', classes
final File picardDocDir = file("build/docs/picarddoc")
doFirst {
// make sure the output folder exists or we can create it
Expand Down Expand Up @@ -176,10 +169,10 @@ task picardDoc(type: Javadoc, dependsOn: ['cleanPicardDoc', classes]) {
options.noTimestamp(false)
}

task currentJar(type: Copy){
tasks.register('currentJar', Copy) {
from shadowJar
into file("$buildDir/libs")
rename { string -> "picard.jar"}
rename { string -> "picard.jar" }
}

shadowJar {
Expand All @@ -188,13 +181,13 @@ shadowJar {

// Run the tests using the legacy parser only. Assumes that test code is written using
// legacy command line parser syntax.
task legacyTest(type: Test) {
tasks.register('legacyTest', Test) {
systemProperty 'picard.useLegacyParser', 'true'
}

// Run the tests using the Barclay command line parser (useLegacyParser=false), which requires
// conversion of test command lines from Picard-style command line syntax to Barclay-style syntax.
task barclayTest(type: Test) {
tasks.register('barclayTest', Test) {
systemProperty 'picard.convertCommandLine', 'true'
}

Expand All @@ -203,7 +196,7 @@ test {
dependsOn barclayTest
}

tasks.withType(Test) {
tasks.withType(Test).configureEach {
outputs.upToDateWhen { false } // tests will always rerun
description = "Runs the unit tests"

Expand All @@ -214,7 +207,7 @@ tasks.withType(Test) {

useTestNG {
List excludes = ["slow", "broken"]
if( !OperatingSystem.current().isUnix() ) {
if (!OperatingSystem.current().isUnix()) {
excludes << "unix"
}
String TEST_TYPE = "$System.env.TEST_TYPE"
Expand All @@ -239,8 +232,8 @@ tasks.withType(Test) {

beforeTest { descriptor ->
count++
if( count % 100 == 0) {
logger.lifecycle("Finished "+ Integer.toString(count++) + " tests")
if (count % 100 == 0) {
logger.lifecycle("Finished " + Integer.toString(count++) + " tests")
}
}
} else {
Expand All @@ -252,7 +245,7 @@ tasks.withType(Test) {

// listen to standard out and standard error of the test JVM(s)
onOutput { descriptor, event ->
logger.lifecycle("Test: " + descriptor + " produced standard out/err: " + event.message )
logger.lifecycle("Test: " + descriptor + " produced standard out/err: " + event.message)
}
}

Expand Down Expand Up @@ -282,25 +275,7 @@ jacocoTestReport {
}

wrapper {
gradleVersion = '8.2.1'
}

task javadocJar(type: Jar) {
archiveClassifier.set('javadoc')
from 'build/docs/javadoc'
}

task sourcesJar(type: Jar) {
from sourceSets.main.allSource
archiveClassifier.set('sources')
}

/**
* This specifies what artifacts will be built and uploaded when performing a maven upload.
*/
artifacts {
archives javadocJar
archives sourcesJar
gradleVersion = '8.5'
}

/**
Expand Down Expand Up @@ -375,18 +350,21 @@ publish {
ext.htmlDir = file("build/docs/html")

//update static web docs
task copyJavadoc(dependsOn: ['javadoc', 'picardDoc'], type: Copy) {
tasks.register('copyJavadoc', Copy) {
dependsOn 'javadoc', 'picardDoc'
from 'build/docs/javadoc'
into "$htmlDir/javadoc"
}

task copyPicardDoc(dependsOn: 'picardDoc', type: Copy){
tasks.register('copyPicardDoc', Copy) {
dependsOn 'picardDoc'
from 'build/docs/picarddoc'
into "$htmlDir/picarddoc"
}

task updateGhPages(dependsOn: ['copyJavadoc', 'copyPicardDoc']){
outputs.dir htmlDir
tasks.register('updateGhPages') {
dependsOn 'copyJavadoc', 'copyPicardDoc'
outputs.dir htmlDir
}

updateGhPages.finalizedBy gitPublishPush
Expand Down
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 3 additions & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.2.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
24 changes: 16 additions & 8 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand All @@ -80,13 +80,10 @@ do
esac
done

APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

APP_NAME="Gradle"
# This is normally unused
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}

# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down Expand Up @@ -133,22 +130,29 @@ location of your Java installation."
fi
else
JAVACMD=java
which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
if ! command -v java >/dev/null 2>&1
then
die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
Please set the JAVA_HOME variable in your environment to match the
location of your Java installation."
fi
fi

# Increase the maximum file descriptors if we can.
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
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
ulimit -n "$MAX_FD" ||
warn "Could not set maximum file descriptor limit to $MAX_FD"
esac
Expand Down Expand Up @@ -193,6 +197,10 @@ if "$cygwin" || "$msys" ; then
done
fi


# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'

# Collect all arguments for the java command;
# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
# shell script including quotes and variable substitutions, so put them in
Expand Down

0 comments on commit 5706839

Please sign in to comment.