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