Bogdan Drutu | 00202c0 | 2017-03-21 10:52:28 -0700 | [diff] [blame] | 1 | buildscript { |
| 2 | repositories { |
| 3 | mavenCentral() |
| 4 | mavenLocal() |
| 5 | maven { |
| 6 | url "https://plugins.gradle.org/m2/" |
| 7 | } |
| 8 | } |
| 9 | dependencies { |
Stefan Schmidt | 0918986 | 2017-10-31 01:58:58 +0100 | [diff] [blame] | 10 | classpath 'ru.vyarus:gradle-animalsniffer-plugin:1.4.2' |
Kristen Kozak | d7745ef | 2017-11-10 18:23:35 -0800 | [diff] [blame] | 11 | classpath 'net.ltgt.gradle:gradle-errorprone-plugin:0.0.13' |
Bogdan Drutu | a5ff0dc | 2017-03-29 10:44:45 -0700 | [diff] [blame] | 12 | classpath "net.ltgt.gradle:gradle-apt-plugin:0.10" |
Stefan Schmidt | 7bfe925 | 2018-01-08 20:20:31 +0100 | [diff] [blame] | 13 | classpath 'com.github.ben-manes:gradle-versions-plugin:0.17.0' |
Bogdan Drutu | 6cb4dd2 | 2017-11-03 09:25:12 +1100 | [diff] [blame] | 14 | classpath "gradle.plugin.com.github.sherter.google-java-format:google-java-format-gradle-plugin:0.6" |
Bogdan Drutu | 00202c0 | 2017-03-21 10:52:28 -0700 | [diff] [blame] | 15 | } |
| 16 | } |
| 17 | |
Stefan Schmidt | e220edb | 2017-08-18 20:49:18 +0200 | [diff] [blame] | 18 | // Display the version report using: ./gradlew dependencyUpdates |
| 19 | // Also see https://github.com/ben-manes/gradle-versions-plugin. |
| 20 | apply plugin: 'com.github.ben-manes.versions' |
| 21 | |
Kristen Kozak | a5f4a10 | 2017-12-19 20:02:00 -0800 | [diff] [blame] | 22 | // Don't use the Checker Framework by default, since it interferes with Error Prone. |
| 23 | def useCheckerFramework = rootProject.hasProperty('checkerFramework') |
| 24 | def useErrorProne = !useCheckerFramework |
| 25 | |
Bogdan Drutu | 00202c0 | 2017-03-21 10:52:28 -0700 | [diff] [blame] | 26 | subprojects { |
| 27 | apply plugin: "checkstyle" |
| 28 | apply plugin: 'maven' |
| 29 | apply plugin: 'idea' |
Fabian Lange | 5430ec7 | 2018-02-02 14:23:58 -0800 | [diff] [blame] | 30 | apply plugin: 'eclipse' |
Bogdan Drutu | 00202c0 | 2017-03-21 10:52:28 -0700 | [diff] [blame] | 31 | apply plugin: 'java' |
| 32 | apply plugin: "signing" |
| 33 | apply plugin: "jacoco" |
Bogdan Drutu | b0e6050 | 2017-03-22 19:23:35 -0700 | [diff] [blame] | 34 | // The plugin only has an effect if a signature is specified |
| 35 | apply plugin: 'ru.vyarus.animalsniffer' |
Bogdan Drutu | 07f0dd2 | 2017-03-22 08:54:53 -0700 | [diff] [blame] | 36 | apply plugin: 'findbugs' |
Bogdan Drutu | 6cb4dd2 | 2017-11-03 09:25:12 +1100 | [diff] [blame] | 37 | apply plugin: 'net.ltgt.apt' |
Bogdan Drutu | b0e6050 | 2017-03-22 19:23:35 -0700 | [diff] [blame] | 38 | // Plugins that require java8 |
| 39 | if (JavaVersion.current().isJava8Compatible()) { |
Kristen Kozak | a5f4a10 | 2017-12-19 20:02:00 -0800 | [diff] [blame] | 40 | if (useErrorProne) { |
| 41 | apply plugin: "net.ltgt.errorprone" |
| 42 | } |
Bogdan Drutu | 6cb4dd2 | 2017-11-03 09:25:12 +1100 | [diff] [blame] | 43 | apply plugin: 'com.github.sherter.google-java-format' |
Bogdan Drutu | b0e6050 | 2017-03-22 19:23:35 -0700 | [diff] [blame] | 44 | } |
Bogdan Drutu | 00202c0 | 2017-03-21 10:52:28 -0700 | [diff] [blame] | 45 | |
Bogdan Drutu | 1d2eda6 | 2017-06-19 23:54:11 -0700 | [diff] [blame] | 46 | group = "io.opencensus" |
Yang Song | 1cc5554 | 2018-04-27 17:36:44 -0700 | [diff] [blame] | 47 | version = "0.14.0-SNAPSHOT" // CURRENT_OPENCENSUS_VERSION |
Bogdan Drutu | 00202c0 | 2017-03-21 10:52:28 -0700 | [diff] [blame] | 48 | |
| 49 | sourceCompatibility = 1.6 |
| 50 | targetCompatibility = 1.6 |
| 51 | |
| 52 | repositories { |
| 53 | mavenCentral() |
| 54 | mavenLocal() |
| 55 | } |
| 56 | |
Kristen Kozak | a5f4a10 | 2017-12-19 20:02:00 -0800 | [diff] [blame] | 57 | if (useCheckerFramework) { |
| 58 | configurations { |
| 59 | checkerFrameworkJavac { |
| 60 | description = 'a customization of the Open JDK javac compiler with additional support for type annotations' |
| 61 | } |
| 62 | checkerFrameworkAnnotatedJDK { |
| 63 | description = 'a copy of JDK classes with Checker Framework type qualifiers inserted' |
| 64 | } |
| 65 | } |
| 66 | } |
| 67 | |
Bogdan Drutu | 00202c0 | 2017-03-21 10:52:28 -0700 | [diff] [blame] | 68 | [compileJava, compileTestJava].each() { |
Kristen Kozak | ebb2d1d | 2018-02-26 16:07:52 -0800 | [diff] [blame] | 69 | // We suppress the "try" warning because it disallows managing an auto-closeable with |
| 70 | // try-with-resources without referencing the auto-closeable within the try block. |
Kristen Kozak | 9cb2384 | 2017-03-21 17:51:20 -0700 | [diff] [blame] | 71 | // We suppress the "processing" warning as suggested in |
| 72 | // https://groups.google.com/forum/#!topic/bazel-discuss/_R3A9TJSoPM |
| 73 | it.options.compilerArgs += ["-Xlint:all", "-Xlint:-try", "-Xlint:-processing"] |
Kristen Kozak | a5f4a10 | 2017-12-19 20:02:00 -0800 | [diff] [blame] | 74 | if (useErrorProne) { |
| 75 | if (JavaVersion.current().isJava8Compatible()) { |
| 76 | it.options.compilerArgs += ["-XepDisableWarningsInGeneratedCode"] |
Bogdan Drutu | 709d97a | 2018-05-30 16:32:34 -0700 | [diff] [blame] | 77 | // Exclude generated protobuf from error-prone checks. |
| 78 | it.options.compilerArgs += ["-XepExcludedPaths:.*/gen_gradle/.*"] |
Kristen Kozak | a5f4a10 | 2017-12-19 20:02:00 -0800 | [diff] [blame] | 79 | // TODO(bdrutu): Read files directly instead of reading from properties. |
| 80 | if (rootProject.hasProperty("errorProneWarnings")) { |
| 81 | it.options.compilerArgs += rootProject.properties["errorProneWarnings"].split(',').collect { |
| 82 | it as String |
| 83 | } |
| 84 | } |
| 85 | if (rootProject.hasProperty("errorProneExperimentalErrors")) { |
| 86 | it.options.compilerArgs += rootProject.properties["errorProneExperimentalErrors"].split(',').collect { |
| 87 | it as String |
| 88 | } |
| 89 | } |
| 90 | if (rootProject.hasProperty("errorProneExperimentalWarnings")) { |
| 91 | it.options.compilerArgs += rootProject.properties["errorProneExperimentalWarnings"].split(',').collect { |
| 92 | it as String |
| 93 | } |
| 94 | } |
| 95 | if (rootProject.hasProperty("errorProneExperimentalSuggestions")) { |
| 96 | it.options.compilerArgs += rootProject.properties["errorProneExperimentalSuggestions"].split(',').collect { |
| 97 | it as String |
| 98 | } |
Bogdan Drutu | 14920b4 | 2017-03-23 17:13:53 -0700 | [diff] [blame] | 99 | } |
| 100 | } |
Kristen Kozak | a5f4a10 | 2017-12-19 20:02:00 -0800 | [diff] [blame] | 101 | } |
| 102 | if (useCheckerFramework) { |
| 103 | it.options.compilerArgs += [ |
Kristen Kozak | 3c52606 | 2017-12-28 12:27:22 -0800 | [diff] [blame] | 104 | '-processor', |
| 105 | 'com.google.auto.value.processor.AutoValueProcessor,org.checkerframework.checker.nullness.NullnessChecker', |
| 106 | "-Astubs=$rootDir/checker-framework/stubs" |
Kristen Kozak | a5f4a10 | 2017-12-19 20:02:00 -0800 | [diff] [blame] | 107 | ] |
Bogdan Drutu | 14920b4 | 2017-03-23 17:13:53 -0700 | [diff] [blame] | 108 | } |
Bogdan Drutu | 00202c0 | 2017-03-21 10:52:28 -0700 | [diff] [blame] | 109 | it.options.encoding = "UTF-8" |
Bogdan Drutu | 709d97a | 2018-05-30 16:32:34 -0700 | [diff] [blame] | 110 | // Protobuf-generated code produces some warnings. |
| 111 | // https://github.com/google/protobuf/issues/2718 |
| 112 | it.options.compilerArgs += ["-Xlint:-cast"] |
Kristen Kozak | 3b57717 | 2018-02-26 16:15:04 -0800 | [diff] [blame] | 113 | if (!JavaVersion.current().isJava9()) { |
| 114 | // TODO(sebright): Enable -Werror for Java 9 once we upgrade AutoValue (issue #1017). |
Bogdan Drutu | b0e6050 | 2017-03-22 19:23:35 -0700 | [diff] [blame] | 115 | it.options.compilerArgs += ["-Werror"] |
| 116 | } |
Kristen Kozak | 3b57717 | 2018-02-26 16:15:04 -0800 | [diff] [blame] | 117 | if (JavaVersion.current().isJava7()) { |
| 118 | // Suppress all deprecation warnings with Java 7, since there are some bugs in its handling of |
| 119 | // @SuppressWarnings. See |
| 120 | // https://stackoverflow.com/questions/26921774/how-to-avoid-deprecation-warnings-when-suppresswarningsdeprecation-doesnt |
| 121 | it.options.compilerArgs += ["-Xlint:-deprecation"] |
| 122 | |
| 123 | // TODO(bdrutu): Enable for Java 7 when fix the issue with configuring bootstrap class. |
| 124 | // [options] bootstrap class path not set in conjunction with -source 1.6 |
| 125 | it.options.compilerArgs += ["-Xlint:-options"] |
| 126 | } |
| 127 | if (JavaVersion.current().isJava9()) { |
| 128 | // TODO(sebright): Currently, building with Java 9 produces the following "options" warnings: |
| 129 | // |
| 130 | // :opencensus-api:compileJavawarning: [options] bootstrap class path not set in conjunction with -source 1.6 |
| 131 | // warning: [options] source value 1.6 is obsolete and will be removed in a future release |
| 132 | // warning: [options] target value 1.6 is obsolete and will be removed in a future release |
| 133 | it.options.compilerArgs += ["-Xlint:-options"] |
| 134 | } |
Bogdan Drutu | 00202c0 | 2017-03-21 10:52:28 -0700 | [diff] [blame] | 135 | } |
| 136 | |
| 137 | compileTestJava { |
| 138 | // serialVersionUID is basically guaranteed to be useless in tests |
| 139 | options.compilerArgs += ["-Xlint:-serial"] |
| 140 | // It undeprecates DoubleSubject.isEqualTo(Double). |
| 141 | options.compilerArgs += ["-Xlint:-deprecation"] |
Bogdan Drutu | 00202c0 | 2017-03-21 10:52:28 -0700 | [diff] [blame] | 142 | } |
| 143 | |
| 144 | jar.manifest { |
| 145 | attributes('Implementation-Title': name, |
| 146 | 'Implementation-Version': version, |
| 147 | 'Built-By': System.getProperty('user.name'), |
| 148 | 'Built-JDK': System.getProperty('java.version'), |
| 149 | 'Source-Compatibility': sourceCompatibility, |
| 150 | 'Target-Compatibility': targetCompatibility) |
| 151 | } |
| 152 | |
| 153 | javadoc.options { |
| 154 | encoding = 'UTF-8' |
| 155 | links 'https://docs.oracle.com/javase/8/docs/api/' |
| 156 | } |
| 157 | |
| 158 | ext { |
Bogdan Drutu | 709d97a | 2018-05-30 16:32:34 -0700 | [diff] [blame] | 159 | appengineVersion = '1.9.63' |
Kristen Kozak | 9cb2384 | 2017-03-21 17:51:20 -0700 | [diff] [blame] | 160 | autoValueVersion = '1.4' |
Stefan Schmidt | 82f859b | 2017-07-14 21:50:37 +0200 | [diff] [blame] | 161 | findBugsVersion = '3.0.1' |
Bogdan Drutu | 26232c4 | 2018-01-17 10:03:55 -0800 | [diff] [blame] | 162 | errorProneVersion = '2.2.0' |
Bogdan Drutu | 1c416c0 | 2018-05-31 06:28:54 -0700 | [diff] [blame^] | 163 | grpcVersion = '1.12.0' |
Yang Song | 422d78f | 2018-03-26 12:07:30 -0700 | [diff] [blame] | 164 | guavaVersion = '20.0' |
Yang Song | 36c018e | 2018-05-09 10:19:09 -0700 | [diff] [blame] | 165 | googleAuthVersion = '0.9.1' |
Bogdan Drutu | 1c416c0 | 2018-05-31 06:28:54 -0700 | [diff] [blame^] | 166 | googleCloudVersion = '0.49.0-beta' |
Maxime Petazzoni | 64d0583 | 2018-01-17 09:09:13 -0800 | [diff] [blame] | 167 | signalfxVersion = '0.0.39' |
Yang Song | f30f808 | 2018-05-30 10:35:04 -0700 | [diff] [blame] | 168 | prometheusVersion = '0.4.0' |
Bogdan Drutu | 709d97a | 2018-05-30 16:32:34 -0700 | [diff] [blame] | 169 | protobufVersion = '3.5.1' |
Bogdan Drutu | 490dfe8 | 2018-02-15 20:15:39 -0800 | [diff] [blame] | 170 | zipkinReporterVersion = '2.3.2' |
Bogdan Drutu | 1c416c0 | 2018-05-31 06:28:54 -0700 | [diff] [blame^] | 171 | jaegerReporterVersion = '0.27.0' |
Bogdan Drutu | 00202c0 | 2017-03-21 10:52:28 -0700 | [diff] [blame] | 172 | |
| 173 | libraries = [ |
Bogdan Drutu | 709d97a | 2018-05-30 16:32:34 -0700 | [diff] [blame] | 174 | appengine_api: "com.google.appengine:appengine-api-1.0-sdk:${appengineVersion}", |
Bogdan Drutu | 31b3fdd | 2017-08-16 18:57:26 -0700 | [diff] [blame] | 175 | auto_value: "com.google.auto.value:auto-value:${autoValueVersion}", |
| 176 | auto_service: 'com.google.auto.service:auto-service:1.0-rc3', |
Stefan Schmidt | ee1fd02 | 2018-03-05 20:39:48 +0100 | [diff] [blame] | 177 | byte_buddy: 'net.bytebuddy:byte-buddy:1.7.11', |
Stefan Schmidt | cdd4ce2 | 2017-11-20 20:59:30 +0100 | [diff] [blame] | 178 | config: 'com.typesafe:config:1.2.1', |
Yang Song | 37fe5d3 | 2018-03-21 14:52:11 -0700 | [diff] [blame] | 179 | disruptor: 'com.lmax:disruptor:3.4.1', |
Kristen Kozak | ba78379 | 2017-11-10 18:28:44 -0800 | [diff] [blame] | 180 | errorprone: "com.google.errorprone:error_prone_annotations:${errorProneVersion}", |
Bogdan Drutu | 31b3fdd | 2017-08-16 18:57:26 -0700 | [diff] [blame] | 181 | findbugs_annotations: "com.google.code.findbugs:annotations:${findBugsVersion}", |
Bogdan Drutu | 61178e9 | 2017-09-20 09:41:37 -0700 | [diff] [blame] | 182 | google_auth: "com.google.auth:google-auth-library-credentials:${googleAuthVersion}", |
| 183 | google_cloud_trace: "com.google.cloud:google-cloud-trace:${googleCloudVersion}", |
Adrian Cole | d05056c | 2017-09-24 10:46:17 +0800 | [diff] [blame] | 184 | zipkin_reporter: "io.zipkin.reporter2:zipkin-reporter:${zipkinReporterVersion}", |
| 185 | zipkin_urlconnection: "io.zipkin.reporter2:zipkin-sender-urlconnection:${zipkinReporterVersion}", |
Marc Carré | 8190805 | 2018-03-16 01:03:49 +0000 | [diff] [blame] | 186 | jaeger_reporter: "com.uber.jaeger:jaeger-core:${jaegerReporterVersion}", |
Yang Song | 6fe9afd | 2017-11-08 18:17:08 -0800 | [diff] [blame] | 187 | google_cloud_monitoring: "com.google.cloud:google-cloud-monitoring:${googleCloudVersion}", |
Bogdan Drutu | 8781dbb | 2017-09-05 10:40:42 -0700 | [diff] [blame] | 188 | grpc_context: "io.grpc:grpc-context:${grpcVersion}", |
| 189 | grpc_core: "io.grpc:grpc-core:${grpcVersion}", |
Bogdan Drutu | 31b3fdd | 2017-08-16 18:57:26 -0700 | [diff] [blame] | 190 | guava: "com.google.guava:guava:${guavaVersion}", |
| 191 | jsr305: "com.google.code.findbugs:jsr305:${findBugsVersion}", |
Maxime Petazzoni | 64d0583 | 2018-01-17 09:09:13 -0800 | [diff] [blame] | 192 | signalfx_java: "com.signalfx.public:signalfx-java:${signalfxVersion}", |
Yang Song | b0d3967 | 2018-02-13 12:47:32 -0800 | [diff] [blame] | 193 | prometheus_simpleclient: "io.prometheus:simpleclient:${prometheusVersion}", |
Bogdan Drutu | 709d97a | 2018-05-30 16:32:34 -0700 | [diff] [blame] | 194 | protobuf: "com.google.protobuf:protobuf-java:${protobufVersion}", |
Bogdan Drutu | 00202c0 | 2017-03-21 10:52:28 -0700 | [diff] [blame] | 195 | |
| 196 | // Test dependencies. |
Bogdan Drutu | 31b3fdd | 2017-08-16 18:57:26 -0700 | [diff] [blame] | 197 | guava_testlib: "com.google.guava:guava-testlib:${guavaVersion}", |
Bogdan Drutu | bbe1d0f | 2017-10-26 14:05:26 -0700 | [diff] [blame] | 198 | junit: 'junit:junit:4.12', |
Kristen Kozak | 23be8f0 | 2017-11-10 15:01:23 -0800 | [diff] [blame] | 199 | mockito: 'org.mockito:mockito-core:1.9.5', |
Bogdan Drutu | 31b3fdd | 2017-08-16 18:57:26 -0700 | [diff] [blame] | 200 | truth: 'com.google.truth:truth:0.30', |
Bogdan Drutu | 00202c0 | 2017-03-21 10:52:28 -0700 | [diff] [blame] | 201 | ] |
| 202 | } |
| 203 | |
Bogdan Drutu | 0eaaccb | 2018-01-23 19:38:02 -0800 | [diff] [blame] | 204 | configurations { |
| 205 | compile { |
| 206 | // Detect Maven Enforcer's dependencyConvergence failures. We only |
| 207 | // care for artifacts used as libraries by others. |
Bogdan Drutu | 13cf2b8 | 2018-02-26 15:24:26 -0800 | [diff] [blame] | 208 | if (!(project.name in ['benchmarks', 'opencensus-all', |
| 209 | 'opencensus-exporter-stats-stackdriver', |
Bogdan Drutu | 1c416c0 | 2018-05-31 06:28:54 -0700 | [diff] [blame^] | 210 | 'opencensus-exporter-trace-stackdriver', |
| 211 | 'opencensus-exporter-trace-jaeger'])) { |
Bogdan Drutu | 0eaaccb | 2018-01-23 19:38:02 -0800 | [diff] [blame] | 212 | resolutionStrategy.failOnVersionConflict() |
| 213 | } |
| 214 | } |
| 215 | } |
| 216 | |
Bogdan Drutu | 00202c0 | 2017-03-21 10:52:28 -0700 | [diff] [blame] | 217 | dependencies { |
Kristen Kozak | a5f4a10 | 2017-12-19 20:02:00 -0800 | [diff] [blame] | 218 | if (useCheckerFramework) { |
Kristen Kozak | c917cc2 | 2018-05-02 18:33:52 -0700 | [diff] [blame] | 219 | ext.checkerFrameworkVersion = '2.5.1' |
Kristen Kozak | 3d3a446 | 2018-04-16 15:50:56 -0700 | [diff] [blame] | 220 | |
| 221 | // 2.4.0 is the last version of the Checker Framework compiler that supports annotations |
| 222 | // in comments, though it should continue to work with newer versions of the Checker Framework. |
| 223 | // See |
| 224 | // https://github.com/census-instrumentation/opencensus-java/pull/1112#issuecomment-381366366. |
| 225 | ext.checkerFrameworkCompilerVersion = '2.4.0' |
| 226 | |
Kristen Kozak | a5f4a10 | 2017-12-19 20:02:00 -0800 | [diff] [blame] | 227 | ext.jdkVersion = 'jdk8' |
| 228 | checkerFrameworkAnnotatedJDK "org.checkerframework:${jdkVersion}:${checkerFrameworkVersion}" |
Kristen Kozak | 3d3a446 | 2018-04-16 15:50:56 -0700 | [diff] [blame] | 229 | checkerFrameworkJavac "org.checkerframework:compiler:${checkerFrameworkCompilerVersion}" |
Kristen Kozak | a5f4a10 | 2017-12-19 20:02:00 -0800 | [diff] [blame] | 230 | compileOnly "org.checkerframework:checker:${checkerFrameworkVersion}" |
| 231 | compile "org.checkerframework:checker-qual:${checkerFrameworkVersion}" |
| 232 | compileOnly libraries.auto_value |
| 233 | } |
| 234 | |
Kristen Kozak | 1bb75e5 | 2018-03-26 16:49:03 -0700 | [diff] [blame] | 235 | compileOnly libraries.errorprone, |
| 236 | libraries.jsr305 |
Bogdan Drutu | 07f0dd2 | 2017-03-22 08:54:53 -0700 | [diff] [blame] | 237 | |
Bogdan Drutu | 00202c0 | 2017-03-21 10:52:28 -0700 | [diff] [blame] | 238 | testCompile libraries.guava_testlib, |
| 239 | libraries.junit, |
| 240 | libraries.mockito, |
| 241 | libraries.truth |
| 242 | |
Kristen Kozak | a5f4a10 | 2017-12-19 20:02:00 -0800 | [diff] [blame] | 243 | if (useErrorProne && JavaVersion.current().isJava8Compatible()) { |
Bogdan Drutu | b0e6050 | 2017-03-22 19:23:35 -0700 | [diff] [blame] | 244 | // The ErrorProne plugin defaults to the latest, which would break our |
| 245 | // build if error prone releases a new version with a new check |
Kristen Kozak | ba78379 | 2017-11-10 18:28:44 -0800 | [diff] [blame] | 246 | errorprone "com.google.errorprone:error_prone_core:${errorProneVersion}" |
Bogdan Drutu | b0e6050 | 2017-03-22 19:23:35 -0700 | [diff] [blame] | 247 | } |
Bogdan Drutu | 00202c0 | 2017-03-21 10:52:28 -0700 | [diff] [blame] | 248 | } |
| 249 | |
Bogdan Drutu | 07f0dd2 | 2017-03-22 08:54:53 -0700 | [diff] [blame] | 250 | findbugs { |
Stefan Schmidt | 82f859b | 2017-07-14 21:50:37 +0200 | [diff] [blame] | 251 | toolVersion = findBugsVersion |
Bogdan Drutu | eba004c | 2017-04-13 13:52:39 -0700 | [diff] [blame] | 252 | ignoreFailures = false // bug free or it doesn't ship! |
Bogdan Drutu | 07f0dd2 | 2017-03-22 08:54:53 -0700 | [diff] [blame] | 253 | effort = 'max' |
Bogdan Drutu | eba004c | 2017-04-13 13:52:39 -0700 | [diff] [blame] | 254 | reportLevel = 'low' // low = sensitive to even minor mistakes |
| 255 | omitVisitors = [] // bugs that we want to ignore |
Kristen Kozak | b27b1c7 | 2017-04-12 16:38:04 -0700 | [diff] [blame] | 256 | excludeFilter = file("$rootDir/findbugs-exclude.xml") |
Bogdan Drutu | 07f0dd2 | 2017-03-22 08:54:53 -0700 | [diff] [blame] | 257 | } |
Bogdan Drutu | cca79a3 | 2017-03-27 14:17:16 -0700 | [diff] [blame] | 258 | // Generate html report for findbugs. |
| 259 | findbugsMain { |
| 260 | reports { |
| 261 | xml.enabled = false |
| 262 | html.enabled = true |
| 263 | } |
| 264 | } |
Bogdan Drutu | 07f0dd2 | 2017-03-22 08:54:53 -0700 | [diff] [blame] | 265 | |
Bogdan Drutu | 00202c0 | 2017-03-21 10:52:28 -0700 | [diff] [blame] | 266 | checkstyle { |
Bogdan Drutu | b216db3 | 2017-08-24 22:09:37 -0700 | [diff] [blame] | 267 | configFile = file("$rootDir/buildscripts/checkstyle.xml") |
Bogdan Drutu | 8d4372e | 2017-09-02 13:21:17 -0700 | [diff] [blame] | 268 | toolVersion = "8.0" |
Bogdan Drutu | 00202c0 | 2017-03-21 10:52:28 -0700 | [diff] [blame] | 269 | ignoreFailures = false |
| 270 | if (rootProject.hasProperty("checkstyle.ignoreFailures")) { |
| 271 | ignoreFailures = rootProject.properties["checkstyle.ignoreFailures"].toBoolean() |
| 272 | } |
| 273 | configProperties["rootDir"] = rootDir |
| 274 | } |
| 275 | |
Bogdan Drutu | b0e6050 | 2017-03-22 19:23:35 -0700 | [diff] [blame] | 276 | // Disable checkstyle if no java8. |
| 277 | checkstyleMain.enabled = JavaVersion.current().isJava8Compatible() |
| 278 | checkstyleTest.enabled = JavaVersion.current().isJava8Compatible() |
| 279 | |
Bogdan Drutu | 6cb4dd2 | 2017-11-03 09:25:12 +1100 | [diff] [blame] | 280 | // Google formatter works only on java8. |
| 281 | if (JavaVersion.current().isJava8Compatible()) { |
| 282 | googleJavaFormat { |
| 283 | toolVersion '1.5' |
| 284 | } |
| 285 | |
Stefan Schmidt | fe8b990 | 2017-11-03 17:26:09 +0100 | [diff] [blame] | 286 | afterEvaluate { // Allow subproject to add more source sets. |
| 287 | tasks.googleJavaFormat { |
| 288 | source = sourceSets*.allJava |
| 289 | include '**/*.java' |
| 290 | } |
Bogdan Drutu | 6cb4dd2 | 2017-11-03 09:25:12 +1100 | [diff] [blame] | 291 | |
Stefan Schmidt | fe8b990 | 2017-11-03 17:26:09 +0100 | [diff] [blame] | 292 | tasks.verifyGoogleJavaFormat { |
| 293 | source = sourceSets*.allJava |
| 294 | include '**/*.java' |
| 295 | } |
Bogdan Drutu | 6cb4dd2 | 2017-11-03 09:25:12 +1100 | [diff] [blame] | 296 | } |
| 297 | } |
| 298 | |
Bogdan Drutu | eba004c | 2017-04-13 13:52:39 -0700 | [diff] [blame] | 299 | signing { |
| 300 | required false |
| 301 | sign configurations.archives |
| 302 | } |
| 303 | |
| 304 | task javadocJar(type: Jar) { |
| 305 | classifier = 'javadoc' |
| 306 | from javadoc |
| 307 | } |
| 308 | |
| 309 | task sourcesJar(type: Jar) { |
| 310 | classifier = 'sources' |
| 311 | from sourceSets.main.allSource |
| 312 | } |
| 313 | |
| 314 | artifacts { |
| 315 | archives javadocJar, sourcesJar |
| 316 | } |
| 317 | |
| 318 | uploadArchives { |
| 319 | repositories { |
| 320 | mavenDeployer { |
| 321 | beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } |
| 322 | |
| 323 | def configureAuth = { |
| 324 | if (rootProject.hasProperty('ossrhUsername') && rootProject.hasProperty('ossrhPassword')) { |
| 325 | authentication(userName:rootProject.ossrhUsername, password: rootProject.ossrhPassword) |
| 326 | } |
| 327 | } |
| 328 | |
| 329 | repository(url: "https://oss.sonatype.org/service/local/staging/deploy/maven2/", configureAuth) |
| 330 | |
| 331 | snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/", configureAuth) |
| 332 | |
| 333 | pom.project { |
Bogdan Drutu | 1d2eda6 | 2017-06-19 23:54:11 -0700 | [diff] [blame] | 334 | name "OpenCensus" |
Bogdan Drutu | eba004c | 2017-04-13 13:52:39 -0700 | [diff] [blame] | 335 | packaging 'jar' |
Bogdan Drutu | eba004c | 2017-04-13 13:52:39 -0700 | [diff] [blame] | 336 | description project.description |
Bogdan Drutu | 95c9b20 | 2017-06-21 23:56:49 -0700 | [diff] [blame] | 337 | url 'https://github.com/census-instrumentation/opencensus-java' |
Bogdan Drutu | eba004c | 2017-04-13 13:52:39 -0700 | [diff] [blame] | 338 | |
| 339 | scm { |
Bogdan Drutu | 95c9b20 | 2017-06-21 23:56:49 -0700 | [diff] [blame] | 340 | connection 'scm:svn:https://github.com/census-instrumentation/opencensus-java' |
| 341 | developerConnection 'scm:git:git@github.com/census-instrumentation/opencensus-java' |
| 342 | url 'https://github.com/census-instrumentation/opencensus-java' |
Bogdan Drutu | eba004c | 2017-04-13 13:52:39 -0700 | [diff] [blame] | 343 | } |
| 344 | |
| 345 | licenses { |
| 346 | license { |
| 347 | name 'The Apache License, Version 2.0' |
| 348 | url 'http://www.apache.org/licenses/LICENSE-2.0.txt' |
| 349 | } |
| 350 | } |
| 351 | |
| 352 | developers { |
| 353 | developer { |
Bogdan Drutu | 1d2eda6 | 2017-06-19 23:54:11 -0700 | [diff] [blame] | 354 | id 'io.opencensus' |
| 355 | name 'OpenCensus Contributors' |
Bogdan Drutu | dca6c29 | 2017-10-27 14:09:23 -0700 | [diff] [blame] | 356 | email 'census-developers@googlegroups.com' |
Bogdan Drutu | 1d2eda6 | 2017-06-19 23:54:11 -0700 | [diff] [blame] | 357 | url 'opencensus.io' |
Bogdan Drutu | eba004c | 2017-04-13 13:52:39 -0700 | [diff] [blame] | 358 | // https://issues.gradle.org/browse/GRADLE-2719 |
Bogdan Drutu | 6c2b675 | 2018-02-15 17:10:23 -0800 | [diff] [blame] | 359 | organization = 'OpenCensus Authors' |
| 360 | organizationUrl 'https://www.opencensus.io' |
Bogdan Drutu | eba004c | 2017-04-13 13:52:39 -0700 | [diff] [blame] | 361 | } |
| 362 | } |
| 363 | } |
| 364 | } |
| 365 | } |
| 366 | } |
Bogdan Drutu | 6cb4dd2 | 2017-11-03 09:25:12 +1100 | [diff] [blame] | 367 | |
Stefan Schmidt | 973ee9b | 2017-08-24 22:34:33 +0200 | [diff] [blame] | 368 | // Upload the following artifacts only: |
| 369 | uploadArchives.onlyIf { |
| 370 | name in ['opencensus-api', |
| 371 | 'opencensus-contrib-agent', |
Bogdan Drutu | 709d97a | 2018-05-30 16:32:34 -0700 | [diff] [blame] | 372 | 'opencensus-contrib-appengine-standard-util', |
sebright | 5298e6c | 2017-10-27 10:43:00 -0700 | [diff] [blame] | 373 | 'opencensus-contrib-grpc-metrics', |
Bogdan Drutu | 8781dbb | 2017-09-05 10:40:42 -0700 | [diff] [blame] | 374 | 'opencensus-contrib-grpc-util', |
Bogdan Drutu | c90bec7 | 2018-01-25 15:13:17 -0800 | [diff] [blame] | 375 | 'opencensus-contrib-http-util', |
Yang Song | 86dadee | 2018-04-26 09:53:32 -0700 | [diff] [blame] | 376 | 'opencensus-contrib-monitored-resource-util', |
Bogdan Drutu | a851696 | 2017-08-28 13:10:25 -0700 | [diff] [blame] | 377 | 'opencensus-contrib-zpages', |
Yang Song | b0d3967 | 2018-02-13 12:47:32 -0800 | [diff] [blame] | 378 | 'opencensus-exporter-stats-prometheus', |
Maxime Petazzoni | 64d0583 | 2018-01-17 09:09:13 -0800 | [diff] [blame] | 379 | 'opencensus-exporter-stats-signalfx', |
Yang Song | b55bb81 | 2017-11-16 17:57:32 -0800 | [diff] [blame] | 380 | 'opencensus-exporter-stats-stackdriver', |
Fabian Lange | 17a1a1a | 2018-02-09 14:33:30 -0500 | [diff] [blame] | 381 | 'opencensus-exporter-trace-instana', |
Bogdan Drutu | a851696 | 2017-08-28 13:10:25 -0700 | [diff] [blame] | 382 | 'opencensus-exporter-trace-logging', |
| 383 | 'opencensus-exporter-trace-stackdriver', |
Bogdan Drutu | 0b4f14a | 2017-10-27 11:04:41 -0700 | [diff] [blame] | 384 | 'opencensus-exporter-trace-zipkin', |
Marc Carré | 8190805 | 2018-03-16 01:03:49 +0000 | [diff] [blame] | 385 | 'opencensus-exporter-trace-jaeger', |
Stefan Schmidt | 973ee9b | 2017-08-24 22:34:33 +0200 | [diff] [blame] | 386 | 'opencensus-impl-core', |
| 387 | 'opencensus-impl-lite', |
| 388 | 'opencensus-impl', |
| 389 | 'opencensus-testing'] |
| 390 | } |
Bogdan Drutu | eba004c | 2017-04-13 13:52:39 -0700 | [diff] [blame] | 391 | |
Bogdan Drutu | 00202c0 | 2017-03-21 10:52:28 -0700 | [diff] [blame] | 392 | // At a test failure, log the stack trace to the console so that we don't |
| 393 | // have to open the HTML in a browser. |
| 394 | test { |
| 395 | testLogging { |
| 396 | exceptionFormat = 'full' |
| 397 | showExceptions true |
| 398 | showCauses true |
| 399 | showStackTraces true |
| 400 | } |
| 401 | maxHeapSize = '1500m' |
| 402 | } |
Kristen Kozak | a5f4a10 | 2017-12-19 20:02:00 -0800 | [diff] [blame] | 403 | |
| 404 | if (useCheckerFramework) { |
| 405 | allprojects { |
| 406 | tasks.withType(JavaCompile).all { JavaCompile compile -> |
| 407 | compile.doFirst { |
| 408 | compile.options.compilerArgs += [ |
Kristen Kozak | 192d43a | 2018-03-27 12:28:55 -0700 | [diff] [blame] | 409 | '-Xmaxerrs', '10000', |
| 410 | "-Xbootclasspath/p:${configurations.checkerFrameworkAnnotatedJDK.asPath}", |
Bogdan Drutu | 709d97a | 2018-05-30 16:32:34 -0700 | [diff] [blame] | 411 | "-AskipDefs=[\\.AutoValue_|\\.TraceIdProto]", |
Kristen Kozak | d45a961 | 2018-04-04 13:50:40 -0700 | [diff] [blame] | 412 | "-AinvariantArrays" |
Kristen Kozak | a5f4a10 | 2017-12-19 20:02:00 -0800 | [diff] [blame] | 413 | ] |
| 414 | options.fork = true |
| 415 | options.forkOptions.jvmArgs += ["-Xbootclasspath/p:${configurations.checkerFrameworkJavac.asPath}"] |
| 416 | } |
| 417 | } |
| 418 | } |
| 419 | } |
Stefan Schmidt | 7d681cc | 2018-03-09 21:41:09 +0100 | [diff] [blame] | 420 | |
| 421 | // For projects that depend on gRPC during test execution, make sure to |
| 422 | // also configure ALPN if running on a platform (e.g. FreeBSD) that is not |
| 423 | // supported by io.netty:netty-tcnative-boringssl-static:jar. Also see: |
| 424 | // https://github.com/grpc/grpc-java/blob/master/SECURITY.md#tls-with-jdk-jetty-alpnnpn |
| 425 | if (project.name in ['opencensus-exporter-stats-stackdriver', |
| 426 | 'opencensus-exporter-trace-stackdriver']) { |
| 427 | def os = org.gradle.internal.os.OperatingSystem.current() |
| 428 | if (!os.isLinux() && !os.isWindows() && !os.isMacOsX()) { |
| 429 | configurations { |
| 430 | alpn |
| 431 | } |
| 432 | dependencies { |
| 433 | alpn 'org.mortbay.jetty.alpn:jetty-alpn-agent:2.0.7' |
| 434 | } |
| 435 | test { |
| 436 | jvmArgs "-javaagent:${configurations.alpn.asPath}" |
| 437 | } |
| 438 | } |
| 439 | } |
Bogdan Drutu | 00202c0 | 2017-03-21 10:52:28 -0700 | [diff] [blame] | 440 | } |