380 lines
14 KiB
Groovy
380 lines
14 KiB
Groovy
plugins {
|
|
id "com.github.sherter.google-java-format" apply false
|
|
id "com.jfrog.artifactory" apply false
|
|
id "com.jfrog.bintray" version "1.8.4" apply false // Need *specific* version.
|
|
id "net.ltgt.errorprone" apply false
|
|
id "ru.vyarus.animalsniffer" apply false
|
|
id "io.morethan.jmhreport" apply false
|
|
}
|
|
|
|
subprojects {
|
|
apply plugin: 'checkstyle'
|
|
apply plugin: 'eclipse'
|
|
apply plugin: 'java'
|
|
apply plugin: 'java-library'
|
|
apply plugin: 'idea'
|
|
apply plugin: 'signing'
|
|
apply plugin: 'jacoco'
|
|
|
|
apply plugin: 'com.github.sherter.google-java-format'
|
|
apply plugin: 'net.ltgt.errorprone'
|
|
|
|
group = "io.opentelemetry"
|
|
version = "0.4.0-SNAPSHOT" // CURRENT_OPEN_TELEMETRY_VERSION
|
|
|
|
repositories {
|
|
mavenCentral()
|
|
jcenter()
|
|
mavenLocal()
|
|
}
|
|
|
|
sourceCompatibility = 1.7
|
|
targetCompatibility = 1.7
|
|
|
|
tasks.withType(JavaCompile) {
|
|
// We suppress the "try" warning because it disallows managing an auto-closeable with
|
|
// try-with-resources without referencing the auto-closeable within the try block.
|
|
// We suppress the "processing" warning as suggested in
|
|
// https://groups.google.com/forum/#!topic/bazel-discuss/_R3A9TJSoPM
|
|
it.options.compilerArgs += ["-Xlint:all", "-Xlint:-try", "-Xlint:-processing"]
|
|
it.options.errorprone.disableWarningsInGeneratedCode = true
|
|
it.options.errorprone.allDisabledChecksAsWarnings = true
|
|
|
|
// Doesn't currently use Var annotations.
|
|
it.options.errorprone.disable("Var") // "-Xep:Var:OFF"
|
|
|
|
// ImmutableRefactoring suggests using com.google.errorprone.annotations.Immutable,
|
|
// but currently uses javax.annotation.concurrent.Immutable
|
|
it.options.errorprone.disable("ImmutableRefactoring") // "-Xep:ImmutableRefactoring:OFF"
|
|
|
|
// NullPointerException is experimental and incomplete
|
|
// (https://github.com/google/error-prone/issues/1253).
|
|
it.options.errorprone.disable("NullableDereference") // "-Xep:NullableDereference:OFF"
|
|
|
|
// ExpectedExceptionRefactoring and TestExceptionRefactoring suggest using
|
|
// assertThrows, but assertThrows only works well with lambdas.
|
|
it.options.errorprone.disable("ExpectedExceptionRefactoring") // "-Xep:ExpectedExceptionRefactoring:OFF"
|
|
|
|
// AutoValueImmutableFields suggests returning Guava types from API methods
|
|
it.options.errorprone.disable("AutoValueImmutableFields") // "-Xep:AutoValueImmutableFields:OFF"
|
|
|
|
it.options.encoding = "UTF-8"
|
|
|
|
// Ignore warnings for protobuf and jmh generated files.
|
|
it.options.errorprone.excludedPaths = ".*generated.*" // "-XepExcludedPaths:.*/build/generated/source/proto/.*"
|
|
|
|
// Enforce errorprone warnings to be errors.
|
|
if (!JavaVersion.current().isJava9() && !JavaVersion.current().isJava10() && !JavaVersion.current().isJava11()) {
|
|
// TODO: Enable -Werror for Java 9+
|
|
it.options.compilerArgs += ["-Werror"]
|
|
}
|
|
}
|
|
|
|
compileTestJava {
|
|
// serialVersionUID is basically guaranteed to be useless in tests
|
|
options.compilerArgs += ["-Xlint:-serial"]
|
|
}
|
|
|
|
jar.manifest {
|
|
attributes('Implementation-Title': name,
|
|
'Implementation-Version': version,
|
|
'Built-By': System.getProperty('user.name'),
|
|
'Built-JDK': System.getProperty('java.version'),
|
|
'Source-Compatibility': sourceCompatibility,
|
|
'Target-Compatibility': targetCompatibility)
|
|
}
|
|
|
|
ext {
|
|
autoValueVersion = '1.6.6'
|
|
errorProneVersion = '2.3.3'
|
|
errorProneJavacVersion = '9+181-r4173-1'
|
|
findBugsJsr305Version = '3.0.2'
|
|
grpcVersion = '1.28.0'
|
|
guavaVersion = '28.2-android'
|
|
jmhVersion = '1.19'
|
|
opentracingVersion = '0.33.0'
|
|
prometheusVersion = '0.8.1'
|
|
protobufVersion = '3.11.4'
|
|
protocVersion = '3.11.4'
|
|
|
|
libraries = [
|
|
auto_value : "com.google.auto.value:auto-value:${autoValueVersion}",
|
|
auto_value_annotation : "com.google.auto.value:auto-value-annotations:${autoValueVersion}",
|
|
disruptor : "com.lmax:disruptor:3.4.2",
|
|
errorprone_annotation : "com.google.errorprone:error_prone_annotations:${errorProneVersion}",
|
|
errorprone_core : "com.google.errorprone:error_prone_core:${errorProneVersion}",
|
|
errorprone_javac : "com.google.errorprone:javac:${errorProneJavacVersion}",
|
|
grpc_api : "io.grpc:grpc-api:${grpcVersion}",
|
|
grpc_context : "io.grpc:grpc-context:${grpcVersion}",
|
|
grpc_protobuf : "io.grpc:grpc-protobuf:${grpcVersion}",
|
|
grpc_stub : "io.grpc:grpc-stub:${grpcVersion}",
|
|
guava : "com.google.guava:guava:${guavaVersion}",
|
|
javax_annotations : "javax.annotation:javax.annotation-api:1.3.2",
|
|
jmh_core : "org.openjdk.jmh:jmh-core:${jmhVersion}",
|
|
jmh_bytecode : "org.openjdk.jmh:jmh-generator-bytecode:${jmhVersion}",
|
|
jsr305 : "com.google.code.findbugs:jsr305:${findBugsJsr305Version}",
|
|
prometheus_client : "io.prometheus:simpleclient:${prometheusVersion}",
|
|
prometheus_client_common: "io.prometheus:simpleclient_common:${prometheusVersion}",
|
|
protobuf : "com.google.protobuf:protobuf-java:${protobufVersion}",
|
|
protobuf_util : "com.google.protobuf:protobuf-java-util:${protobufVersion}",
|
|
|
|
// Compatibility layer
|
|
opentracing : "io.opentracing:opentracing-api:${opentracingVersion}",
|
|
|
|
// Test dependencies.
|
|
guava_testlib : "com.google.guava:guava-testlib:${guavaVersion}",
|
|
junit : 'junit:junit:4.12',
|
|
mockito : 'org.mockito:mockito-core:2.28.2',
|
|
truth : 'com.google.truth:truth:1.0.1',
|
|
slf4jsimple : 'org.slf4j:slf4j-simple:1.7.25', // Compatibility layer
|
|
awaitility : 'org.awaitility:awaitility:3.0.0', // Compatibility layer
|
|
testcontainers : 'org.testcontainers:testcontainers:1.13.0',
|
|
rest_assured : 'io.rest-assured:rest-assured:4.2.0',
|
|
jaeger_client : 'io.jaegertracing:jaeger-client:1.2.0' // Jaeger Client
|
|
]
|
|
}
|
|
|
|
checkstyle {
|
|
configFile = file("$rootDir/buildscripts/checkstyle.xml")
|
|
toolVersion = "8.12"
|
|
ignoreFailures = false
|
|
configProperties["rootDir"] = rootDir
|
|
}
|
|
|
|
jacoco { toolVersion = "0.8.2" }
|
|
|
|
googleJavaFormat {
|
|
toolVersion = '1.7'
|
|
}
|
|
|
|
configurations {
|
|
compile {
|
|
// Detect Maven Enforcer's dependencyConvergence failures. We only
|
|
// care for artifacts used as libraries by others.
|
|
// TODO: Enable failOnVersionConflict()
|
|
resolutionStrategy.preferProjectModules()
|
|
}
|
|
}
|
|
|
|
dependencies {
|
|
compileOnly libraries.auto_value_annotation,
|
|
libraries.errorprone_annotation,
|
|
libraries.jsr305
|
|
|
|
testImplementation libraries.junit,
|
|
libraries.mockito,
|
|
libraries.truth,
|
|
libraries.guava_testlib,
|
|
libraries.jaeger_client
|
|
|
|
// The ErrorProne plugin defaults to the latest, which would break our
|
|
// build if error prone releases a new version with a new check
|
|
errorprone libraries.errorprone_core
|
|
errorproneJavac libraries.errorprone_javac
|
|
|
|
if (JavaVersion.current().isJava9() || JavaVersion.current().isJava10() || JavaVersion.current().isJava11()) {
|
|
// Workaround for @javax.annotation.Generated
|
|
// see: https://github.com/grpc/grpc-java/issues/3633
|
|
compile("javax.annotation:javax.annotation-api:1.3.2")
|
|
}
|
|
}
|
|
|
|
javadoc.options {
|
|
source = "8"
|
|
encoding = "UTF-8"
|
|
links 'https://docs.oracle.com/javase/8/docs/api/'
|
|
}
|
|
|
|
afterEvaluate { // Allow subproject to add more source sets.
|
|
tasks.googleJavaFormat {
|
|
source = sourceSets*.allJava
|
|
include '**/*.java'
|
|
}
|
|
|
|
tasks.verifyGoogleJavaFormat {
|
|
source = sourceSets*.allJava
|
|
include '**/*.java'
|
|
}
|
|
|
|
jar {
|
|
inputs.property("moduleName", moduleName)
|
|
|
|
manifest {
|
|
attributes('Automatic-Module-Name': moduleName)
|
|
}
|
|
}
|
|
}
|
|
|
|
signing {
|
|
required false
|
|
sign configurations.archives
|
|
}
|
|
|
|
task javadocJar(type: Jar) {
|
|
classifier = 'javadoc'
|
|
from javadoc
|
|
}
|
|
|
|
task sourcesJar(type: Jar) {
|
|
classifier = 'sources'
|
|
from sourceSets.main.allSource
|
|
}
|
|
|
|
artifacts {
|
|
archives javadocJar, sourcesJar
|
|
}
|
|
|
|
// At a test failure, log the stack trace to the console so that we don't
|
|
// have to open the HTML in a browser.
|
|
test {
|
|
testLogging {
|
|
exceptionFormat = 'full'
|
|
showExceptions = true
|
|
showCauses = true
|
|
showStackTraces = true
|
|
}
|
|
maxHeapSize = '1500m'
|
|
}
|
|
|
|
plugins.withId("me.champeau.gradle.jmh") {
|
|
// Always include the jmhreport plugin and run it after jmh task.
|
|
pluginManager.apply "io.morethan.jmhreport"
|
|
dependencies {
|
|
jmh libraries.jmh_core,
|
|
libraries.jmh_bytecode
|
|
}
|
|
|
|
// invoke jmh on a single benchmark class like so:
|
|
// ./gradlew -PjmhIncludeSingleClass=StatsTraceContextBenchmark clean :grpc-core:jmh
|
|
jmh {
|
|
failOnError = true
|
|
resultFormat = 'JSON'
|
|
// Otherwise an error will happen:
|
|
// Could not expand ZIP 'byte-buddy-agent-1.9.7.jar'.
|
|
includeTests = false
|
|
profilers = ["gc"]
|
|
if (project.hasProperty('jmhIncludeSingleClass')) {
|
|
include = [
|
|
project.property('jmhIncludeSingleClass')
|
|
]
|
|
}
|
|
}
|
|
|
|
jmhReport {
|
|
jmhResultPath = project.file("${project.buildDir}/reports/jmh/results.json")
|
|
jmhReportOutput = project.file("${project.buildDir}/reports/jmh")
|
|
}
|
|
|
|
// Always run jmhReport after jmh task.
|
|
tasks.jmh.finalizedBy tasks.jmhReport
|
|
}
|
|
|
|
plugins.withId("maven-publish") {
|
|
// Always include the artifactory/bintray plugins to do the deployment.
|
|
pluginManager.apply "com.jfrog.artifactory"
|
|
pluginManager.apply "com.jfrog.bintray"
|
|
|
|
publishing {
|
|
publications {
|
|
mavenPublication(MavenPublication) {
|
|
version version
|
|
groupId group
|
|
|
|
from components.java
|
|
artifact sourcesJar
|
|
artifact javadocJar
|
|
|
|
pom {
|
|
name = 'OpenTelemetry Java'
|
|
packaging = 'jar'
|
|
url = 'https://github.com/open-telemetry/opentelemetry-java'
|
|
|
|
licenses {
|
|
license {
|
|
name = 'The Apache License, Version 2.0'
|
|
url = 'http://www.apache.org/licenses/LICENSE-2.0.txt'
|
|
}
|
|
}
|
|
|
|
developers {
|
|
developer {
|
|
id = 'opentelemetry'
|
|
name = 'OpenTelemetry Gitter'
|
|
url = 'https://gitter.im/open-telemetry/community'
|
|
}
|
|
}
|
|
|
|
scm {
|
|
connection = 'scm:git:git@github.com:open-telemetry/opentelemetry-java.git'
|
|
developerConnection = 'scm:git:git@github.com:open-telemetry/opentelemetry-java.git'
|
|
url = 'git@github.com:open-telemetry/opentelemetry-java.git'
|
|
}
|
|
|
|
afterEvaluate {
|
|
// description is not available until evaluated.
|
|
description = project.description
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// Snapshot publishing.
|
|
artifactory {
|
|
contextUrl = 'https://oss.jfrog.org'
|
|
publish {
|
|
repository {
|
|
repoKey = 'oss-snapshot-local'
|
|
username = System.getenv("BINTRAY_USER")
|
|
password = System.getenv("BINTRAY_KEY")
|
|
}
|
|
defaults {
|
|
publications('mavenPublication')
|
|
publishArtifacts = true
|
|
publishPom = true
|
|
}
|
|
}
|
|
resolve {
|
|
repoKey = 'libs-release'
|
|
}
|
|
}
|
|
|
|
// Release artifacts publishing.
|
|
bintray {
|
|
user = System.getenv("BINTRAY_USER")
|
|
key = System.getenv("BINTRAY_KEY")
|
|
publications = ['mavenPublication']
|
|
|
|
publish = true
|
|
|
|
pkg {
|
|
repo = 'maven'
|
|
name = 'opentelemetry-java'
|
|
licenses = ['Apache-2.0']
|
|
vcsUrl = 'https://github.com/open-telemetry/opentelemetry-java.git'
|
|
userOrg = 'open-telemetry'
|
|
|
|
githubRepo = 'open-telemetry/opentelemetry-java'
|
|
|
|
version {
|
|
name = project.version
|
|
|
|
gpg {
|
|
sign = true
|
|
}
|
|
|
|
mavenCentralSync {
|
|
user = System.getenv("SONATYPE_USER")
|
|
password = System.getenv("SONATYPE_KEY")
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
wrapper {
|
|
distributionType = Wrapper.DistributionType.ALL
|
|
gradleVersion = '6.0.1'
|
|
}
|