blob: f0b88645ad8e5bc5977b41e972025b096eb774b1 [file] [log] [blame]
buildscript {
repositories {
mavenCentral()
mavenLocal()
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath 'ru.vyarus:gradle-animalsniffer-plugin:1.4.0'
classpath 'net.ltgt.gradle:gradle-errorprone-plugin:0.0.11'
classpath "net.ltgt.gradle:gradle-apt-plugin:0.10"
classpath 'com.github.ben-manes:gradle-versions-plugin:0.15.0'
}
}
// Display the version report using: ./gradlew dependencyUpdates
// Also see https://github.com/ben-manes/gradle-versions-plugin.
apply plugin: 'com.github.ben-manes.versions'
subprojects {
apply plugin: "checkstyle"
apply plugin: 'maven'
apply plugin: 'idea'
apply plugin: 'java'
apply plugin: "signing"
apply plugin: "jacoco"
// The plugin only has an effect if a signature is specified
apply plugin: 'ru.vyarus.animalsniffer'
apply plugin: 'findbugs'
apply plugin: "net.ltgt.apt"
// Plugins that require java8
if (JavaVersion.current().isJava8Compatible()) {
apply plugin: "net.ltgt.errorprone"
}
group = "io.opencensus"
version = "0.8.0-SNAPSHOT" // CURRENT_OPENCENSUS_VERSION
sourceCompatibility = 1.6
targetCompatibility = 1.6
repositories {
mavenCentral()
mavenLocal()
}
[compileJava, compileTestJava].each() {
// 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"]
if (JavaVersion.current().isJava8Compatible()) {
// TODO(bdrutu): Read files directly instead of reading from properties.
if (rootProject.hasProperty("errorProneWarnings")) {
it.options.compilerArgs += rootProject.properties["errorProneWarnings"].split(',').collect {
it as String
}
}
if (rootProject.hasProperty("errorProneExperimentalErrors")) {
it.options.compilerArgs += rootProject.properties["errorProneExperimentalErrors"].split(',').collect {
it as String
}
}
if (rootProject.hasProperty("errorProneExperimentalWarnings")) {
it.options.compilerArgs += rootProject.properties["errorProneExperimentalWarnings"].split(',').collect {
it as String
}
}
if (rootProject.hasProperty("errorProneExperimentalSuggestions")) {
it.options.compilerArgs += rootProject.properties["errorProneExperimentalSuggestions"].split(',').collect {
it as String
}
}
}
it.options.encoding = "UTF-8"
// TODO(bdrutu): Enable when fix the issue with configuring bootstrap class.
// [options] bootstrap class path not set in conjunction with -source 1.6
if (JavaVersion.current().isJava8Compatible()) {
it.options.compilerArgs += ["-Werror"]
}
}
compileTestJava {
// serialVersionUID is basically guaranteed to be useless in tests
options.compilerArgs += ["-Xlint:-serial"]
// It undeprecates DoubleSubject.isEqualTo(Double).
options.compilerArgs += ["-Xlint:-deprecation"]
}
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)
}
javadoc.options {
encoding = 'UTF-8'
links 'https://docs.oracle.com/javase/8/docs/api/'
}
ext {
autoValueVersion = '1.4'
findBugsVersion = '3.0.1'
grpcVersion = '1.7.0'
guavaVersion = '19.0'
googleAuthVersion = '0.8.0'
googleCloudVersion = '0.26.0-alpha'
zipkinReporterVersion = '2.0.0'
libraries = [
auto_value: "com.google.auto.value:auto-value:${autoValueVersion}",
auto_service: 'com.google.auto.service:auto-service:1.0-rc3',
byte_buddy: 'net.bytebuddy:byte-buddy:1.7.6',
disruptor: 'com.lmax:disruptor:3.3.6',
errorprone: 'com.google.errorprone:error_prone_annotations:2.0.19',
findbugs_annotations: "com.google.code.findbugs:annotations:${findBugsVersion}",
google_auth: "com.google.auth:google-auth-library-credentials:${googleAuthVersion}",
google_cloud_trace: "com.google.cloud:google-cloud-trace:${googleCloudVersion}",
zipkin_reporter: "io.zipkin.reporter2:zipkin-reporter:${zipkinReporterVersion}",
zipkin_urlconnection: "io.zipkin.reporter2:zipkin-sender-urlconnection:${zipkinReporterVersion}",
grpc_context: "io.grpc:grpc-context:${grpcVersion}",
grpc_core: "io.grpc:grpc-core:${grpcVersion}",
guava: "com.google.guava:guava:${guavaVersion}",
jsr305: "com.google.code.findbugs:jsr305:${findBugsVersion}",
// Test dependencies.
guava_testlib: "com.google.guava:guava-testlib:${guavaVersion}",
junit: 'junit:junit:4.12',
mockito: 'org.mockito:mockito-core:1.9.5',
truth: 'com.google.truth:truth:0.30',
]
}
dependencies {
compile libraries.errorprone,
libraries.jsr305
testCompile libraries.guava_testlib,
libraries.junit,
libraries.mockito,
libraries.truth
if (JavaVersion.current().isJava8Compatible()) {
// The ErrorProne plugin defaults to the latest, which would break our
// build if error prone releases a new version with a new check
errorprone 'com.google.errorprone:error_prone_core:2.0.19'
}
}
findbugs {
toolVersion = findBugsVersion
ignoreFailures = false // bug free or it doesn't ship!
effort = 'max'
reportLevel = 'low' // low = sensitive to even minor mistakes
omitVisitors = [] // bugs that we want to ignore
excludeFilter = file("$rootDir/findbugs-exclude.xml")
}
// Generate html report for findbugs.
findbugsMain {
reports {
xml.enabled = false
html.enabled = true
}
}
// Disable findbugs for tests.
findbugsTest.enabled = false
checkstyle {
configFile = file("$rootDir/buildscripts/checkstyle.xml")
toolVersion = "8.0"
ignoreFailures = false
if (rootProject.hasProperty("checkstyle.ignoreFailures")) {
ignoreFailures = rootProject.properties["checkstyle.ignoreFailures"].toBoolean()
}
configProperties["rootDir"] = rootDir
}
// Disable checkstyle if no java8.
checkstyleMain.enabled = JavaVersion.current().isJava8Compatible()
checkstyleTest.enabled = JavaVersion.current().isJava8Compatible()
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
}
uploadArchives {
repositories {
mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
def configureAuth = {
if (rootProject.hasProperty('ossrhUsername') && rootProject.hasProperty('ossrhPassword')) {
authentication(userName:rootProject.ossrhUsername, password: rootProject.ossrhPassword)
}
}
repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/", configureAuth)
snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/", configureAuth)
pom.project {
name "OpenCensus"
packaging 'jar'
description project.description
url 'https://github.com/census-instrumentation/opencensus-java'
scm {
connection 'scm:svn:https://github.com/census-instrumentation/opencensus-java'
developerConnection 'scm:git:[email protected]/census-instrumentation/opencensus-java'
url 'https://github.com/census-instrumentation/opencensus-java'
}
licenses {
license {
name 'The Apache License, Version 2.0'
url 'http://www.apache.org/licenses/LICENSE-2.0.txt'
}
}
developers {
developer {
id 'io.opencensus'
name 'OpenCensus Contributors'
email '[email protected]'
url 'opencensus.io'
// https://issues.gradle.org/browse/GRADLE-2719
organization = 'Google, Inc.'
organizationUrl 'https://www.google.com'
}
}
}
}
}
}
// Upload the following artifacts only:
uploadArchives.onlyIf {
name in ['opencensus-api',
'opencensus-contrib-agent',
'opencensus-contrib-grpc-metrics',
'opencensus-contrib-grpc-util',
'opencensus-contrib-zpages',
'opencensus-exporter-trace-logging',
'opencensus-exporter-trace-stackdriver',
'opencensus-exporter-trace-zipkin',
'opencensus-impl-core',
'opencensus-impl-lite',
'opencensus-impl',
'opencensus-testing']
}
// 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'
}
}