blob: f409f5f5dd8cba1cba04d77555058baf00cc0844 [file] [log] [blame]
Kun Zhang4bc2d6d2015-04-17 10:49:11 -07001buildscript {
2 repositories {
Kun Zhang4bc2d6d2015-04-17 10:49:11 -07003 mavenLocal()
Eric Anderson675080b2017-02-24 14:53:23 -08004 maven {
5 url "https://plugins.gradle.org/m2/"
6 }
Kun Zhang4bc2d6d2015-04-17 10:49:11 -07007 }
8 dependencies {
nmittlerc4bcf142015-09-16 15:15:10 -07009 classpath 'com.google.gradle:osdetector-gradle-plugin:1.4.0'
Carl Mastrangelo8572f5f2017-07-18 13:53:45 -070010 classpath 'ru.vyarus:gradle-animalsniffer-plugin:1.4.0'
Eric Anderson35a6bf82018-01-08 14:05:16 -080011 classpath 'net.ltgt.gradle:gradle-errorprone-plugin:0.0.13'
12 classpath 'net.ltgt.gradle:gradle-apt-plugin:0.13'
Eric Andersone085a0e2018-05-16 15:37:24 -070013 classpath "me.champeau.gradle:jmh-gradle-plugin:0.4.5"
zpencera62108a2017-09-27 08:31:43 -070014 classpath 'me.champeau.gradle:japicmp-gradle-plugin:0.2.5'
Kun Zhang4bc2d6d2015-04-17 10:49:11 -070015 }
16}
Eric Andersonb938ba52015-02-28 09:59:25 -080017
Louis Ryan540b4d32015-09-04 13:26:24 -070018subprojects {
Eric Andersonc3e8dae2015-01-30 14:58:07 -080019 apply plugin: "checkstyle"
nathanmittler164b7342014-12-15 09:58:05 -080020 apply plugin: "java"
21 apply plugin: "maven"
nmittler52f42202015-01-21 14:30:14 -080022 apply plugin: "idea"
Eric Anderson192144e2015-03-02 13:31:14 -080023 apply plugin: "signing"
Eric Anderson041cdb12015-05-05 12:29:26 -070024 apply plugin: "jacoco"
nathanmittler164b7342014-12-15 09:58:05 -080025
Eric Anderson6164b7b2017-08-26 17:10:18 -070026 apply plugin: "me.champeau.gradle.jmh"
nmittlerc4bcf142015-09-16 15:15:10 -070027 apply plugin: "com.google.osdetector"
Eric Anderson42aa64c2017-02-02 13:48:12 -080028 // The plugin only has an effect if a signature is specified
29 apply plugin: "ru.vyarus.animalsniffer"
Eric Anderson675080b2017-02-24 14:53:23 -080030 if (!rootProject.hasProperty('errorProne') || rootProject.errorProne.toBoolean()) {
31 apply plugin: "net.ltgt.errorprone"
Eric Anderson35a6bf82018-01-08 14:05:16 -080032 apply plugin: "net.ltgt.apt"
Eric Anderson982541b2017-04-26 13:33:27 -070033
34 dependencies {
35 // The ErrorProne plugin defaults to the latest, which would break our
36 // build if error prone releases a new version with a new check
Eric Andersonaf028342018-01-10 09:30:38 -080037 errorprone 'com.google.errorprone:error_prone_core:2.2.0'
Eric Anderson35a6bf82018-01-08 14:05:16 -080038 apt 'com.google.guava:guava-beta-checker:1.0'
Eric Anderson982541b2017-04-26 13:33:27 -070039 }
40 } else {
41 // Remove per-project error-prone checker config
42 allprojects {
43 afterEvaluate { project ->
44 project.tasks.withType(JavaCompile) {
Eric Anderson52411722018-03-12 18:37:14 -070045 options.compilerArgs.removeAll { it.startsWith("-Xep") }
Eric Anderson982541b2017-04-26 13:33:27 -070046 }
47 }
48 }
Eric Anderson675080b2017-02-24 14:53:23 -080049 }
zpencer5713ebc2017-07-15 12:41:20 -070050 // TODO(zpencer): remove when intellij 2017.2 is released
51 // https://github.com/gradle/gradle/issues/2315
52 idea.module.inheritOutputDirs = true
nmittlerc4bcf142015-09-16 15:15:10 -070053
nmittlerf8314582015-01-27 10:25:39 -080054 group = "io.grpc"
zpencer62e6e2d2018-04-23 15:24:24 -070055 version = "1.13.0-SNAPSHOT" // CURRENT_GRPC_VERSION
nathanmittler164b7342014-12-15 09:58:05 -080056
57 sourceCompatibility = 1.6
58 targetCompatibility = 1.6
59
60 repositories {
Kun Zhanga6653bb2017-09-25 15:38:48 -070061 maven {
zpencer066ad3c2018-03-01 19:11:24 -080062 // The google mirror is less flaky than mavenCentral()
63 url "https://maven-central.storage-download.googleapis.com/repos/central/data/"
Kun Zhanga6653bb2017-09-25 15:38:48 -070064 }
zpencer066ad3c2018-03-01 19:11:24 -080065 mavenLocal()
nathanmittler164b7342014-12-15 09:58:05 -080066 }
67
Eric Anderson6164b7b2017-08-26 17:10:18 -070068 [compileJava, compileTestJava, compileJmhJava].each() {
Eric Anderson675080b2017-02-24 14:53:23 -080069 it.options.compilerArgs += ["-Xlint:all", "-Xlint:-options", "-Xlint:-path"]
Eric Anderson76d09552015-03-12 15:25:11 -070070 it.options.encoding = "UTF-8"
Eric Anderson3c03eb72016-07-10 11:40:12 -070071 if (rootProject.hasProperty('failOnWarnings') && rootProject.failOnWarnings.toBoolean()) {
72 it.options.compilerArgs += ["-Werror"]
73 }
nmittler02c953e2015-01-26 14:03:11 -080074 }
75
Eric Anderson641cb352016-05-24 14:29:52 -070076 compileTestJava {
77 // serialVersionUID is basically guaranteed to be useless in our tests
Eric Anderson4bc0c952018-01-08 15:08:56 -080078 // LinkedList doesn't hurt much in tests and has lots of usages
79 options.compilerArgs += ["-Xlint:-serial", "-Xep:JdkObsolete:OFF"]
Eric Anderson641cb352016-05-24 14:29:52 -070080 }
81
nmittler8c1d38a2015-06-01 08:31:00 -070082 jar.manifest {
83 attributes('Implementation-Title': name,
84 'Implementation-Version': version,
85 'Built-By': System.getProperty('user.name'),
86 'Built-JDK': System.getProperty('java.version'),
87 'Source-Compatibility': sourceCompatibility,
88 'Target-Compatibility': targetCompatibility)
89 }
90
Eric Anderson10fb2062015-05-05 10:28:38 -070091 javadoc.options {
92 encoding = 'UTF-8'
ZHANG Dapeng66ebcb12017-05-17 08:52:07 -070093 use = true
Eric Anderson10fb2062015-05-05 10:28:38 -070094 links 'https://docs.oracle.com/javase/8/docs/api/'
95 }
Eric Anderson14444a92015-03-11 16:44:38 -070096
Jakob Buchgraber7ddcdfd2015-02-13 16:21:53 -080097 ext {
Kun Zhang6b1e7d62015-05-07 15:20:44 -070098 def exeSuffix = osdetector.os == 'windows' ? ".exe" : ""
99 protocPluginBaseName = 'protoc-gen-grpc-java'
Eric Anderson46ce4092016-01-26 12:13:06 -0800100 javaPluginPath = "$rootDir/compiler/build/exe/java_plugin/$protocPluginBaseName$exeSuffix"
Kun Zhang6b1e7d62015-05-07 15:20:44 -0700101
Carl Mastrangelo4388d902018-05-23 17:16:45 -0700102 nettyVersion = '4.1.25.Final'
Eric Anderson5f0ee3a2018-03-23 15:45:05 -0700103 guavaVersion = '20.0'
Kun Zhang86d64122018-01-05 16:40:20 -0800104 protobufVersion = '3.5.1'
105 protocVersion = '3.5.1-1'
Kun Zhange2ed2e82016-01-27 08:26:19 -0800106 protobufNanoVersion = '3.0.0-alpha-5'
Bogdan Drutu2a127ce2018-06-04 15:27:27 -0700107 opencensusVersion = '0.12.3'
Kun Zhang6b1e7d62015-05-07 15:20:44 -0700108
Kun Zhang111f6dd2015-05-05 16:11:27 -0700109 configureProtoCompilation = {
Kun Zhang35f77ee2015-06-22 16:29:30 -0700110 String generatedSourcePath = "${projectDir}/src/generated"
Kun Zhang111f6dd2015-05-05 16:11:27 -0700111 if (rootProject.childProjects.containsKey('grpc-compiler')) {
112 // Only when the codegen is built along with the project, will we be able to recompile
113 // the proto files.
114 project.apply plugin: 'com.google.protobuf'
Kun Zhang35f77ee2015-06-22 16:29:30 -0700115 project.protobuf {
116 protoc {
117 if (project.hasProperty('protoc')) {
118 path = project.protoc
119 } else {
Carl Mastrangelo0fe2c5c2017-05-23 17:04:51 -0700120 artifact = "com.google.protobuf:protoc:${protocVersion}"
Kun Zhang35f77ee2015-06-22 16:29:30 -0700121 }
122 }
123 plugins {
124 grpc {
125 path = javaPluginPath
126 }
127 }
128 generateProtoTasks {
129 all().each { task ->
130 task.dependsOn ':grpc-compiler:java_pluginExecutable'
131 // Delete the generated sources first, so that we can be alerted if they are not re-compiled.
Eric Andersone9b4d152016-04-19 11:54:04 -0700132 task.dependsOn 'deleteGeneratedSource' + task.sourceSet.name
Kun Zhang35f77ee2015-06-22 16:29:30 -0700133 // Recompile protos when the codegen has been changed
134 task.inputs.file javaPluginPath
135 // Recompile protos when build.gradle has been changed, because
136 // it's possible the version of protoc has been changed.
137 task.inputs.file "${rootProject.projectDir}/build.gradle"
138 task.plugins {
ZHANG Dapenge1091252016-07-21 16:35:18 -0700139 grpc {
Eric Anderson182164e2016-06-16 13:54:12 -0700140 option 'noversion'
ZHANG Dapenge1091252016-07-21 16:35:18 -0700141 }
Kun Zhang2cdc5e32015-05-11 16:58:28 -0700142 }
143 }
144 }
Kun Zhang35f77ee2015-06-22 16:29:30 -0700145 generatedFilesBaseDir = generatedSourcePath
146 }
147
Eric Andersone9b4d152016-04-19 11:54:04 -0700148 sourceSets.each { sourceSet ->
Carl Mastrangeloaaf90672017-03-23 18:02:35 -0700149 task "deleteGeneratedSource${sourceSet.name}" {
150 doLast {
151 project.delete project.fileTree(dir: generatedSourcePath + '/' + sourceSet.name)
152 }
Eric Andersone9b4d152016-04-19 11:54:04 -0700153 }
Kun Zhang2cdc5e32015-05-11 16:58:28 -0700154 }
Kun Zhang111f6dd2015-05-05 16:11:27 -0700155 } else {
156 // Otherwise, we just use the checked-in generated code.
157 project.sourceSets {
158 main {
159 java {
Kun Zhang35f77ee2015-06-22 16:29:30 -0700160 srcDir "${generatedSourcePath}/main/java"
Eric Andersoncea8e8e2015-10-27 19:53:18 -0700161 srcDir "${generatedSourcePath}/main/javanano"
Kun Zhang35f77ee2015-06-22 16:29:30 -0700162 srcDir "${generatedSourcePath}/main/grpc"
Kun Zhang287a27a2015-05-07 17:32:31 -0700163 }
Kun Zhang111f6dd2015-05-05 16:11:27 -0700164 }
Eric Andersoncea8e8e2015-10-27 19:53:18 -0700165 test {
166 java {
167 srcDir "${generatedSourcePath}/test/java"
168 srcDir "${generatedSourcePath}/test/javanano"
169 srcDir "${generatedSourcePath}/test/grpc"
170 }
171 }
Kun Zhang111f6dd2015-05-05 16:11:27 -0700172 }
173 }
Eric Andersondbef1af2016-05-23 12:05:41 -0700174
Eric Anderson6164b7b2017-08-26 17:10:18 -0700175 [compileJava, compileTestJava, compileJmhJava].each() {
Eric Andersondbef1af2016-05-23 12:05:41 -0700176 // Protobuf-generated code produces some warnings.
Eric Anderson675080b2017-02-24 14:53:23 -0800177 // https://github.com/google/protobuf/issues/2718
Eric Anderson1fb72ef2018-03-08 16:55:16 -0800178 it.options.compilerArgs += [
179 "-Xlint:-cast",
180 "-XepExcludedPaths:.*/src/generated/[^/]+/java/.*",
181 ]
Eric Andersondbef1af2016-05-23 12:05:41 -0700182 }
Kun Zhang111f6dd2015-05-05 16:11:27 -0700183 }
184
Eric Anderson65d73c02015-05-21 11:54:04 -0700185 def epoll_suffix = "";
186 if (osdetector.classifier in ["linux-x86_64"]) {
187 // The native code is only pre-compiled on certain platforms.
188 epoll_suffix = ":" + osdetector.classifier
189 }
Jakob Buchgraber7ddcdfd2015-02-13 16:21:53 -0800190 libraries = [
zpencerb6f556c2017-12-08 11:30:52 -0800191 errorprone: "com.google.errorprone:error_prone_annotations:2.1.2",
Carl Mastrangelo172b2d32017-12-19 12:33:27 -0800192 gson: "com.google.code.gson:gson:2.7",
Carl Mastrangelo28253612016-05-16 10:23:53 -0700193 guava: "com.google.guava:guava:${guavaVersion}",
Jeff Pinnerb1cc7cc2015-02-25 10:17:23 -0800194 hpack: 'com.twitter:hpack:0.10.1',
Eric Anderson4e82e622018-03-28 17:13:39 -0700195 javax_annotation: 'javax.annotation:javax.annotation-api:1.2',
nmittlerb897a892015-02-23 12:03:59 -0800196 jsr305: 'com.google.code.findbugs:jsr305:3.0.0',
Eric Anderson6bab82e2017-11-17 11:33:15 -0800197 oauth_client: 'com.google.auth:google-auth-library-oauth2-http:0.9.0',
Garrett Jones69aedda2017-11-17 13:15:31 -0800198 google_api_protos: 'com.google.api.grpc:proto-google-common-protos:1.0.0',
Eric Anderson6bab82e2017-11-17 11:33:15 -0800199 google_auth_credentials: 'com.google.auth:google-auth-library-credentials:0.9.0',
Xudong Ma6d296e82015-09-21 10:39:00 -0700200 okhttp: 'com.squareup.okhttp:okhttp:2.5.0',
Carl Mastrangelo3671af22017-11-28 15:05:10 -0800201 okio: 'com.squareup.okio:okio:1.13.0',
Bogdan Drutuaf936912018-01-23 09:12:33 -0800202 opencensus_api: "io.opencensus:opencensus-api:${opencensusVersion}",
203 opencensus_contrib_grpc_metrics: "io.opencensus:opencensus-contrib-grpc-metrics:${opencensusVersion}",
204 opencensus_impl: "io.opencensus:opencensus-impl:${opencensusVersion}",
205 opencensus_impl_lite: "io.opencensus:opencensus-impl-lite:${opencensusVersion}",
Yang Song4a0cf0b2017-06-06 18:16:55 -0700206 instrumentation_api: 'com.google.instrumentation:instrumentation-api:0.4.3',
Kun Zhangc5b94c72015-05-06 16:44:55 -0700207 protobuf: "com.google.protobuf:protobuf-java:${protobufVersion}",
Eric Andersona8700a72016-07-29 11:57:41 -0700208 protobuf_lite: "com.google.protobuf:protobuf-lite:3.0.1",
Eric Andersonb1d72e52016-09-27 17:15:12 -0700209 protoc_lite: "com.google.protobuf:protoc-gen-javalite:3.0.0",
Kun Zhangbd23a8d2015-08-28 18:47:06 -0700210 protobuf_nano: "com.google.protobuf.nano:protobuf-javanano:${protobufNanoVersion}",
zpencer14003c12018-03-26 17:29:55 -0700211 protobuf_plugin: 'com.google.protobuf:protobuf-gradle-plugin:0.8.5',
Carl Mastrangelo8e1fba72016-03-02 09:30:35 -0800212 protobuf_util: "com.google.protobuf:protobuf-java-util:${protobufVersion}",
Jiangtao Lie7f2f1d2018-02-15 09:28:00 -0800213 lang: "org.apache.commons:commons-lang3:3.5",
nathanmittler164b7342014-12-15 09:58:05 -0800214
Łukasz Strzałkowski67eefa62017-05-15 10:57:43 -0700215 netty: "io.netty:netty-codec-http2:[${nettyVersion}]",
216 netty_epoll: "io.netty:netty-transport-native-epoll:${nettyVersion}" + epoll_suffix,
217 netty_proxy_handler: "io.netty:netty-handler-proxy:${nettyVersion}",
Carl Mastrangelo045c5662018-04-30 16:55:52 -0700218 netty_tcnative: 'io.netty:netty-tcnative-boringssl-static:2.0.8.Final',
nathanmittler164b7342014-12-15 09:58:05 -0800219
Eric Anderson7eab0d92018-02-15 17:14:10 -0800220 conscrypt: 'org.conscrypt:conscrypt-openjdk-uber:1.0.1',
Nathan Herring8db84972018-05-30 21:26:02 +0200221 re2j: 'com.google.re2j:re2j:1.2',
Eric Anderson7eab0d92018-02-15 17:14:10 -0800222
Jakob Buchgraber7ddcdfd2015-02-13 16:21:53 -0800223 // Test dependencies.
Carl Mastrangelo5e36a8d2017-10-05 11:24:15 -0700224 junit: 'junit:junit:4.12',
Carl Mastrangelob3bc7fc2016-04-01 15:18:23 -0700225 mockito: 'org.mockito:mockito-core:1.9.5',
Eric Anderson2d882692017-10-30 10:58:37 -0700226 truth: 'com.google.truth:truth:0.36',
Eric Anderson5f0ee3a2018-03-23 15:45:05 -0700227 guava_testlib: 'com.google.guava:guava-testlib:20.0',
Louis Ryana7049bc2016-03-23 13:18:04 -0700228
229 // Benchmark dependencies
Carl Mastrangelob9f65902017-10-17 17:03:12 -0700230 hdrhistogram: 'org.hdrhistogram:HdrHistogram:2.1.10',
Louis Ryana7049bc2016-03-23 13:18:04 -0700231 math: 'org.apache.commons:commons-math3:3.6',
ZHANG Dapengaed886d2016-05-02 14:01:36 -0700232
233 // Jetty ALPN dependencies
Carl Mastrangelo713ac0a2018-02-22 13:32:05 -0800234 jetty_alpn_agent: 'org.mortbay.jetty.alpn:jetty-alpn-agent:2.0.7'
Jakob Buchgraber7ddcdfd2015-02-13 16:21:53 -0800235 ]
Jakob Buchgraber7ddcdfd2015-02-13 16:21:53 -0800236 }
nathanmittler164b7342014-12-15 09:58:05 -0800237
ZHANG Dapengaed886d2016-05-02 14:01:36 -0700238 // Define a separate configuration for managing the dependency on Jetty ALPN agent.
nmittler74cfe6c2015-05-22 12:25:10 -0700239 configurations {
ZHANG Dapengaed886d2016-05-02 14:01:36 -0700240 alpnagent
Eric Andersona3ff9cd2017-09-18 16:20:18 -0700241
242 compile {
243 // Detect Maven Enforcer's dependencyConvergence failures. We only
244 // care for artifacts used as libraries by others.
245 if (!(project.name in ['grpc-benchmarks', 'grpc-interop-testing'])) {
246 resolutionStrategy.failOnVersionConflict()
247 }
248 }
nmittler74cfe6c2015-05-22 12:25:10 -0700249 }
250
nathanmittler164b7342014-12-15 09:58:05 -0800251 dependencies {
252 testCompile libraries.junit,
Eric Andersona3ff9cd2017-09-18 16:20:18 -0700253 libraries.mockito,
254 libraries.truth
nmittler74cfe6c2015-05-22 12:25:10 -0700255
ZHANG Dapengaed886d2016-05-02 14:01:36 -0700256 // Configuration for modules that use Jetty ALPN agent
257 alpnagent libraries.jetty_alpn_agent
Eric Anderson6164b7b2017-08-26 17:10:18 -0700258
259 jmh 'org.openjdk.jmh:jmh-core:1.19',
260 'org.openjdk.jmh:jmh-generator-bytecode:1.19'
nathanmittler164b7342014-12-15 09:58:05 -0800261 }
Eric Anderson192144e2015-03-02 13:31:14 -0800262
263 signing {
264 required false
265 sign configurations.archives
266 }
267
nmittler732cfc02015-03-03 07:59:13 -0800268 // Disable JavaDoc doclint on Java 8. It's annoying.
269 if (JavaVersion.current().isJava8Compatible()) {
270 allprojects {
271 tasks.withType(Javadoc) {
272 options.addStringOption('Xdoclint:none', '-quiet')
273 }
274 }
275 }
276
Eric Andersonc3e8dae2015-01-30 14:58:07 -0800277 checkstyle {
Eric Andersone6d00622017-07-07 10:57:03 -0700278 configFile = file("$rootDir/buildscripts/checkstyle.xml")
Eric Anderson6ab27ab2016-04-18 09:15:25 -0700279 toolVersion = "6.17"
Eric Andersonad44f0a2015-05-05 08:54:51 -0700280 ignoreFailures = false
Eric Anderson26141b42015-03-21 10:59:17 -0700281 if (rootProject.hasProperty("checkstyle.ignoreFailures")) {
282 ignoreFailures = rootProject.properties["checkstyle.ignoreFailures"].toBoolean()
283 }
Eric Andersonefa774b2015-09-15 10:34:14 -0700284 configProperties["rootDir"] = rootDir
Eric Andersonc3e8dae2015-01-30 14:58:07 -0800285 }
286
287 checkstyleMain {
Kun Zhang693a7d22015-05-06 11:35:08 -0700288 source = fileTree(dir: "src/main", include: "**/*.java")
Eric Andersonc3e8dae2015-01-30 14:58:07 -0800289 }
290
291 checkstyleTest {
Kun Zhang693a7d22015-05-06 11:35:08 -0700292 source = fileTree(dir: "src/test", include: "**/*.java")
Eric Andersonc3e8dae2015-01-30 14:58:07 -0800293 }
294
zpencer4f19f142018-03-13 17:46:03 -0700295 // invoke jmh on a single benchmark class like so:
296 // ./gradlew -PjmhIncludeSingleClass=StatsTraceContextBenchmark clean :grpc-core:jmh
Eric Anderson6164b7b2017-08-26 17:10:18 -0700297 jmh {
298 warmupIterations = 10
299 iterations = 10
300 fork = 1
301 // None of our benchmarks need the tests, and we have pseudo-circular
302 // dependencies that break when including them. (context's testCompile
303 // depends on core; core's testCompile depends on testing)
304 includeTests = false
zpencer4f19f142018-03-13 17:46:03 -0700305 if (project.hasProperty('jmhIncludeSingleClass')) {
306 include = [project.property('jmhIncludeSingleClass')]
307 }
Eric Anderson6164b7b2017-08-26 17:10:18 -0700308 }
309
Eric Anderson192144e2015-03-02 13:31:14 -0800310 task javadocJar(type: Jar) {
311 classifier = 'javadoc'
312 from javadoc
313 }
314
315 task sourcesJar(type: Jar) {
316 classifier = 'sources'
317 from sourceSets.main.allSource
318 }
319
320 artifacts {
321 archives javadocJar, sourcesJar
322 }
323
324 uploadArchives.repositories.mavenDeployer {
325 beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
Eric Anderson4f4cedf2017-12-14 16:51:14 -0800326 if (rootProject.hasProperty('repositoryDir')) {
327 repository(url: new File(rootProject.repositoryDir).toURI())
328 } else {
zpencer89259212018-02-13 11:17:53 -0800329 String stagingUrl
330 if (rootProject.hasProperty('repositoryId')) {
331 stagingUrl = 'https://oss.sonatype.org/service/local/staging/deployByRepositoryId/' +
332 rootProject.repositoryId
333 } else {
334 stagingUrl = 'https://oss.sonatype.org/service/local/staging/deploy/maven2/'
335 }
336 def configureAuth = {
337 if (rootProject.hasProperty('ossrhUsername') && rootProject.hasProperty('ossrhPassword')) {
338 authentication(userName: rootProject.ossrhUsername, password: rootProject.ossrhPassword)
339 }
340 }
Eric Anderson4f4cedf2017-12-14 16:51:14 -0800341 repository(url: stagingUrl, configureAuth)
342 snapshotRepository(url: 'https://oss.sonatype.org/content/repositories/snapshots/', configureAuth)
343 }
Eric Anderson192144e2015-03-02 13:31:14 -0800344 }
zpencerb07c70a2017-10-06 10:44:58 -0700345 uploadArchives.onlyIf { !name.contains("grpc-gae-interop-testing") }
Eric Anderson192144e2015-03-02 13:31:14 -0800346
347 [
348 install.repositories.mavenInstaller,
349 uploadArchives.repositories.mavenDeployer,
350 ]*.pom*.whenConfigured { pom ->
351 pom.project {
Eric Anderson7e8a02c2015-03-12 17:03:01 -0700352 name "$project.group:$project.name"
Eric Anderson192144e2015-03-02 13:31:14 -0800353 description project.description
354 url 'https://github.com/grpc/grpc-java'
355
356 scm {
Eric Andersonb7354952016-04-08 08:37:07 -0700357 connection 'scm:git:https://github.com/grpc/grpc-java.git'
358 developerConnection 'scm:git:git@github.com:grpc/grpc-java.git'
Eric Anderson192144e2015-03-02 13:31:14 -0800359 url 'https://github.com/grpc/grpc-java'
360 }
361
362 licenses {
363 license {
Carl Mastrangelo7b97df02017-05-31 14:37:42 -0700364 name 'Apache 2.0'
365 url 'https://opensource.org/licenses/Apache-2.0'
Eric Anderson192144e2015-03-02 13:31:14 -0800366 }
367 }
Eric Anderson7e8a02c2015-03-12 17:03:01 -0700368
369 developers {
370 developer {
371 id "grpc.io"
372 name "gRPC Contributors"
373 email "grpc-io@googlegroups.com"
Mehrdad Afshari8ce0bc22017-07-10 22:48:17 +0000374 url "https://grpc.io/"
Eric Anderson7e8a02c2015-03-12 17:03:01 -0700375 // https://issues.gradle.org/browse/GRADLE-2719
Carl Mastrangelo3bfd6302017-05-31 13:29:01 -0700376 organization = "gRPC Authors"
Eric Anderson7e8a02c2015-03-12 17:03:01 -0700377 organizationUrl "https://www.google.com"
378 }
379 }
Eric Anderson192144e2015-03-02 13:31:14 -0800380 }
Eric Anderson90db93b2016-04-08 13:47:30 -0700381 if (!(project.name in
ZHANG Dapeng7c97aa92017-09-28 09:31:32 -0700382 ["grpc-stub", "grpc-protobuf", "grpc-protobuf-lite", "grpc-protobuf-nano"])) {
Eric Anderson90db93b2016-04-08 13:47:30 -0700383 def core = pom.dependencies.find {dep -> dep.artifactId == 'grpc-core'}
384 if (core != null) {
385 // Depend on specific version of grpc-core because internal package is unstable
386 core.version = "[" + core.version + "]"
387 }
388 }
Eric Anderson192144e2015-03-02 13:31:14 -0800389 }
Kun Zhang3ddd1d52015-04-22 10:02:19 -0700390 // At a test failure, log the stack trace to the console so that we don't
391 // have to open the HTML in a browser.
392 test {
393 testLogging {
394 exceptionFormat = 'full'
nmittler4ee2a652015-06-01 16:20:08 -0700395 showExceptions true
396 showCauses true
397 showStackTraces true
Kun Zhang3ddd1d52015-04-22 10:02:19 -0700398 }
Eric Anderson56dca032016-02-12 08:48:41 -0800399 maxHeapSize = '1500m'
Kun Zhang3ddd1d52015-04-22 10:02:19 -0700400 }
nathanmittler164b7342014-12-15 09:58:05 -0800401}
zpencera62108a2017-09-27 08:31:43 -0700402
403// Run with: ./gradlew japicmp --continue
404def baselineGrpcVersion = '1.6.1'
405def publicApiSubprojects = [
Jiangtao Lie7f2f1d2018-02-15 09:28:00 -0800406 // TODO: uncomment after grpc-alts artifact is published.
407 // ':grpc-alts',
zpencera62108a2017-09-27 08:31:43 -0700408 ':grpc-auth',
409 ':grpc-context',
410 ':grpc-core',
411 ':grpc-grpclb',
412 ':grpc-netty',
413 ':grpc-okhttp',
414 ':grpc-protobuf',
415 ':grpc-protobuf-lite',
416 ':grpc-protobuf-nano',
417 ':grpc-stub',
418 ':grpc-testing',
419]
420
421publicApiSubprojects.each { name ->
422 project(":$name") {
423 apply plugin: 'me.champeau.gradle.japicmp'
424
425 // Get the baseline version's jar for this subproject
426 File baselineArtifact = null
427 // Use a detached configuration, otherwise the current version's jar will take precedence
428 // over the baseline jar.
429 // A necessary hack, the intuitive thing does NOT work:
430 // https://discuss.gradle.org/t/is-the-default-configuration-leaking-into-independent-configurations/2088/6
431 def oldGroup = project.group
432 try {
433 project.group = 'virtual_group_for_japicmp'
434 String depModule = "io.grpc:${project.name}:${baselineGrpcVersion}@jar"
435 String depJar = "${project.name}-${baselineGrpcVersion}.jar"
436 Configuration configuration = configurations.detachedConfiguration(
437 dependencies.create(depModule)
438 )
439 baselineArtifact = files(configuration.files).filter {
440 it.name.equals(depJar)
441 }.singleFile
442 } finally {
443 project.group = oldGroup
444 }
445
446 // Add a japicmp task that compares the current .jar with baseline .jar
447 task japicmp(type: me.champeau.gradle.japicmp.JapicmpTask, dependsOn: jar) {
448 oldClasspath = files(baselineArtifact)
449 newClasspath = files(jar.archivePath)
450 onlyBinaryIncompatibleModified = false
451 // Be quiet about things that did not change
452 onlyModified = true
453 // This task should fail if there are incompatible changes
454 failOnModification = true
455 ignoreMissingClasses = true
456 htmlOutputFile = file("$buildDir/reports/japi.html")
457
458 packageExcludes = ['io.grpc.internal']
459
460 // Also break on source incompatible changes, not just binary.
461 // Eg adding abstract method to public class.
462 // TODO(zpencer): enable after japicmp-gradle-plugin/pull/14
463 // breakOnSourceIncompatibility = true
464
465 // Ignore any classes or methods marked @ExperimentalApi
466 // TODO(zpencer): enable after japicmp-gradle-plugin/pull/15
467 // annotationExcludes = ['@io.grpc.ExperimentalApi']
468 }
469 }
470}