blob: ab2db123a099547a6605000a7e38556c184032c2 [file] [log] [blame]
Kun Zhang4bc2d6d2015-04-17 10:49:11 -07001buildscript {
ZHANG Dapeng5ce10f02018-06-11 18:35:18 -07002 repositories {
3 mavenLocal()
4 maven { url "https://plugins.gradle.org/m2/" }
Eric Anderson675080b2017-02-24 14:53:23 -08005 }
ZHANG Dapeng5ce10f02018-06-11 18:35:18 -07006 dependencies {
7 classpath "com.diffplug.spotless:spotless-plugin-gradle:3.13.0"
8 classpath 'com.google.gradle:osdetector-gradle-plugin:1.4.0'
Eric Andersond66ba242018-07-26 10:35:20 -07009 classpath 'ru.vyarus:gradle-animalsniffer-plugin:1.4.5'
ZHANG Dapeng5ce10f02018-06-11 18:35:18 -070010 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 Zhang4bc2d6d2015-04-17 10:49:11 -070015}
Eric Andersonb938ba52015-02-28 09:59:25 -080016
Louis Ryan540b4d32015-09-04 13:26:24 -070017subprojects {
Eric Andersonc3e8dae2015-01-30 14:58:07 -080018 apply plugin: "checkstyle"
nathanmittler164b7342014-12-15 09:58:05 -080019 apply plugin: "java"
20 apply plugin: "maven"
nmittler52f42202015-01-21 14:30:14 -080021 apply plugin: "idea"
Eric Anderson192144e2015-03-02 13:31:14 -080022 apply plugin: "signing"
Eric Anderson041cdb12015-05-05 12:29:26 -070023 apply plugin: "jacoco"
nathanmittler164b7342014-12-15 09:58:05 -080024
Eric Anderson6164b7b2017-08-26 17:10:18 -070025 apply plugin: "me.champeau.gradle.jmh"
nmittlerc4bcf142015-09-16 15:15:10 -070026 apply plugin: "com.google.osdetector"
Eric Anderson42aa64c2017-02-02 13:48:12 -080027 // The plugin only has an effect if a signature is specified
28 apply plugin: "ru.vyarus.animalsniffer"
zpencer37e6f5f2018-07-19 13:35:27 -070029 // 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 Dapeng5ce10f02018-06-11 18:35:18 -070032 apply plugin: "net.ltgt.errorprone"
33 apply plugin: "net.ltgt.apt"
Eric Anderson982541b2017-04-26 13:33:27 -070034
ZHANG Dapeng5ce10f02018-06-11 18:35:18 -070035 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 Anderson982541b2017-04-26 13:33:27 -070040 }
ZHANG Dapeng5ce10f02018-06-11 18:35:18 -070041 } 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 Anderson675080b2017-02-24 14:53:23 -080050 }
zpencer5713ebc2017-07-15 12:41:20 -070051 // TODO(zpencer): remove when intellij 2017.2 is released
52 // https://github.com/gradle/gradle/issues/2315
53 idea.module.inheritOutputDirs = true
nmittlerc4bcf142015-09-16 15:15:10 -070054
nmittlerf8314582015-01-27 10:25:39 -080055 group = "io.grpc"
zpencer43354452018-07-18 10:48:04 -070056 version = "1.15.0-SNAPSHOT" // CURRENT_GRPC_VERSION
nathanmittler164b7342014-12-15 09:58:05 -080057
58 sourceCompatibility = 1.6
59 targetCompatibility = 1.6
60
61 repositories {
ZHANG Dapeng5ce10f02018-06-11 18:35:18 -070062 maven { // The google mirror is less flaky than mavenCentral()
63 url "https://maven-central.storage-download.googleapis.com/repos/central/data/" }
zpencer066ad3c2018-03-01 19:11:24 -080064 mavenLocal()
nathanmittler164b7342014-12-15 09:58:05 -080065 }
66
ZHANG Dapeng5ce10f02018-06-11 18:35:18 -070067 [
68 compileJava,
69 compileTestJava,
70 compileJmhJava
71 ].each() {
72 it.options.compilerArgs += [
73 "-Xlint:all",
74 "-Xlint:-options",
75 "-Xlint:-path"
76 ]
Eric Anderson76d09552015-03-12 15:25:11 -070077 it.options.encoding = "UTF-8"
Eric Anderson3c03eb72016-07-10 11:40:12 -070078 if (rootProject.hasProperty('failOnWarnings') && rootProject.failOnWarnings.toBoolean()) {
79 it.options.compilerArgs += ["-Werror"]
80 }
nmittler02c953e2015-01-26 14:03:11 -080081 }
82
Eric Anderson641cb352016-05-24 14:29:52 -070083 compileTestJava {
ZHANG Dapeng5ce10f02018-06-11 18:35:18 -070084 // 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 Anderson641cb352016-05-24 14:29:52 -070090 }
91
nmittler8c1d38a2015-06-01 08:31:00 -070092 jar.manifest {
93 attributes('Implementation-Title': name,
ZHANG Dapeng5ce10f02018-06-11 18:35:18 -070094 '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)
nmittler8c1d38a2015-06-01 08:31:00 -070099 }
100
Eric Anderson10fb2062015-05-05 10:28:38 -0700101 javadoc.options {
102 encoding = 'UTF-8'
ZHANG Dapeng66ebcb12017-05-17 08:52:07 -0700103 use = true
Eric Anderson10fb2062015-05-05 10:28:38 -0700104 links 'https://docs.oracle.com/javase/8/docs/api/'
105 }
Eric Anderson14444a92015-03-11 16:44:38 -0700106
Jakob Buchgraber7ddcdfd2015-02-13 16:21:53 -0800107 ext {
Kun Zhang6b1e7d62015-05-07 15:20:44 -0700108 def exeSuffix = osdetector.os == 'windows' ? ".exe" : ""
109 protocPluginBaseName = 'protoc-gen-grpc-java'
Eric Anderson46ce4092016-01-26 12:13:06 -0800110 javaPluginPath = "$rootDir/compiler/build/exe/java_plugin/$protocPluginBaseName$exeSuffix"
Kun Zhang6b1e7d62015-05-07 15:20:44 -0700111
Carl Mastrangelo7d455962018-07-20 16:36:00 -0700112 nettyVersion = '4.1.27.Final'
Eric Anderson5f0ee3a2018-03-23 15:45:05 -0700113 guavaVersion = '20.0'
Kun Zhang86d64122018-01-05 16:40:20 -0800114 protobufVersion = '3.5.1'
115 protocVersion = '3.5.1-1'
Kun Zhange2ed2e82016-01-27 08:26:19 -0800116 protobufNanoVersion = '3.0.0-alpha-5'
Bogdan Drutu2a127ce2018-06-04 15:27:27 -0700117 opencensusVersion = '0.12.3'
Kun Zhang6b1e7d62015-05-07 15:20:44 -0700118
Kun Zhang111f6dd2015-05-05 16:11:27 -0700119 configureProtoCompilation = {
ZHANG Dapeng5ce10f02018-06-11 18:35:18 -0700120 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 Dapenge1091252016-07-21 16:35:18 -0700132 }
ZHANG Dapeng5ce10f02018-06-11 18:35:18 -0700133 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 Zhang2cdc5e32015-05-11 16:58:28 -0700148 }
ZHANG Dapeng5ce10f02018-06-11 18:35:18 -0700149
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 Zhang35f77ee2015-06-22 16:29:30 -0700175 }
176
ZHANG Dapeng5ce10f02018-06-11 18:35:18 -0700177 [
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 Zhang2cdc5e32015-05-11 16:58:28 -0700188 }
Kun Zhang111f6dd2015-05-05 16:11:27 -0700189 }
190
Eric Anderson65d73c02015-05-21 11:54:04 -0700191 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 Buchgraber7ddcdfd2015-02-13 16:21:53 -0800196 libraries = [
Eric Anderson15a5ba22018-07-19 13:40:41 -0700197 errorprone: "com.google.errorprone:error_prone_annotations:2.2.0",
ZHANG Dapeng5ce10f02018-06-11 18:35:18 -0700198 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",
nathanmittler164b7342014-12-15 09:58:05 -0800220
ZHANG Dapeng5ce10f02018-06-11 18:35:18 -0700221 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 Mastrangelo7d455962018-07-20 16:36:00 -0700224 netty_tcnative: 'io.netty:netty-tcnative-boringssl-static:2.0.12.Final',
nathanmittler164b7342014-12-15 09:58:05 -0800225
ZHANG Dapeng5ce10f02018-06-11 18:35:18 -0700226 conscrypt: 'org.conscrypt:conscrypt-openjdk-uber:1.0.1',
227 re2j: 'com.google.re2j:re2j:1.2',
Eric Anderson7eab0d92018-02-15 17:14:10 -0800228
ZHANG Dapeng5ce10f02018-06-11 18:35:18 -0700229 // Test dependencies.
230 junit: 'junit:junit:4.12',
231 mockito: 'org.mockito:mockito-core:1.9.5',
Eric Anderson5823fff2018-07-23 14:42:39 -0700232 truth: 'com.google.truth:truth:0.42',
ZHANG Dapeng5ce10f02018-06-11 18:35:18 -0700233 guava_testlib: 'com.google.guava:guava-testlib:20.0',
Louis Ryana7049bc2016-03-23 13:18:04 -0700234
ZHANG Dapeng5ce10f02018-06-11 18:35:18 -0700235 // Benchmark dependencies
236 hdrhistogram: 'org.hdrhistogram:HdrHistogram:2.1.10',
237 math: 'org.apache.commons:commons-math3:3.6',
ZHANG Dapengaed886d2016-05-02 14:01:36 -0700238
ZHANG Dapeng5ce10f02018-06-11 18:35:18 -0700239 // Jetty ALPN dependencies
240 jetty_alpn_agent: 'org.mortbay.jetty.alpn:jetty-alpn-agent:2.0.7'
Jakob Buchgraber7ddcdfd2015-02-13 16:21:53 -0800241 ]
Jakob Buchgraber7ddcdfd2015-02-13 16:21:53 -0800242 }
nathanmittler164b7342014-12-15 09:58:05 -0800243
ZHANG Dapengaed886d2016-05-02 14:01:36 -0700244 // Define a separate configuration for managing the dependency on Jetty ALPN agent.
nmittler74cfe6c2015-05-22 12:25:10 -0700245 configurations {
ZHANG Dapengaed886d2016-05-02 14:01:36 -0700246 alpnagent
Eric Andersona3ff9cd2017-09-18 16:20:18 -0700247
248 compile {
249 // Detect Maven Enforcer's dependencyConvergence failures. We only
250 // care for artifacts used as libraries by others.
ZHANG Dapeng5ce10f02018-06-11 18:35:18 -0700251 if (!(project.name in [
252 'grpc-benchmarks',
Eric Andersonc30e5092018-07-20 17:59:19 -0700253 'grpc-interop-testing',
254 'grpc-gae-interop-testing-jdk7',
255 'grpc-gae-interop-testing-jdk8',
ZHANG Dapeng5ce10f02018-06-11 18:35:18 -0700256 ])) {
Eric Andersona3ff9cd2017-09-18 16:20:18 -0700257 resolutionStrategy.failOnVersionConflict()
258 }
259 }
nmittler74cfe6c2015-05-22 12:25:10 -0700260 }
261
nathanmittler164b7342014-12-15 09:58:05 -0800262 dependencies {
263 testCompile libraries.junit,
ZHANG Dapeng5ce10f02018-06-11 18:35:18 -0700264 libraries.mockito,
265 libraries.truth
nmittler74cfe6c2015-05-22 12:25:10 -0700266
ZHANG Dapengaed886d2016-05-02 14:01:36 -0700267 // Configuration for modules that use Jetty ALPN agent
268 alpnagent libraries.jetty_alpn_agent
Eric Anderson6164b7b2017-08-26 17:10:18 -0700269
270 jmh 'org.openjdk.jmh:jmh-core:1.19',
ZHANG Dapeng5ce10f02018-06-11 18:35:18 -0700271 'org.openjdk.jmh:jmh-generator-bytecode:1.19'
nathanmittler164b7342014-12-15 09:58:05 -0800272 }
Eric Anderson192144e2015-03-02 13:31:14 -0800273
274 signing {
275 required false
276 sign configurations.archives
277 }
278
nmittler732cfc02015-03-03 07:59:13 -0800279 // Disable JavaDoc doclint on Java 8. It's annoying.
280 if (JavaVersion.current().isJava8Compatible()) {
ZHANG Dapeng5ce10f02018-06-11 18:35:18 -0700281 allprojects {
282 tasks.withType(Javadoc) {
283 options.addStringOption('Xdoclint:none', '-quiet')
284 }
nmittler732cfc02015-03-03 07:59:13 -0800285 }
nmittler732cfc02015-03-03 07:59:13 -0800286 }
287
zpencer37e6f5f2018-07-19 13:35:27 -0700288 // For jdk10 we must explicitly choose between html4 and html5, otherwise we get a warning
289 if (JavaVersion.current().isJava10Compatible()) {
290 allprojects {
291 tasks.withType(Javadoc) {
292 options.addBooleanOption('html4', true)
293 }
294 }
295 }
296
Eric Andersonc3e8dae2015-01-30 14:58:07 -0800297 checkstyle {
Eric Anderson8188a3e2017-07-12 10:53:50 -0700298 configDir = file("$rootDir/buildscripts")
Eric Anderson6ab27ab2016-04-18 09:15:25 -0700299 toolVersion = "6.17"
Eric Andersonad44f0a2015-05-05 08:54:51 -0700300 ignoreFailures = false
Eric Anderson26141b42015-03-21 10:59:17 -0700301 if (rootProject.hasProperty("checkstyle.ignoreFailures")) {
302 ignoreFailures = rootProject.properties["checkstyle.ignoreFailures"].toBoolean()
303 }
Eric Andersonc3e8dae2015-01-30 14:58:07 -0800304 }
305
306 checkstyleMain {
Kun Zhang693a7d22015-05-06 11:35:08 -0700307 source = fileTree(dir: "src/main", include: "**/*.java")
Eric Andersonc3e8dae2015-01-30 14:58:07 -0800308 }
309
310 checkstyleTest {
Kun Zhang693a7d22015-05-06 11:35:08 -0700311 source = fileTree(dir: "src/test", include: "**/*.java")
Eric Andersonc3e8dae2015-01-30 14:58:07 -0800312 }
313
zpencer4f19f142018-03-13 17:46:03 -0700314 // invoke jmh on a single benchmark class like so:
315 // ./gradlew -PjmhIncludeSingleClass=StatsTraceContextBenchmark clean :grpc-core:jmh
Eric Anderson6164b7b2017-08-26 17:10:18 -0700316 jmh {
317 warmupIterations = 10
318 iterations = 10
319 fork = 1
320 // None of our benchmarks need the tests, and we have pseudo-circular
321 // dependencies that break when including them. (context's testCompile
322 // depends on core; core's testCompile depends on testing)
323 includeTests = false
zpencer4f19f142018-03-13 17:46:03 -0700324 if (project.hasProperty('jmhIncludeSingleClass')) {
ZHANG Dapeng5ce10f02018-06-11 18:35:18 -0700325 include = [
326 project.property('jmhIncludeSingleClass')
327 ]
zpencer4f19f142018-03-13 17:46:03 -0700328 }
Eric Anderson6164b7b2017-08-26 17:10:18 -0700329 }
330
Eric Anderson192144e2015-03-02 13:31:14 -0800331 task javadocJar(type: Jar) {
332 classifier = 'javadoc'
333 from javadoc
334 }
335
336 task sourcesJar(type: Jar) {
337 classifier = 'sources'
338 from sourceSets.main.allSource
339 }
340
ZHANG Dapeng5ce10f02018-06-11 18:35:18 -0700341 artifacts { archives javadocJar, sourcesJar }
Eric Anderson192144e2015-03-02 13:31:14 -0800342
343 uploadArchives.repositories.mavenDeployer {
344 beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
Eric Anderson4f4cedf2017-12-14 16:51:14 -0800345 if (rootProject.hasProperty('repositoryDir')) {
ZHANG Dapeng5ce10f02018-06-11 18:35:18 -0700346 repository(url: new File(rootProject.repositoryDir).toURI())
Eric Anderson4f4cedf2017-12-14 16:51:14 -0800347 } else {
ZHANG Dapeng5ce10f02018-06-11 18:35:18 -0700348 String stagingUrl
349 if (rootProject.hasProperty('repositoryId')) {
350 stagingUrl = 'https://oss.sonatype.org/service/local/staging/deployByRepositoryId/' +
351 rootProject.repositoryId
352 } else {
353 stagingUrl = 'https://oss.sonatype.org/service/local/staging/deploy/maven2/'
zpencer89259212018-02-13 11:17:53 -0800354 }
ZHANG Dapeng5ce10f02018-06-11 18:35:18 -0700355 def configureAuth = {
356 if (rootProject.hasProperty('ossrhUsername') && rootProject.hasProperty('ossrhPassword')) {
357 authentication(userName: rootProject.ossrhUsername, password: rootProject.ossrhPassword)
358 }
359 }
360 repository(url: stagingUrl, configureAuth)
361 snapshotRepository(url: 'https://oss.sonatype.org/content/repositories/snapshots/', configureAuth)
Eric Anderson4f4cedf2017-12-14 16:51:14 -0800362 }
Eric Anderson192144e2015-03-02 13:31:14 -0800363 }
zpencerb07c70a2017-10-06 10:44:58 -0700364 uploadArchives.onlyIf { !name.contains("grpc-gae-interop-testing") }
Eric Anderson192144e2015-03-02 13:31:14 -0800365
366 [
ZHANG Dapeng5ce10f02018-06-11 18:35:18 -0700367 install.repositories.mavenInstaller,
368 uploadArchives.repositories.mavenDeployer,
Eric Anderson192144e2015-03-02 13:31:14 -0800369 ]*.pom*.whenConfigured { pom ->
370 pom.project {
Eric Anderson7e8a02c2015-03-12 17:03:01 -0700371 name "$project.group:$project.name"
Eric Anderson192144e2015-03-02 13:31:14 -0800372 description project.description
373 url 'https://github.com/grpc/grpc-java'
374
375 scm {
Eric Andersonb7354952016-04-08 08:37:07 -0700376 connection 'scm:git:https://github.com/grpc/grpc-java.git'
377 developerConnection 'scm:git:git@github.com:grpc/grpc-java.git'
Eric Anderson192144e2015-03-02 13:31:14 -0800378 url 'https://github.com/grpc/grpc-java'
379 }
380
381 licenses {
382 license {
Carl Mastrangelo7b97df02017-05-31 14:37:42 -0700383 name 'Apache 2.0'
384 url 'https://opensource.org/licenses/Apache-2.0'
Eric Anderson192144e2015-03-02 13:31:14 -0800385 }
386 }
Eric Anderson7e8a02c2015-03-12 17:03:01 -0700387
388 developers {
389 developer {
390 id "grpc.io"
391 name "gRPC Contributors"
392 email "grpc-io@googlegroups.com"
Mehrdad Afshari8ce0bc22017-07-10 22:48:17 +0000393 url "https://grpc.io/"
Eric Anderson7e8a02c2015-03-12 17:03:01 -0700394 // https://issues.gradle.org/browse/GRADLE-2719
Carl Mastrangelo3bfd6302017-05-31 13:29:01 -0700395 organization = "gRPC Authors"
Eric Anderson7e8a02c2015-03-12 17:03:01 -0700396 organizationUrl "https://www.google.com"
397 }
398 }
Eric Anderson192144e2015-03-02 13:31:14 -0800399 }
Eric Anderson90db93b2016-04-08 13:47:30 -0700400 if (!(project.name in
ZHANG Dapeng5ce10f02018-06-11 18:35:18 -0700401 [
402 "grpc-stub",
403 "grpc-protobuf",
404 "grpc-protobuf-lite",
405 "grpc-protobuf-nano"
406 ])) {
407 def core = pom.dependencies.find {dep -> dep.artifactId == 'grpc-core'}
408 if (core != null) {
409 // Depend on specific version of grpc-core because internal package is unstable
410 core.version = "[" + core.version + "]"
411 }
Eric Anderson90db93b2016-04-08 13:47:30 -0700412 }
Eric Anderson192144e2015-03-02 13:31:14 -0800413 }
Kun Zhang3ddd1d52015-04-22 10:02:19 -0700414 // At a test failure, log the stack trace to the console so that we don't
415 // have to open the HTML in a browser.
416 test {
417 testLogging {
418 exceptionFormat = 'full'
nmittler4ee2a652015-06-01 16:20:08 -0700419 showExceptions true
420 showCauses true
421 showStackTraces true
Kun Zhang3ddd1d52015-04-22 10:02:19 -0700422 }
Eric Anderson56dca032016-02-12 08:48:41 -0800423 maxHeapSize = '1500m'
Kun Zhang3ddd1d52015-04-22 10:02:19 -0700424 }
nathanmittler164b7342014-12-15 09:58:05 -0800425}
zpencera62108a2017-09-27 08:31:43 -0700426
427// Run with: ./gradlew japicmp --continue
428def baselineGrpcVersion = '1.6.1'
429def publicApiSubprojects = [
ZHANG Dapeng5ce10f02018-06-11 18:35:18 -0700430 // TODO: uncomment after grpc-alts artifact is published.
431 // ':grpc-alts',
432 ':grpc-auth',
433 ':grpc-context',
434 ':grpc-core',
435 ':grpc-grpclb',
436 ':grpc-netty',
437 ':grpc-okhttp',
438 ':grpc-protobuf',
439 ':grpc-protobuf-lite',
440 ':grpc-protobuf-nano',
441 ':grpc-stub',
442 ':grpc-testing',
zpencera62108a2017-09-27 08:31:43 -0700443]
444
445publicApiSubprojects.each { name ->
446 project(":$name") {
447 apply plugin: 'me.champeau.gradle.japicmp'
448
449 // Get the baseline version's jar for this subproject
450 File baselineArtifact = null
451 // Use a detached configuration, otherwise the current version's jar will take precedence
452 // over the baseline jar.
453 // A necessary hack, the intuitive thing does NOT work:
454 // https://discuss.gradle.org/t/is-the-default-configuration-leaking-into-independent-configurations/2088/6
455 def oldGroup = project.group
456 try {
457 project.group = 'virtual_group_for_japicmp'
458 String depModule = "io.grpc:${project.name}:${baselineGrpcVersion}@jar"
459 String depJar = "${project.name}-${baselineGrpcVersion}.jar"
460 Configuration configuration = configurations.detachedConfiguration(
461 dependencies.create(depModule)
ZHANG Dapeng5ce10f02018-06-11 18:35:18 -0700462 )
zpencera62108a2017-09-27 08:31:43 -0700463 baselineArtifact = files(configuration.files).filter {
464 it.name.equals(depJar)
465 }.singleFile
466 } finally {
467 project.group = oldGroup
468 }
469
470 // Add a japicmp task that compares the current .jar with baseline .jar
471 task japicmp(type: me.champeau.gradle.japicmp.JapicmpTask, dependsOn: jar) {
472 oldClasspath = files(baselineArtifact)
473 newClasspath = files(jar.archivePath)
474 onlyBinaryIncompatibleModified = false
475 // Be quiet about things that did not change
476 onlyModified = true
477 // This task should fail if there are incompatible changes
478 failOnModification = true
479 ignoreMissingClasses = true
480 htmlOutputFile = file("$buildDir/reports/japi.html")
481
482 packageExcludes = ['io.grpc.internal']
483
484 // Also break on source incompatible changes, not just binary.
485 // Eg adding abstract method to public class.
486 // TODO(zpencer): enable after japicmp-gradle-plugin/pull/14
487 // breakOnSourceIncompatibility = true
488
489 // Ignore any classes or methods marked @ExperimentalApi
490 // TODO(zpencer): enable after japicmp-gradle-plugin/pull/15
491 // annotationExcludes = ['@io.grpc.ExperimentalApi']
492 }
493 }
494}
ZHANG Dapeng5ce10f02018-06-11 18:35:18 -0700495
496// format checkers
497apply plugin: "com.diffplug.gradle.spotless"
498apply plugin: 'groovy'
499spotless {
500 groovyGradle {
501 target '**/*.gradle'
502 greclipse()
503 indentWithSpaces()
504 paddedCell()
505 }
506}