1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192
|
// Dependencies for the buildscript
buildscript {
repositories {
mavenCentral()
}
}
// PLUGINS
plugins {
id 'java-library'
id 'maven-publish'
id 'signing'
id 'com.palantir.git-version' version "0.11.0"
}
// Apply the custom jacoco coverage plugin
apply from: 'gradle/jacoco.coverage.gradle'
group = 'org.broadinstitute'
final isRelease = Boolean.getBoolean("release")
version = (isRelease ? gitVersion() : gitVersion() + "-SNAPSHOT")
description = """HTTP/S FileSystem provider for Java NIO.2"""
// library dependencies
repositories {
jcenter()
mavenCentral()
}
def slf4jVersion = "1.7.25"
dependencies {
// for logging, we use the SLF4J API
implementation "org.slf4j:slf4j-api:" + slf4jVersion
// use TestNG for testing
testImplementation "org.testng:testng:6.11"
testImplementation "org.mockito:mockito-core:2.8.47"
// add SLF4J implementation for testing
testImplementation "org.slf4j:slf4j-simple:" + slf4jVersion
}
// for managing the wrapper task
wrapper {
gradleVersion = '6.3'
}
java {
withJavadocJar()
withSourcesJar()
}
tasks.withType(Javadoc) {
// the title includes the version of the API
title = "http-nio $version API"
// add the links to the Java8 API too
options.links("http://docs.oracle.com/javase/8/docs/api/")
// add Java8 optional tags
options.tags = ["apiNote:a:API Note:",
"implSpec:a:Implementation Requirements:",
"implNote:a:Implementation Note:"]
// capture the output for the javadoc task to check if there are warnings
// from https://stackoverflow.com/questions/29519085/how-to-fail-gradle-build-on-javadoc-warnings
def capturedOutput = []
def listener = { capturedOutput << it } as StandardOutputListener
doFirst {
logging.addStandardErrorListener(listener)
logging.addStandardOutputListener(listener)
}
doLast {
logging.removeStandardOutputListener(listener)
logging.removeStandardErrorListener(listener)
// if threre is any warning, fail with a gradle exception
capturedOutput.each { e ->
if(e.toString() =~ " warning: ") {
throw new GradleException("There are javadoc warnings: javadoc failed");
}
}
}
}
// test task
tasks.withType(Test) {
// tests could be always re-run
outputs.upToDateWhen { false }
useTestNG()
// do not show the stdout/stderr of the test JVM(s) on the console
testLogging.showStandardStreams = false
// set heap size for the test JVM(s)
minHeapSize = "1G"
maxHeapSize = "2G"
// log the test that is running
beforeTest { descriptor ->
logger.lifecycle("Running Test: " + descriptor)
}
// logging after the tests
testLogging {
testLogging {
events "skipped", "failed"
exceptionFormat = "full"
}
afterSuite { desc, result ->
if (!desc.parent) { // will match the outermost suite
println "Results: ${result.resultType} (${result.testCount} tests, ${result.successfulTestCount} successes, ${result.failedTestCount} failures, ${result.skippedTestCount} skipped)"
}
}
}
}
// for jar tasks
tasks.withType(Jar) {
// add license
from(rootProject.projectDir) {
include "LICENSE.txt"
into "META-INF"
}
// add manifest information
manifest {
attributes 'Implementation-Title': project.name,
'Implementation-Version': project.version
}
}
publishing {
publications {
library(MavenPublication) {
from components.java
pom {
name = 'http-nio'
packaging = 'jar'
description = project.description
url = 'https://github.com/lbergelson/http-nio'
developers {
developer {
id = 'MagicDGS'
name = 'Daniel Gómez-Sánchez'
url = 'https://github.com/magicDGS/'
}
developer {
id = "gatkdev"
name = "GATK Development Team"
email = "gatk-dev-public@broadinstitute.org"
}
}
scm {
url = 'git@github.com:lbergelson/http-nio.git'
connection = 'scm:git:git@github.com:lbergelson/htt-nio.git'
}
licenses {
license {
name = 'BSD 3-Clause'
url = 'https://github.com/lbergelson/http-nio/blob/master/LICENSE.txt'
distribution = 'repo'
}
}
}
repositories {
maven {
credentials {
username = isRelease ? project.findProperty("sonatypeUsername") : project.findProperty("artifactoryUsername")
password = isRelease ? project.findProperty("sonatypePassword") : project.findProperty("artifactoryPassword")
}
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
}
}
}
}
}
//
//tasks.withType(Sign) {
// onlyIf { isRelease && gradle.taskGraph.hasTask("publishLibraryPublicationToMavenRepository") }
//}
signing {
sign publishing.publications.library
}
|