Kun Zhang | 4bc2d6d | 2015-04-17 10:49:11 -0700 | [diff] [blame] | 1 | buildscript { |
ZHANG Dapeng | 5ce10f0 | 2018-06-11 18:35:18 -0700 | [diff] [blame] | 2 | repositories { |
| 3 | mavenLocal() |
| 4 | maven { url "https://plugins.gradle.org/m2/" } |
Eric Anderson | 675080b | 2017-02-24 14:53:23 -0800 | [diff] [blame] | 5 | } |
ZHANG Dapeng | 5ce10f0 | 2018-06-11 18:35:18 -0700 | [diff] [blame] | 6 | dependencies { |
| 7 | classpath "com.diffplug.spotless:spotless-plugin-gradle:3.13.0" |
| 8 | classpath 'com.google.gradle:osdetector-gradle-plugin:1.4.0' |
| 9 | classpath 'ru.vyarus:gradle-animalsniffer-plugin:1.4.0' |
| 10 | classpath 'net.ltgt.gradle:gradle-errorprone-plugin:0.0.13' |
| 11 | classpath 'net.ltgt.gradle:gradle-apt-plugin:0.13' |
| 12 | classpath "me.champeau.gradle:jmh-gradle-plugin:0.4.5" |
| 13 | classpath 'me.champeau.gradle:japicmp-gradle-plugin:0.2.5' |
| 14 | } |
Kun Zhang | 4bc2d6d | 2015-04-17 10:49:11 -0700 | [diff] [blame] | 15 | } |
Eric Anderson | b938ba5 | 2015-02-28 09:59:25 -0800 | [diff] [blame] | 16 | |
Louis Ryan | 540b4d3 | 2015-09-04 13:26:24 -0700 | [diff] [blame] | 17 | subprojects { |
Eric Anderson | c3e8dae | 2015-01-30 14:58:07 -0800 | [diff] [blame] | 18 | apply plugin: "checkstyle" |
nathanmittler | 164b734 | 2014-12-15 09:58:05 -0800 | [diff] [blame] | 19 | apply plugin: "java" |
| 20 | apply plugin: "maven" |
nmittler | 52f4220 | 2015-01-21 14:30:14 -0800 | [diff] [blame] | 21 | apply plugin: "idea" |
Eric Anderson | 192144e | 2015-03-02 13:31:14 -0800 | [diff] [blame] | 22 | apply plugin: "signing" |
Eric Anderson | 041cdb1 | 2015-05-05 12:29:26 -0700 | [diff] [blame] | 23 | apply plugin: "jacoco" |
nathanmittler | 164b734 | 2014-12-15 09:58:05 -0800 | [diff] [blame] | 24 | |
Eric Anderson | 6164b7b | 2017-08-26 17:10:18 -0700 | [diff] [blame] | 25 | apply plugin: "me.champeau.gradle.jmh" |
nmittler | c4bcf14 | 2015-09-16 15:15:10 -0700 | [diff] [blame] | 26 | apply plugin: "com.google.osdetector" |
Eric Anderson | 42aa64c | 2017-02-02 13:48:12 -0800 | [diff] [blame] | 27 | // The plugin only has an effect if a signature is specified |
| 28 | apply plugin: "ru.vyarus.animalsniffer" |
zpencer | 37e6f5f | 2018-07-19 13:35:27 -0700 | [diff] [blame] | 29 | // jdk10 not supported by errorprone: https://github.com/google/error-prone/issues/860 |
| 30 | if (!JavaVersion.current().isJava10Compatible() && |
| 31 | rootProject.properties.get('errorProne', true)) { |
ZHANG Dapeng | 5ce10f0 | 2018-06-11 18:35:18 -0700 | [diff] [blame] | 32 | apply plugin: "net.ltgt.errorprone" |
| 33 | apply plugin: "net.ltgt.apt" |
Eric Anderson | 982541b | 2017-04-26 13:33:27 -0700 | [diff] [blame] | 34 | |
ZHANG Dapeng | 5ce10f0 | 2018-06-11 18:35:18 -0700 | [diff] [blame] | 35 | dependencies { |
| 36 | // The ErrorProne plugin defaults to the latest, which would break our |
| 37 | // build if error prone releases a new version with a new check |
| 38 | errorprone 'com.google.errorprone:error_prone_core:2.2.0' |
| 39 | apt 'com.google.guava:guava-beta-checker:1.0' |
Eric Anderson | 982541b | 2017-04-26 13:33:27 -0700 | [diff] [blame] | 40 | } |
ZHANG Dapeng | 5ce10f0 | 2018-06-11 18:35:18 -0700 | [diff] [blame] | 41 | } else { |
| 42 | // Remove per-project error-prone checker config |
| 43 | allprojects { |
| 44 | afterEvaluate { project -> |
| 45 | project.tasks.withType(JavaCompile) { |
| 46 | options.compilerArgs.removeAll { it.startsWith("-Xep") } |
| 47 | } |
| 48 | } |
| 49 | } |
Eric Anderson | 675080b | 2017-02-24 14:53:23 -0800 | [diff] [blame] | 50 | } |
zpencer | 5713ebc | 2017-07-15 12:41:20 -0700 | [diff] [blame] | 51 | // TODO(zpencer): remove when intellij 2017.2 is released |
| 52 | // https://github.com/gradle/gradle/issues/2315 |
| 53 | idea.module.inheritOutputDirs = true |
nmittler | c4bcf14 | 2015-09-16 15:15:10 -0700 | [diff] [blame] | 54 | |
nmittler | f831458 | 2015-01-27 10:25:39 -0800 | [diff] [blame] | 55 | group = "io.grpc" |
zpencer | 4335445 | 2018-07-18 10:48:04 -0700 | [diff] [blame] | 56 | version = "1.15.0-SNAPSHOT" // CURRENT_GRPC_VERSION |
nathanmittler | 164b734 | 2014-12-15 09:58:05 -0800 | [diff] [blame] | 57 | |
| 58 | sourceCompatibility = 1.6 |
| 59 | targetCompatibility = 1.6 |
| 60 | |
| 61 | repositories { |
ZHANG Dapeng | 5ce10f0 | 2018-06-11 18:35:18 -0700 | [diff] [blame] | 62 | maven { // The google mirror is less flaky than mavenCentral() |
| 63 | url "https://maven-central.storage-download.googleapis.com/repos/central/data/" } |
zpencer | 066ad3c | 2018-03-01 19:11:24 -0800 | [diff] [blame] | 64 | mavenLocal() |
nathanmittler | 164b734 | 2014-12-15 09:58:05 -0800 | [diff] [blame] | 65 | } |
| 66 | |
ZHANG Dapeng | 5ce10f0 | 2018-06-11 18:35:18 -0700 | [diff] [blame] | 67 | [ |
| 68 | compileJava, |
| 69 | compileTestJava, |
| 70 | compileJmhJava |
| 71 | ].each() { |
| 72 | it.options.compilerArgs += [ |
| 73 | "-Xlint:all", |
| 74 | "-Xlint:-options", |
| 75 | "-Xlint:-path" |
| 76 | ] |
Eric Anderson | 76d0955 | 2015-03-12 15:25:11 -0700 | [diff] [blame] | 77 | it.options.encoding = "UTF-8" |
Eric Anderson | 3c03eb7 | 2016-07-10 11:40:12 -0700 | [diff] [blame] | 78 | if (rootProject.hasProperty('failOnWarnings') && rootProject.failOnWarnings.toBoolean()) { |
| 79 | it.options.compilerArgs += ["-Werror"] |
| 80 | } |
nmittler | 02c953e | 2015-01-26 14:03:11 -0800 | [diff] [blame] | 81 | } |
| 82 | |
Eric Anderson | 641cb35 | 2016-05-24 14:29:52 -0700 | [diff] [blame] | 83 | compileTestJava { |
ZHANG Dapeng | 5ce10f0 | 2018-06-11 18:35:18 -0700 | [diff] [blame] | 84 | // serialVersionUID is basically guaranteed to be useless in our tests |
| 85 | // LinkedList doesn't hurt much in tests and has lots of usages |
| 86 | options.compilerArgs += [ |
| 87 | "-Xlint:-serial", |
| 88 | "-Xep:JdkObsolete:OFF" |
| 89 | ] |
Eric Anderson | 641cb35 | 2016-05-24 14:29:52 -0700 | [diff] [blame] | 90 | } |
| 91 | |
nmittler | 8c1d38a | 2015-06-01 08:31:00 -0700 | [diff] [blame] | 92 | jar.manifest { |
| 93 | attributes('Implementation-Title': name, |
ZHANG Dapeng | 5ce10f0 | 2018-06-11 18:35:18 -0700 | [diff] [blame] | 94 | 'Implementation-Version': version, |
| 95 | 'Built-By': System.getProperty('user.name'), |
| 96 | 'Built-JDK': System.getProperty('java.version'), |
| 97 | 'Source-Compatibility': sourceCompatibility, |
| 98 | 'Target-Compatibility': targetCompatibility) |
nmittler | 8c1d38a | 2015-06-01 08:31:00 -0700 | [diff] [blame] | 99 | } |
| 100 | |
Eric Anderson | 10fb206 | 2015-05-05 10:28:38 -0700 | [diff] [blame] | 101 | javadoc.options { |
| 102 | encoding = 'UTF-8' |
ZHANG Dapeng | 66ebcb1 | 2017-05-17 08:52:07 -0700 | [diff] [blame] | 103 | use = true |
Eric Anderson | 10fb206 | 2015-05-05 10:28:38 -0700 | [diff] [blame] | 104 | links 'https://docs.oracle.com/javase/8/docs/api/' |
| 105 | } |
Eric Anderson | 14444a9 | 2015-03-11 16:44:38 -0700 | [diff] [blame] | 106 | |
Jakob Buchgraber | 7ddcdfd | 2015-02-13 16:21:53 -0800 | [diff] [blame] | 107 | ext { |
Kun Zhang | 6b1e7d6 | 2015-05-07 15:20:44 -0700 | [diff] [blame] | 108 | def exeSuffix = osdetector.os == 'windows' ? ".exe" : "" |
| 109 | protocPluginBaseName = 'protoc-gen-grpc-java' |
Eric Anderson | 46ce409 | 2016-01-26 12:13:06 -0800 | [diff] [blame] | 110 | javaPluginPath = "$rootDir/compiler/build/exe/java_plugin/$protocPluginBaseName$exeSuffix" |
Kun Zhang | 6b1e7d6 | 2015-05-07 15:20:44 -0700 | [diff] [blame] | 111 | |
Carl Mastrangelo | 7d45596 | 2018-07-20 16:36:00 -0700 | [diff] [blame^] | 112 | nettyVersion = '4.1.27.Final' |
Eric Anderson | 5f0ee3a | 2018-03-23 15:45:05 -0700 | [diff] [blame] | 113 | guavaVersion = '20.0' |
Kun Zhang | 86d6412 | 2018-01-05 16:40:20 -0800 | [diff] [blame] | 114 | protobufVersion = '3.5.1' |
| 115 | protocVersion = '3.5.1-1' |
Kun Zhang | e2ed2e8 | 2016-01-27 08:26:19 -0800 | [diff] [blame] | 116 | protobufNanoVersion = '3.0.0-alpha-5' |
Bogdan Drutu | 2a127ce | 2018-06-04 15:27:27 -0700 | [diff] [blame] | 117 | opencensusVersion = '0.12.3' |
Kun Zhang | 6b1e7d6 | 2015-05-07 15:20:44 -0700 | [diff] [blame] | 118 | |
Kun Zhang | 111f6dd | 2015-05-05 16:11:27 -0700 | [diff] [blame] | 119 | configureProtoCompilation = { |
ZHANG Dapeng | 5ce10f0 | 2018-06-11 18:35:18 -0700 | [diff] [blame] | 120 | String generatedSourcePath = "${projectDir}/src/generated" |
| 121 | if (rootProject.childProjects.containsKey('grpc-compiler')) { |
| 122 | // Only when the codegen is built along with the project, will we be able to recompile |
| 123 | // the proto files. |
| 124 | project.apply plugin: 'com.google.protobuf' |
| 125 | project.protobuf { |
| 126 | protoc { |
| 127 | if (project.hasProperty('protoc')) { |
| 128 | path = project.protoc |
| 129 | } else { |
| 130 | artifact = "com.google.protobuf:protoc:${protocVersion}" |
| 131 | } |
ZHANG Dapeng | e109125 | 2016-07-21 16:35:18 -0700 | [diff] [blame] | 132 | } |
ZHANG Dapeng | 5ce10f0 | 2018-06-11 18:35:18 -0700 | [diff] [blame] | 133 | plugins { grpc { path = javaPluginPath } } |
| 134 | generateProtoTasks { |
| 135 | all().each { task -> |
| 136 | task.dependsOn ':grpc-compiler:java_pluginExecutable' |
| 137 | // Delete the generated sources first, so that we can be alerted if they are not re-compiled. |
| 138 | task.dependsOn 'deleteGeneratedSource' + task.sourceSet.name |
| 139 | // Recompile protos when the codegen has been changed |
| 140 | task.inputs.file javaPluginPath |
| 141 | // Recompile protos when build.gradle has been changed, because |
| 142 | // it's possible the version of protoc has been changed. |
| 143 | task.inputs.file "${rootProject.projectDir}/build.gradle" |
| 144 | task.plugins { grpc { option 'noversion' } } |
| 145 | } |
| 146 | } |
| 147 | generatedFilesBaseDir = generatedSourcePath |
Kun Zhang | 2cdc5e3 | 2015-05-11 16:58:28 -0700 | [diff] [blame] | 148 | } |
ZHANG Dapeng | 5ce10f0 | 2018-06-11 18:35:18 -0700 | [diff] [blame] | 149 | |
| 150 | sourceSets.each { sourceSet -> |
| 151 | task "deleteGeneratedSource${sourceSet.name}" { |
| 152 | doLast { |
| 153 | project.delete project.fileTree(dir: generatedSourcePath + '/' + sourceSet.name) |
| 154 | } |
| 155 | } |
| 156 | } |
| 157 | } else { |
| 158 | // Otherwise, we just use the checked-in generated code. |
| 159 | project.sourceSets { |
| 160 | main { |
| 161 | java { |
| 162 | srcDir "${generatedSourcePath}/main/java" |
| 163 | srcDir "${generatedSourcePath}/main/javanano" |
| 164 | srcDir "${generatedSourcePath}/main/grpc" |
| 165 | } |
| 166 | } |
| 167 | test { |
| 168 | java { |
| 169 | srcDir "${generatedSourcePath}/test/java" |
| 170 | srcDir "${generatedSourcePath}/test/javanano" |
| 171 | srcDir "${generatedSourcePath}/test/grpc" |
| 172 | } |
| 173 | } |
| 174 | } |
Kun Zhang | 35f77ee | 2015-06-22 16:29:30 -0700 | [diff] [blame] | 175 | } |
| 176 | |
ZHANG Dapeng | 5ce10f0 | 2018-06-11 18:35:18 -0700 | [diff] [blame] | 177 | [ |
| 178 | compileJava, |
| 179 | compileTestJava, |
| 180 | compileJmhJava |
| 181 | ].each() { |
| 182 | // Protobuf-generated code produces some warnings. |
| 183 | // https://github.com/google/protobuf/issues/2718 |
| 184 | it.options.compilerArgs += [ |
| 185 | "-Xlint:-cast", |
| 186 | "-XepExcludedPaths:.*/src/generated/[^/]+/java/.*", |
| 187 | ] |
Kun Zhang | 2cdc5e3 | 2015-05-11 16:58:28 -0700 | [diff] [blame] | 188 | } |
Kun Zhang | 111f6dd | 2015-05-05 16:11:27 -0700 | [diff] [blame] | 189 | } |
| 190 | |
Eric Anderson | 65d73c0 | 2015-05-21 11:54:04 -0700 | [diff] [blame] | 191 | def epoll_suffix = ""; |
| 192 | if (osdetector.classifier in ["linux-x86_64"]) { |
| 193 | // The native code is only pre-compiled on certain platforms. |
| 194 | epoll_suffix = ":" + osdetector.classifier |
| 195 | } |
Jakob Buchgraber | 7ddcdfd | 2015-02-13 16:21:53 -0800 | [diff] [blame] | 196 | libraries = [ |
Eric Anderson | 15a5ba2 | 2018-07-19 13:40:41 -0700 | [diff] [blame] | 197 | errorprone: "com.google.errorprone:error_prone_annotations:2.2.0", |
ZHANG Dapeng | 5ce10f0 | 2018-06-11 18:35:18 -0700 | [diff] [blame] | 198 | gson: "com.google.code.gson:gson:2.7", |
| 199 | guava: "com.google.guava:guava:${guavaVersion}", |
| 200 | hpack: 'com.twitter:hpack:0.10.1', |
| 201 | javax_annotation: 'javax.annotation:javax.annotation-api:1.2', |
| 202 | jsr305: 'com.google.code.findbugs:jsr305:3.0.0', |
| 203 | oauth_client: 'com.google.auth:google-auth-library-oauth2-http:0.9.0', |
| 204 | google_api_protos: 'com.google.api.grpc:proto-google-common-protos:1.0.0', |
| 205 | google_auth_credentials: 'com.google.auth:google-auth-library-credentials:0.9.0', |
| 206 | okhttp: 'com.squareup.okhttp:okhttp:2.5.0', |
| 207 | okio: 'com.squareup.okio:okio:1.13.0', |
| 208 | opencensus_api: "io.opencensus:opencensus-api:${opencensusVersion}", |
| 209 | opencensus_contrib_grpc_metrics: "io.opencensus:opencensus-contrib-grpc-metrics:${opencensusVersion}", |
| 210 | opencensus_impl: "io.opencensus:opencensus-impl:${opencensusVersion}", |
| 211 | opencensus_impl_lite: "io.opencensus:opencensus-impl-lite:${opencensusVersion}", |
| 212 | instrumentation_api: 'com.google.instrumentation:instrumentation-api:0.4.3', |
| 213 | protobuf: "com.google.protobuf:protobuf-java:${protobufVersion}", |
| 214 | protobuf_lite: "com.google.protobuf:protobuf-lite:3.0.1", |
| 215 | protoc_lite: "com.google.protobuf:protoc-gen-javalite:3.0.0", |
| 216 | protobuf_nano: "com.google.protobuf.nano:protobuf-javanano:${protobufNanoVersion}", |
| 217 | protobuf_plugin: 'com.google.protobuf:protobuf-gradle-plugin:0.8.5', |
| 218 | protobuf_util: "com.google.protobuf:protobuf-java-util:${protobufVersion}", |
| 219 | lang: "org.apache.commons:commons-lang3:3.5", |
nathanmittler | 164b734 | 2014-12-15 09:58:05 -0800 | [diff] [blame] | 220 | |
ZHANG Dapeng | 5ce10f0 | 2018-06-11 18:35:18 -0700 | [diff] [blame] | 221 | netty: "io.netty:netty-codec-http2:[${nettyVersion}]", |
| 222 | netty_epoll: "io.netty:netty-transport-native-epoll:${nettyVersion}" + epoll_suffix, |
| 223 | netty_proxy_handler: "io.netty:netty-handler-proxy:${nettyVersion}", |
Carl Mastrangelo | 7d45596 | 2018-07-20 16:36:00 -0700 | [diff] [blame^] | 224 | netty_tcnative: 'io.netty:netty-tcnative-boringssl-static:2.0.12.Final', |
nathanmittler | 164b734 | 2014-12-15 09:58:05 -0800 | [diff] [blame] | 225 | |
ZHANG Dapeng | 5ce10f0 | 2018-06-11 18:35:18 -0700 | [diff] [blame] | 226 | conscrypt: 'org.conscrypt:conscrypt-openjdk-uber:1.0.1', |
| 227 | re2j: 'com.google.re2j:re2j:1.2', |
Eric Anderson | 7eab0d9 | 2018-02-15 17:14:10 -0800 | [diff] [blame] | 228 | |
ZHANG Dapeng | 5ce10f0 | 2018-06-11 18:35:18 -0700 | [diff] [blame] | 229 | // Test dependencies. |
| 230 | junit: 'junit:junit:4.12', |
| 231 | mockito: 'org.mockito:mockito-core:1.9.5', |
Eric Anderson | 6d7c7dc | 2018-07-18 15:26:38 -0700 | [diff] [blame] | 232 | truth: 'com.google.truth:truth:0.42', |
ZHANG Dapeng | 5ce10f0 | 2018-06-11 18:35:18 -0700 | [diff] [blame] | 233 | guava_testlib: 'com.google.guava:guava-testlib:20.0', |
Louis Ryan | a7049bc | 2016-03-23 13:18:04 -0700 | [diff] [blame] | 234 | |
ZHANG Dapeng | 5ce10f0 | 2018-06-11 18:35:18 -0700 | [diff] [blame] | 235 | // Benchmark dependencies |
| 236 | hdrhistogram: 'org.hdrhistogram:HdrHistogram:2.1.10', |
| 237 | math: 'org.apache.commons:commons-math3:3.6', |
ZHANG Dapeng | aed886d | 2016-05-02 14:01:36 -0700 | [diff] [blame] | 238 | |
ZHANG Dapeng | 5ce10f0 | 2018-06-11 18:35:18 -0700 | [diff] [blame] | 239 | // Jetty ALPN dependencies |
| 240 | jetty_alpn_agent: 'org.mortbay.jetty.alpn:jetty-alpn-agent:2.0.7' |
Jakob Buchgraber | 7ddcdfd | 2015-02-13 16:21:53 -0800 | [diff] [blame] | 241 | ] |
Jakob Buchgraber | 7ddcdfd | 2015-02-13 16:21:53 -0800 | [diff] [blame] | 242 | } |
nathanmittler | 164b734 | 2014-12-15 09:58:05 -0800 | [diff] [blame] | 243 | |
ZHANG Dapeng | aed886d | 2016-05-02 14:01:36 -0700 | [diff] [blame] | 244 | // Define a separate configuration for managing the dependency on Jetty ALPN agent. |
nmittler | 74cfe6c | 2015-05-22 12:25:10 -0700 | [diff] [blame] | 245 | configurations { |
ZHANG Dapeng | aed886d | 2016-05-02 14:01:36 -0700 | [diff] [blame] | 246 | alpnagent |
Eric Anderson | a3ff9cd | 2017-09-18 16:20:18 -0700 | [diff] [blame] | 247 | |
| 248 | compile { |
| 249 | // Detect Maven Enforcer's dependencyConvergence failures. We only |
| 250 | // care for artifacts used as libraries by others. |
ZHANG Dapeng | 5ce10f0 | 2018-06-11 18:35:18 -0700 | [diff] [blame] | 251 | if (!(project.name in [ |
| 252 | 'grpc-benchmarks', |
| 253 | 'grpc-interop-testing' |
| 254 | ])) { |
Eric Anderson | a3ff9cd | 2017-09-18 16:20:18 -0700 | [diff] [blame] | 255 | resolutionStrategy.failOnVersionConflict() |
| 256 | } |
| 257 | } |
nmittler | 74cfe6c | 2015-05-22 12:25:10 -0700 | [diff] [blame] | 258 | } |
| 259 | |
nathanmittler | 164b734 | 2014-12-15 09:58:05 -0800 | [diff] [blame] | 260 | dependencies { |
| 261 | testCompile libraries.junit, |
ZHANG Dapeng | 5ce10f0 | 2018-06-11 18:35:18 -0700 | [diff] [blame] | 262 | libraries.mockito, |
| 263 | libraries.truth |
nmittler | 74cfe6c | 2015-05-22 12:25:10 -0700 | [diff] [blame] | 264 | |
ZHANG Dapeng | aed886d | 2016-05-02 14:01:36 -0700 | [diff] [blame] | 265 | // Configuration for modules that use Jetty ALPN agent |
| 266 | alpnagent libraries.jetty_alpn_agent |
Eric Anderson | 6164b7b | 2017-08-26 17:10:18 -0700 | [diff] [blame] | 267 | |
| 268 | jmh 'org.openjdk.jmh:jmh-core:1.19', |
ZHANG Dapeng | 5ce10f0 | 2018-06-11 18:35:18 -0700 | [diff] [blame] | 269 | 'org.openjdk.jmh:jmh-generator-bytecode:1.19' |
nathanmittler | 164b734 | 2014-12-15 09:58:05 -0800 | [diff] [blame] | 270 | } |
Eric Anderson | 192144e | 2015-03-02 13:31:14 -0800 | [diff] [blame] | 271 | |
| 272 | signing { |
| 273 | required false |
| 274 | sign configurations.archives |
| 275 | } |
| 276 | |
nmittler | 732cfc0 | 2015-03-03 07:59:13 -0800 | [diff] [blame] | 277 | // Disable JavaDoc doclint on Java 8. It's annoying. |
| 278 | if (JavaVersion.current().isJava8Compatible()) { |
ZHANG Dapeng | 5ce10f0 | 2018-06-11 18:35:18 -0700 | [diff] [blame] | 279 | allprojects { |
| 280 | tasks.withType(Javadoc) { |
| 281 | options.addStringOption('Xdoclint:none', '-quiet') |
| 282 | } |
nmittler | 732cfc0 | 2015-03-03 07:59:13 -0800 | [diff] [blame] | 283 | } |
nmittler | 732cfc0 | 2015-03-03 07:59:13 -0800 | [diff] [blame] | 284 | } |
| 285 | |
zpencer | 37e6f5f | 2018-07-19 13:35:27 -0700 | [diff] [blame] | 286 | // For jdk10 we must explicitly choose between html4 and html5, otherwise we get a warning |
| 287 | if (JavaVersion.current().isJava10Compatible()) { |
| 288 | allprojects { |
| 289 | tasks.withType(Javadoc) { |
| 290 | options.addBooleanOption('html4', true) |
| 291 | } |
| 292 | } |
| 293 | } |
| 294 | |
Eric Anderson | c3e8dae | 2015-01-30 14:58:07 -0800 | [diff] [blame] | 295 | checkstyle { |
Eric Anderson | e6d0062 | 2017-07-07 10:57:03 -0700 | [diff] [blame] | 296 | configFile = file("$rootDir/buildscripts/checkstyle.xml") |
Eric Anderson | 6ab27ab | 2016-04-18 09:15:25 -0700 | [diff] [blame] | 297 | toolVersion = "6.17" |
Eric Anderson | ad44f0a | 2015-05-05 08:54:51 -0700 | [diff] [blame] | 298 | ignoreFailures = false |
Eric Anderson | 26141b4 | 2015-03-21 10:59:17 -0700 | [diff] [blame] | 299 | if (rootProject.hasProperty("checkstyle.ignoreFailures")) { |
| 300 | ignoreFailures = rootProject.properties["checkstyle.ignoreFailures"].toBoolean() |
| 301 | } |
Eric Anderson | efa774b | 2015-09-15 10:34:14 -0700 | [diff] [blame] | 302 | configProperties["rootDir"] = rootDir |
Eric Anderson | c3e8dae | 2015-01-30 14:58:07 -0800 | [diff] [blame] | 303 | } |
| 304 | |
| 305 | checkstyleMain { |
Kun Zhang | 693a7d2 | 2015-05-06 11:35:08 -0700 | [diff] [blame] | 306 | source = fileTree(dir: "src/main", include: "**/*.java") |
Eric Anderson | c3e8dae | 2015-01-30 14:58:07 -0800 | [diff] [blame] | 307 | } |
| 308 | |
| 309 | checkstyleTest { |
Kun Zhang | 693a7d2 | 2015-05-06 11:35:08 -0700 | [diff] [blame] | 310 | source = fileTree(dir: "src/test", include: "**/*.java") |
Eric Anderson | c3e8dae | 2015-01-30 14:58:07 -0800 | [diff] [blame] | 311 | } |
| 312 | |
zpencer | 4f19f14 | 2018-03-13 17:46:03 -0700 | [diff] [blame] | 313 | // invoke jmh on a single benchmark class like so: |
| 314 | // ./gradlew -PjmhIncludeSingleClass=StatsTraceContextBenchmark clean :grpc-core:jmh |
Eric Anderson | 6164b7b | 2017-08-26 17:10:18 -0700 | [diff] [blame] | 315 | jmh { |
| 316 | warmupIterations = 10 |
| 317 | iterations = 10 |
| 318 | fork = 1 |
| 319 | // None of our benchmarks need the tests, and we have pseudo-circular |
| 320 | // dependencies that break when including them. (context's testCompile |
| 321 | // depends on core; core's testCompile depends on testing) |
| 322 | includeTests = false |
zpencer | 4f19f14 | 2018-03-13 17:46:03 -0700 | [diff] [blame] | 323 | if (project.hasProperty('jmhIncludeSingleClass')) { |
ZHANG Dapeng | 5ce10f0 | 2018-06-11 18:35:18 -0700 | [diff] [blame] | 324 | include = [ |
| 325 | project.property('jmhIncludeSingleClass') |
| 326 | ] |
zpencer | 4f19f14 | 2018-03-13 17:46:03 -0700 | [diff] [blame] | 327 | } |
Eric Anderson | 6164b7b | 2017-08-26 17:10:18 -0700 | [diff] [blame] | 328 | } |
| 329 | |
Eric Anderson | 192144e | 2015-03-02 13:31:14 -0800 | [diff] [blame] | 330 | task javadocJar(type: Jar) { |
| 331 | classifier = 'javadoc' |
| 332 | from javadoc |
| 333 | } |
| 334 | |
| 335 | task sourcesJar(type: Jar) { |
| 336 | classifier = 'sources' |
| 337 | from sourceSets.main.allSource |
| 338 | } |
| 339 | |
ZHANG Dapeng | 5ce10f0 | 2018-06-11 18:35:18 -0700 | [diff] [blame] | 340 | artifacts { archives javadocJar, sourcesJar } |
Eric Anderson | 192144e | 2015-03-02 13:31:14 -0800 | [diff] [blame] | 341 | |
| 342 | uploadArchives.repositories.mavenDeployer { |
| 343 | beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } |
Eric Anderson | 4f4cedf | 2017-12-14 16:51:14 -0800 | [diff] [blame] | 344 | if (rootProject.hasProperty('repositoryDir')) { |
ZHANG Dapeng | 5ce10f0 | 2018-06-11 18:35:18 -0700 | [diff] [blame] | 345 | repository(url: new File(rootProject.repositoryDir).toURI()) |
Eric Anderson | 4f4cedf | 2017-12-14 16:51:14 -0800 | [diff] [blame] | 346 | } else { |
ZHANG Dapeng | 5ce10f0 | 2018-06-11 18:35:18 -0700 | [diff] [blame] | 347 | String stagingUrl |
| 348 | if (rootProject.hasProperty('repositoryId')) { |
| 349 | stagingUrl = 'https://oss.sonatype.org/service/local/staging/deployByRepositoryId/' + |
| 350 | rootProject.repositoryId |
| 351 | } else { |
| 352 | stagingUrl = 'https://oss.sonatype.org/service/local/staging/deploy/maven2/' |
zpencer | 8925921 | 2018-02-13 11:17:53 -0800 | [diff] [blame] | 353 | } |
ZHANG Dapeng | 5ce10f0 | 2018-06-11 18:35:18 -0700 | [diff] [blame] | 354 | def configureAuth = { |
| 355 | if (rootProject.hasProperty('ossrhUsername') && rootProject.hasProperty('ossrhPassword')) { |
| 356 | authentication(userName: rootProject.ossrhUsername, password: rootProject.ossrhPassword) |
| 357 | } |
| 358 | } |
| 359 | repository(url: stagingUrl, configureAuth) |
| 360 | snapshotRepository(url: 'https://oss.sonatype.org/content/repositories/snapshots/', configureAuth) |
Eric Anderson | 4f4cedf | 2017-12-14 16:51:14 -0800 | [diff] [blame] | 361 | } |
Eric Anderson | 192144e | 2015-03-02 13:31:14 -0800 | [diff] [blame] | 362 | } |
zpencer | b07c70a | 2017-10-06 10:44:58 -0700 | [diff] [blame] | 363 | uploadArchives.onlyIf { !name.contains("grpc-gae-interop-testing") } |
Eric Anderson | 192144e | 2015-03-02 13:31:14 -0800 | [diff] [blame] | 364 | |
| 365 | [ |
ZHANG Dapeng | 5ce10f0 | 2018-06-11 18:35:18 -0700 | [diff] [blame] | 366 | install.repositories.mavenInstaller, |
| 367 | uploadArchives.repositories.mavenDeployer, |
Eric Anderson | 192144e | 2015-03-02 13:31:14 -0800 | [diff] [blame] | 368 | ]*.pom*.whenConfigured { pom -> |
| 369 | pom.project { |
Eric Anderson | 7e8a02c | 2015-03-12 17:03:01 -0700 | [diff] [blame] | 370 | name "$project.group:$project.name" |
Eric Anderson | 192144e | 2015-03-02 13:31:14 -0800 | [diff] [blame] | 371 | description project.description |
| 372 | url 'https://github.com/grpc/grpc-java' |
| 373 | |
| 374 | scm { |
Eric Anderson | b735495 | 2016-04-08 08:37:07 -0700 | [diff] [blame] | 375 | connection 'scm:git:https://github.com/grpc/grpc-java.git' |
| 376 | developerConnection 'scm:git:git@github.com:grpc/grpc-java.git' |
Eric Anderson | 192144e | 2015-03-02 13:31:14 -0800 | [diff] [blame] | 377 | url 'https://github.com/grpc/grpc-java' |
| 378 | } |
| 379 | |
| 380 | licenses { |
| 381 | license { |
Carl Mastrangelo | 7b97df0 | 2017-05-31 14:37:42 -0700 | [diff] [blame] | 382 | name 'Apache 2.0' |
| 383 | url 'https://opensource.org/licenses/Apache-2.0' |
Eric Anderson | 192144e | 2015-03-02 13:31:14 -0800 | [diff] [blame] | 384 | } |
| 385 | } |
Eric Anderson | 7e8a02c | 2015-03-12 17:03:01 -0700 | [diff] [blame] | 386 | |
| 387 | developers { |
| 388 | developer { |
| 389 | id "grpc.io" |
| 390 | name "gRPC Contributors" |
| 391 | email "grpc-io@googlegroups.com" |
Mehrdad Afshari | 8ce0bc2 | 2017-07-10 22:48:17 +0000 | [diff] [blame] | 392 | url "https://grpc.io/" |
Eric Anderson | 7e8a02c | 2015-03-12 17:03:01 -0700 | [diff] [blame] | 393 | // https://issues.gradle.org/browse/GRADLE-2719 |
Carl Mastrangelo | 3bfd630 | 2017-05-31 13:29:01 -0700 | [diff] [blame] | 394 | organization = "gRPC Authors" |
Eric Anderson | 7e8a02c | 2015-03-12 17:03:01 -0700 | [diff] [blame] | 395 | organizationUrl "https://www.google.com" |
| 396 | } |
| 397 | } |
Eric Anderson | 192144e | 2015-03-02 13:31:14 -0800 | [diff] [blame] | 398 | } |
Eric Anderson | 90db93b | 2016-04-08 13:47:30 -0700 | [diff] [blame] | 399 | if (!(project.name in |
ZHANG Dapeng | 5ce10f0 | 2018-06-11 18:35:18 -0700 | [diff] [blame] | 400 | [ |
| 401 | "grpc-stub", |
| 402 | "grpc-protobuf", |
| 403 | "grpc-protobuf-lite", |
| 404 | "grpc-protobuf-nano" |
| 405 | ])) { |
| 406 | def core = pom.dependencies.find {dep -> dep.artifactId == 'grpc-core'} |
| 407 | if (core != null) { |
| 408 | // Depend on specific version of grpc-core because internal package is unstable |
| 409 | core.version = "[" + core.version + "]" |
| 410 | } |
Eric Anderson | 90db93b | 2016-04-08 13:47:30 -0700 | [diff] [blame] | 411 | } |
Eric Anderson | 192144e | 2015-03-02 13:31:14 -0800 | [diff] [blame] | 412 | } |
Kun Zhang | 3ddd1d5 | 2015-04-22 10:02:19 -0700 | [diff] [blame] | 413 | // At a test failure, log the stack trace to the console so that we don't |
| 414 | // have to open the HTML in a browser. |
| 415 | test { |
| 416 | testLogging { |
| 417 | exceptionFormat = 'full' |
nmittler | 4ee2a65 | 2015-06-01 16:20:08 -0700 | [diff] [blame] | 418 | showExceptions true |
| 419 | showCauses true |
| 420 | showStackTraces true |
Kun Zhang | 3ddd1d5 | 2015-04-22 10:02:19 -0700 | [diff] [blame] | 421 | } |
Eric Anderson | 56dca03 | 2016-02-12 08:48:41 -0800 | [diff] [blame] | 422 | maxHeapSize = '1500m' |
Kun Zhang | 3ddd1d5 | 2015-04-22 10:02:19 -0700 | [diff] [blame] | 423 | } |
nathanmittler | 164b734 | 2014-12-15 09:58:05 -0800 | [diff] [blame] | 424 | } |
zpencer | a62108a | 2017-09-27 08:31:43 -0700 | [diff] [blame] | 425 | |
| 426 | // Run with: ./gradlew japicmp --continue |
| 427 | def baselineGrpcVersion = '1.6.1' |
| 428 | def publicApiSubprojects = [ |
ZHANG Dapeng | 5ce10f0 | 2018-06-11 18:35:18 -0700 | [diff] [blame] | 429 | // TODO: uncomment after grpc-alts artifact is published. |
| 430 | // ':grpc-alts', |
| 431 | ':grpc-auth', |
| 432 | ':grpc-context', |
| 433 | ':grpc-core', |
| 434 | ':grpc-grpclb', |
| 435 | ':grpc-netty', |
| 436 | ':grpc-okhttp', |
| 437 | ':grpc-protobuf', |
| 438 | ':grpc-protobuf-lite', |
| 439 | ':grpc-protobuf-nano', |
| 440 | ':grpc-stub', |
| 441 | ':grpc-testing', |
zpencer | a62108a | 2017-09-27 08:31:43 -0700 | [diff] [blame] | 442 | ] |
| 443 | |
| 444 | publicApiSubprojects.each { name -> |
| 445 | project(":$name") { |
| 446 | apply plugin: 'me.champeau.gradle.japicmp' |
| 447 | |
| 448 | // Get the baseline version's jar for this subproject |
| 449 | File baselineArtifact = null |
| 450 | // Use a detached configuration, otherwise the current version's jar will take precedence |
| 451 | // over the baseline jar. |
| 452 | // A necessary hack, the intuitive thing does NOT work: |
| 453 | // https://discuss.gradle.org/t/is-the-default-configuration-leaking-into-independent-configurations/2088/6 |
| 454 | def oldGroup = project.group |
| 455 | try { |
| 456 | project.group = 'virtual_group_for_japicmp' |
| 457 | String depModule = "io.grpc:${project.name}:${baselineGrpcVersion}@jar" |
| 458 | String depJar = "${project.name}-${baselineGrpcVersion}.jar" |
| 459 | Configuration configuration = configurations.detachedConfiguration( |
| 460 | dependencies.create(depModule) |
ZHANG Dapeng | 5ce10f0 | 2018-06-11 18:35:18 -0700 | [diff] [blame] | 461 | ) |
zpencer | a62108a | 2017-09-27 08:31:43 -0700 | [diff] [blame] | 462 | baselineArtifact = files(configuration.files).filter { |
| 463 | it.name.equals(depJar) |
| 464 | }.singleFile |
| 465 | } finally { |
| 466 | project.group = oldGroup |
| 467 | } |
| 468 | |
| 469 | // Add a japicmp task that compares the current .jar with baseline .jar |
| 470 | task japicmp(type: me.champeau.gradle.japicmp.JapicmpTask, dependsOn: jar) { |
| 471 | oldClasspath = files(baselineArtifact) |
| 472 | newClasspath = files(jar.archivePath) |
| 473 | onlyBinaryIncompatibleModified = false |
| 474 | // Be quiet about things that did not change |
| 475 | onlyModified = true |
| 476 | // This task should fail if there are incompatible changes |
| 477 | failOnModification = true |
| 478 | ignoreMissingClasses = true |
| 479 | htmlOutputFile = file("$buildDir/reports/japi.html") |
| 480 | |
| 481 | packageExcludes = ['io.grpc.internal'] |
| 482 | |
| 483 | // Also break on source incompatible changes, not just binary. |
| 484 | // Eg adding abstract method to public class. |
| 485 | // TODO(zpencer): enable after japicmp-gradle-plugin/pull/14 |
| 486 | // breakOnSourceIncompatibility = true |
| 487 | |
| 488 | // Ignore any classes or methods marked @ExperimentalApi |
| 489 | // TODO(zpencer): enable after japicmp-gradle-plugin/pull/15 |
| 490 | // annotationExcludes = ['@io.grpc.ExperimentalApi'] |
| 491 | } |
| 492 | } |
| 493 | } |
ZHANG Dapeng | 5ce10f0 | 2018-06-11 18:35:18 -0700 | [diff] [blame] | 494 | |
| 495 | // format checkers |
| 496 | apply plugin: "com.diffplug.gradle.spotless" |
| 497 | apply plugin: 'groovy' |
| 498 | spotless { |
| 499 | groovyGradle { |
| 500 | target '**/*.gradle' |
| 501 | greclipse() |
| 502 | indentWithSpaces() |
| 503 | paddedCell() |
| 504 | } |
| 505 | } |