Skip to content

Commit

Permalink
Build and test on Java 11
Browse files Browse the repository at this point in the history
* Changes to allow htsjdk to build and run on Java 11.
  * Fix broken javadoc that fail in 11
  * Fix String.lines conflict: see scala/bug#11125
* Changes to the build:
  * Update gradle 4.8.1 -> 5.2.1
  * Update shadow plugin 2.0.4 -> 4.0.4
  * Update scala test plugin 0.22 -> 0.23
  * Switch publishing plugin from maven -> maven-publish
* Add Java 11 to travis matrix

Co-authored-by: Louis Bergelson <louisb@broadinstitute.org>
  • Loading branch information
tomwhite and lbergelson committed Feb 20, 2019
1 parent 4c8dfbd commit 7cee305
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 68 deletions.
3 changes: 2 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ cache:
jdk:
- oraclejdk8
- openjdk8
- openjdk11
matrix:
fast_finish: true
allow_failures:
Expand All @@ -36,5 +37,5 @@ after_success:
- echo "TRAVIS_BRANCH='$TRAVIS_BRANCH'";
echo "JAVA_HOME='$JAVA_HOME'";
if [ "$TRAVIS_BRANCH" == "master" ]; then
./gradlew uploadArchives;
./gradlew publish;
fi
100 changes: 44 additions & 56 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@ buildscript {
plugins {
id 'java'
id 'scala'
id 'maven'
id 'maven-publish'
id 'signing'
id 'jacoco'
id 'com.palantir.git-version' version '0.11.0'
id 'com.github.johnrengelman.shadow' version '2.0.4'
id 'com.github.maiflai.scalatest' version '0.22'
id 'com.github.johnrengelman.shadow' version '4.0.4'
id 'com.github.maiflai.scalatest' version '0.23'
}

repositories {
Expand All @@ -22,7 +22,6 @@ repositories {
jacocoTestReport {
group = "Reporting"
description = "Generate Jacoco coverage reports after running tests."
additionalSourceDirs = files(sourceSets.main.allJava.srcDirs)

reports {
xml.enabled = true // codecov depends on xml format report
Expand All @@ -38,7 +37,7 @@ dependencies {
compile "org.tukaani:xz:1.5"
compile "gov.nih.nlm.ncbi:ngs-java:2.9.0"

testCompile "org.scala-lang:scala-library:2.12.6"
testCompile "org.scala-lang:scala-library:2.12.8"
testCompile "org.scalatest:scalatest_2.12:3.0.5"
testRuntime 'org.pegdown:pegdown:1.6.0' // Necessary for generating HTML reports with ScalaTest
testCompile "org.testng:testng:6.14.3"
Expand All @@ -58,6 +57,8 @@ group = 'com.github.samtools'

defaultTasks 'jar'



jar {
manifest {
attributes 'Implementation-Title': 'HTSJDK',
Expand Down Expand Up @@ -141,92 +142,79 @@ task testExternalApis(type: Test) {
}

wrapper {
gradleVersion = '4.8.1'
gradleVersion = '5.2.1'
}

// This is a hack to disable the java 8 default javadoc lint until we fix the html formatting
if (JavaVersion.current().isJava8Compatible()) {
tasks.withType(Javadoc) {
options.addStringOption('Xdoclint:none', '-quiet')
}
tasks.withType(Javadoc) {
options.addStringOption('Xdoclint:none', '-quiet')
}

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

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

/**
* This specifies what artifacts will be built and uploaded when performing a maven upload.
*/
artifacts {
archives jar
archives javadocJar
archives sourcesJar
archiveClassifier.set('sources')
}

/**
* Sign non-snapshot releases with our secret key. This should never need to be invoked directly.
*/
signing {
required { isRelease && gradle.taskGraph.hasTask("uploadArchives") }
required { isRelease && gradle.taskGraph.hasTask("publishHtsjdkPublicationToMavenRepository") }
sign configurations.archives
}

/**
* Upload a release to sonatype. You must be an authorized uploader and have your sonatype
* username and password information in your gradle properties file. See the readme for more info.
*
* For releasing to your local maven repo, use gradle install
*/
uploadArchives {
repositories {
mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
publishing {
publications {
htsjdk(MavenPublication) {
from components.java
artifact javadocJar
artifact sourcesJar

repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/") {
authentication(userName: project.findProperty("sonatypeUsername"), password: project.findProperty("sonatypePassword"))
}

snapshotRepository(url: "https://broadinstitute.jfrog.io/broadinstitute/libs-snapshot-local/") {
authentication(userName: System.env.ARTIFACTORY_USERNAME, password: System.env.ARTIFACTORY_PASSWORD)
}

pom.project {
name 'HTSJDK'
packaging 'jar'
description 'A Java API for high-throughput sequencing data (HTS) formats'
url 'http://samtools.github.io/htsjdk/'
pom {
name = 'HTSJDK'
packaging = 'jar'
description = 'A Java API for high-throughput sequencing data (HTS) formats'
url = 'http://samtools.github.io/htsjdk/'

developers {
developer {
id 'picard'
name 'Picard Team'
url 'http://broadinstitute.github.io/picard'
id = 'picard'
name = 'Picard Team'
url = 'http://broadinstitute.github.io/picard'
}
}

scm {
url 'git@github.com:samtools/htsjdk.git'
connection 'scm:git:git@github.com:samtools/htsjdk.git'
url = 'git@github.com:samtools/htsjdk.git'
connection = 'scm:git:git@github.com:samtools/htsjdk.git'
}

licenses {
license {
name 'MIT License'
url 'http://opensource.org/licenses/MIT'
distribution 'repo'
name = 'MIT License'
url = 'http://opensource.org/licenses/MIT'
distribution = 'repo'
}
}
}
}
}
doFirst {
System.out.println("Uploading version $version")

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
}
}
}

task install(dependsOn:publishToMavenLocal)
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,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.8.1-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
2 changes: 1 addition & 1 deletion gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ APP_NAME="Gradle"
APP_BASE_NAME=`basename "$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=""
DEFAULT_JVM_OPTS='"-Xmx64m"'

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD="maximum"
Expand Down
6 changes: 0 additions & 6 deletions src/main/java/htsjdk/samtools/util/MergingIterator.java
Original file line number Diff line number Diff line change
Expand Up @@ -87,17 +87,11 @@ public MergingIterator(final Comparator<T> comparator, final Collection<Closeabl
// should we throw? it's prob'ly an error.
}

/**
* @see java.util.Iterator<T>.hasNext
*/
@Override
public boolean hasNext() {
return ! this.queue.isEmpty();
}

/**
* @see java.util.Iterator<T>.next
*/
@Override
public T next() {
if ( ! this.hasNext()) throw new NoSuchElementException();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ class FastqReaderWriterTest extends UnitSpec {
""".stripMargin.trim

Range.inclusive(1, 3).foreach { n =>
val text = fastq.lines.take(n).mkString("\n")
val text = fastq.linesIterator.take(n).mkString("\n")
val reader = new BufferedReader(new StringReader(text))
an[Exception] shouldBe thrownBy { new FastqReader(null, reader).iterator().toSeq }
}
Expand Down
4 changes: 2 additions & 2 deletions src/test/scala/htsjdk/samtools/util/StringUtilTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -118,8 +118,8 @@ class StringUtilTest extends UnitSpec {

it should "wrap text when lines are longer than length give" in {
val result = StringUtil.wordWrap(textForWrapping, 15)
result.lines.size shouldBe 5
result.lines.foreach(line => line.length should be <= 15)
result.linesIterator.size shouldBe 5
result.linesIterator.foreach(line => line.length should be <= 15)
}

"StringUtil.intValuesToString(int[])" should "generate a CSV string of ints" in {
Expand Down

0 comments on commit 7cee305

Please sign in to comment.