opentelemetry-java-instrume.../gradle/java.gradle

165 lines
4.0 KiB
Groovy

apply plugin: 'java'
apply plugin: 'groovy'
sourceCompatibility = 1.7
targetCompatibility = 1.7
apply plugin: "io.franzbecker.gradle-lombok"
lombok { // optional: values below are the defaults
version = "1.16.20"
sha256 = "c5178b18caaa1a15e17b99ba5e4023d2de2ebc18b58cde0f5a04ca4b31c10e6d"
}
apply plugin: "net.ltgt.errorprone"
tasks.withType(JavaCompile) {
options.compilerArgs += ['-Xep:FutureReturnValueIgnored:OFF']
// workaround for: https://github.com/google/error-prone/issues/780
options.compilerArgs += ['-Xep:ParameterName:OFF']
}
apply plugin: "eclipse"
eclipse {
classpath {
downloadSources = true
downloadJavadoc = true
}
}
if (configurations.find { it.name == 'jmh' }) {
eclipse.classpath.plusConfigurations += [configurations.jmh]
}
task packageSources(type: Jar) {
classifier = 'sources'
from sourceSets.main.allSource
}
artifacts.archives packageSources
repositories {
mavenLocal()
jcenter()
mavenCentral()
}
dependencies {
testCompile deps.junit
testCompile group: 'org.assertj', name: 'assertj-core', version: '2.9.+'
testCompile group: 'org.mockito', name: 'mockito-core', version: '2.7.22'
testCompile deps.spock
testCompile deps.groovy
testCompile deps.testLogging
testCompile group: 'io.ratpack', name: 'ratpack-groovy-test', version: '1.4.6'
testCompile group: 'com.github.stefanbirkner', name: 'system-rules', version: '1.17.1'
}
tasks.withType(Javadoc) {
options.encoding = "utf-8"
options.docEncoding = "utf-8"
options.charSet = "utf-8"
options.addStringOption('Xdoclint:none', '-quiet')
doFirst {
if (project.ext.has("apiLinks")) {
options.links(*project.apiLinks)
}
}
}
javadoc {
source = sourceSets.main.allJava
classpath = configurations.compileClasspath
options {
setMemberLevel JavadocMemberLevel.PUBLIC
setAuthor true
links "https://docs.oracle.com/javase/8/docs/api/"
}
}
task sourceJar(type: Jar) {
from sourceSets.main.allJava
classifier = 'sources'
}
task javaDocJar(type: Jar, dependsOn: javadoc) {
from javadoc.destinationDir
classifier = 'javadoc'
}
artifacts {
archives sourceJar
archives javaDocJar
}
if (project.plugins.hasPlugin('com.github.johnrengelman.shadow')) {
// Remove the no-deps jar from the archives to prevent publication
configurations.archives.with {
artifacts.remove artifacts.find { it.archiveTask.is jar }
}
artifacts {
archives shadowJar
}
}
if (project.hasProperty("removeJarVersionNumbers") && removeJarVersionNumbers) {
tasks.withType(AbstractArchiveTask) {
version = null
}
}
project.ext.testJava8Only = []
project.ext.testJava8Minimum = []
tasks.withType(Test) {
if (name.endsWith("Java7") || name.endsWith("Java9")) {
return
}
def cloned = it
def java7Home = System.getenv("JAVA7_HOME")
if (java7Home != null) {
def testJ7 = task "${cloned.name}Java7"(type: cloned.class) {
description "Runs $cloned.name under java 7"
// TODO: Pull from environment variable:
executable = "$java7Home/bin/java"
afterEvaluate {
exclude project.testJava8Only
exclude project.testJava8Minimum
}
}
tasks.check.dependsOn testJ7
}
def java9Home = System.getenv("JAVA9_HOME")
if (java9Home != null) {
def testJ9 = task "${cloned.name}Java9"(type: cloned.class) {
description "Runs $cloned.name under java 9"
// TODO: Pull from environment variable:
executable = "$java9Home/bin/java"
jvmArgs '--add-opens'
jvmArgs 'java.base/jdk.internal.loader=ALL-UNNAMED'
project.afterEvaluate {
exclude project.testJava8Only
}
}
tasks.check.dependsOn testJ9
}
}
apply from: "$rootDir/gradle/checkstyle.gradle"
apply from: "$rootDir/gradle/codenarc.gradle"
apply from: "$rootDir/gradle/jacoco.gradle"
plugins.withType(BasePlugin) {
project.afterEvaluate {
def deleteTasks = tasks.withType(Delete) + project.tasks.findByPath('clean')
def otherTasks = tasks - deleteTasks
otherTasks*.mustRunAfter deleteTasks
}
}