blob: 7129629598f080835bee13d40555548887b88ffe [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",
Eric Anderson778804f2018-08-16 09:35:25 -070075 "-Xlint:-path",
76 "-Xlint:-try"
ZHANG Dapeng5ce10f02018-06-11 18:35:18 -070077 ]
Eric Anderson76d09552015-03-12 15:25:11 -070078 it.options.encoding = "UTF-8"
Eric Anderson3c03eb72016-07-10 11:40:12 -070079 if (rootProject.hasProperty('failOnWarnings') && rootProject.failOnWarnings.toBoolean()) {
80 it.options.compilerArgs += ["-Werror"]
81 }
nmittler02c953e2015-01-26 14:03:11 -080082 }
83
Eric Anderson641cb352016-05-24 14:29:52 -070084 compileTestJava {
ZHANG Dapeng5ce10f02018-06-11 18:35:18 -070085 // serialVersionUID is basically guaranteed to be useless in our tests
86 // LinkedList doesn't hurt much in tests and has lots of usages
87 options.compilerArgs += [
88 "-Xlint:-serial",
89 "-Xep:JdkObsolete:OFF"
90 ]
Eric Anderson641cb352016-05-24 14:29:52 -070091 }
92
nmittler8c1d38a2015-06-01 08:31:00 -070093 jar.manifest {
94 attributes('Implementation-Title': name,
ZHANG Dapeng5ce10f02018-06-11 18:35:18 -070095 'Implementation-Version': version,
96 'Built-By': System.getProperty('user.name'),
97 'Built-JDK': System.getProperty('java.version'),
98 'Source-Compatibility': sourceCompatibility,
99 'Target-Compatibility': targetCompatibility)
nmittler8c1d38a2015-06-01 08:31:00 -0700100 }
101
Eric Anderson10fb2062015-05-05 10:28:38 -0700102 javadoc.options {
103 encoding = 'UTF-8'
ZHANG Dapeng66ebcb12017-05-17 08:52:07 -0700104 use = true
Eric Anderson10fb2062015-05-05 10:28:38 -0700105 links 'https://docs.oracle.com/javase/8/docs/api/'
106 }
Eric Anderson14444a92015-03-11 16:44:38 -0700107
Jakob Buchgraber7ddcdfd2015-02-13 16:21:53 -0800108 ext {
Kun Zhang6b1e7d62015-05-07 15:20:44 -0700109 def exeSuffix = osdetector.os == 'windows' ? ".exe" : ""
110 protocPluginBaseName = 'protoc-gen-grpc-java'
Eric Anderson46ce4092016-01-26 12:13:06 -0800111 javaPluginPath = "$rootDir/compiler/build/exe/java_plugin/$protocPluginBaseName$exeSuffix"
Kun Zhang6b1e7d62015-05-07 15:20:44 -0700112
Carl Mastrangelo7d455962018-07-20 16:36:00 -0700113 nettyVersion = '4.1.27.Final'
Eric Anderson5f0ee3a2018-03-23 15:45:05 -0700114 guavaVersion = '20.0'
Kun Zhang86d64122018-01-05 16:40:20 -0800115 protobufVersion = '3.5.1'
116 protocVersion = '3.5.1-1'
Kun Zhange2ed2e82016-01-27 08:26:19 -0800117 protobufNanoVersion = '3.0.0-alpha-5'
Bogdan Drutu2a127ce2018-06-04 15:27:27 -0700118 opencensusVersion = '0.12.3'
Kun Zhang6b1e7d62015-05-07 15:20:44 -0700119
Kun Zhang111f6dd2015-05-05 16:11:27 -0700120 configureProtoCompilation = {
ZHANG Dapeng5ce10f02018-06-11 18:35:18 -0700121 String generatedSourcePath = "${projectDir}/src/generated"
122 if (rootProject.childProjects.containsKey('grpc-compiler')) {
123 // Only when the codegen is built along with the project, will we be able to recompile
124 // the proto files.
125 project.apply plugin: 'com.google.protobuf'
126 project.protobuf {
127 protoc {
128 if (project.hasProperty('protoc')) {
129 path = project.protoc
130 } else {
131 artifact = "com.google.protobuf:protoc:${protocVersion}"
132 }
ZHANG Dapenge1091252016-07-21 16:35:18 -0700133 }
ZHANG Dapeng5ce10f02018-06-11 18:35:18 -0700134 plugins { grpc { path = javaPluginPath } }
135 generateProtoTasks {
136 all().each { task ->
137 task.dependsOn ':grpc-compiler:java_pluginExecutable'
138 // Delete the generated sources first, so that we can be alerted if they are not re-compiled.
139 task.dependsOn 'deleteGeneratedSource' + task.sourceSet.name
140 // Recompile protos when the codegen has been changed
141 task.inputs.file javaPluginPath
142 // Recompile protos when build.gradle has been changed, because
143 // it's possible the version of protoc has been changed.
144 task.inputs.file "${rootProject.projectDir}/build.gradle"
145 task.plugins { grpc { option 'noversion' } }
146 }
147 }
148 generatedFilesBaseDir = generatedSourcePath
Kun Zhang2cdc5e32015-05-11 16:58:28 -0700149 }
ZHANG Dapeng5ce10f02018-06-11 18:35:18 -0700150
151 sourceSets.each { sourceSet ->
152 task "deleteGeneratedSource${sourceSet.name}" {
153 doLast {
154 project.delete project.fileTree(dir: generatedSourcePath + '/' + sourceSet.name)
155 }
156 }
157 }
158 } else {
159 // Otherwise, we just use the checked-in generated code.
160 project.sourceSets {
161 main {
162 java {
163 srcDir "${generatedSourcePath}/main/java"
164 srcDir "${generatedSourcePath}/main/javanano"
165 srcDir "${generatedSourcePath}/main/grpc"
166 }
167 }
168 test {
169 java {
170 srcDir "${generatedSourcePath}/test/java"
171 srcDir "${generatedSourcePath}/test/javanano"
172 srcDir "${generatedSourcePath}/test/grpc"
173 }
174 }
175 }
Kun Zhang35f77ee2015-06-22 16:29:30 -0700176 }
177
ZHANG Dapeng5ce10f02018-06-11 18:35:18 -0700178 [
179 compileJava,
180 compileTestJava,
181 compileJmhJava
182 ].each() {
183 // Protobuf-generated code produces some warnings.
184 // https://github.com/google/protobuf/issues/2718
185 it.options.compilerArgs += [
186 "-Xlint:-cast",
187 "-XepExcludedPaths:.*/src/generated/[^/]+/java/.*",
188 ]
Kun Zhang2cdc5e32015-05-11 16:58:28 -0700189 }
Kun Zhang111f6dd2015-05-05 16:11:27 -0700190 }
191
Eric Anderson65d73c02015-05-21 11:54:04 -0700192 def epoll_suffix = "";
193 if (osdetector.classifier in ["linux-x86_64"]) {
194 // The native code is only pre-compiled on certain platforms.
195 epoll_suffix = ":" + osdetector.classifier
196 }
Jakob Buchgraber7ddcdfd2015-02-13 16:21:53 -0800197 libraries = [
Eric Gribkoff79b24702018-08-09 09:09:21 -0700198 animalsniffer_annotations: "org.codehaus.mojo:animal-sniffer-annotations:1.17",
Eric Anderson15a5ba22018-07-19 13:40:41 -0700199 errorprone: "com.google.errorprone:error_prone_annotations:2.2.0",
ZHANG Dapeng5ce10f02018-06-11 18:35:18 -0700200 gson: "com.google.code.gson:gson:2.7",
201 guava: "com.google.guava:guava:${guavaVersion}",
202 hpack: 'com.twitter:hpack:0.10.1',
203 javax_annotation: 'javax.annotation:javax.annotation-api:1.2',
204 jsr305: 'com.google.code.findbugs:jsr305:3.0.0',
205 oauth_client: 'com.google.auth:google-auth-library-oauth2-http:0.9.0',
206 google_api_protos: 'com.google.api.grpc:proto-google-common-protos:1.0.0',
207 google_auth_credentials: 'com.google.auth:google-auth-library-credentials:0.9.0',
208 okhttp: 'com.squareup.okhttp:okhttp:2.5.0',
209 okio: 'com.squareup.okio:okio:1.13.0',
210 opencensus_api: "io.opencensus:opencensus-api:${opencensusVersion}",
211 opencensus_contrib_grpc_metrics: "io.opencensus:opencensus-contrib-grpc-metrics:${opencensusVersion}",
212 opencensus_impl: "io.opencensus:opencensus-impl:${opencensusVersion}",
213 opencensus_impl_lite: "io.opencensus:opencensus-impl-lite:${opencensusVersion}",
214 instrumentation_api: 'com.google.instrumentation:instrumentation-api:0.4.3',
215 protobuf: "com.google.protobuf:protobuf-java:${protobufVersion}",
216 protobuf_lite: "com.google.protobuf:protobuf-lite:3.0.1",
217 protoc_lite: "com.google.protobuf:protoc-gen-javalite:3.0.0",
218 protobuf_nano: "com.google.protobuf.nano:protobuf-javanano:${protobufNanoVersion}",
219 protobuf_plugin: 'com.google.protobuf:protobuf-gradle-plugin:0.8.5',
220 protobuf_util: "com.google.protobuf:protobuf-java-util:${protobufVersion}",
221 lang: "org.apache.commons:commons-lang3:3.5",
nathanmittler164b7342014-12-15 09:58:05 -0800222
ZHANG Dapeng5ce10f02018-06-11 18:35:18 -0700223 netty: "io.netty:netty-codec-http2:[${nettyVersion}]",
224 netty_epoll: "io.netty:netty-transport-native-epoll:${nettyVersion}" + epoll_suffix,
225 netty_proxy_handler: "io.netty:netty-handler-proxy:${nettyVersion}",
Carl Mastrangelo7d455962018-07-20 16:36:00 -0700226 netty_tcnative: 'io.netty:netty-tcnative-boringssl-static:2.0.12.Final',
nathanmittler164b7342014-12-15 09:58:05 -0800227
ZHANG Dapeng5ce10f02018-06-11 18:35:18 -0700228 conscrypt: 'org.conscrypt:conscrypt-openjdk-uber:1.0.1',
229 re2j: 'com.google.re2j:re2j:1.2',
Eric Anderson7eab0d92018-02-15 17:14:10 -0800230
ZHANG Dapeng5ce10f02018-06-11 18:35:18 -0700231 // Test dependencies.
232 junit: 'junit:junit:4.12',
233 mockito: 'org.mockito:mockito-core:1.9.5',
Eric Anderson5823fff2018-07-23 14:42:39 -0700234 truth: 'com.google.truth:truth:0.42',
ZHANG Dapeng5ce10f02018-06-11 18:35:18 -0700235 guava_testlib: 'com.google.guava:guava-testlib:20.0',
Louis Ryana7049bc2016-03-23 13:18:04 -0700236
ZHANG Dapeng5ce10f02018-06-11 18:35:18 -0700237 // Benchmark dependencies
238 hdrhistogram: 'org.hdrhistogram:HdrHistogram:2.1.10',
239 math: 'org.apache.commons:commons-math3:3.6',
ZHANG Dapengaed886d2016-05-02 14:01:36 -0700240
ZHANG Dapeng5ce10f02018-06-11 18:35:18 -0700241 // Jetty ALPN dependencies
242 jetty_alpn_agent: 'org.mortbay.jetty.alpn:jetty-alpn-agent:2.0.7'
Jakob Buchgraber7ddcdfd2015-02-13 16:21:53 -0800243 ]
Jakob Buchgraber7ddcdfd2015-02-13 16:21:53 -0800244 }
nathanmittler164b7342014-12-15 09:58:05 -0800245
ZHANG Dapengaed886d2016-05-02 14:01:36 -0700246 // Define a separate configuration for managing the dependency on Jetty ALPN agent.
nmittler74cfe6c2015-05-22 12:25:10 -0700247 configurations {
ZHANG Dapengaed886d2016-05-02 14:01:36 -0700248 alpnagent
Eric Andersona3ff9cd2017-09-18 16:20:18 -0700249
250 compile {
251 // Detect Maven Enforcer's dependencyConvergence failures. We only
252 // care for artifacts used as libraries by others.
ZHANG Dapeng5ce10f02018-06-11 18:35:18 -0700253 if (!(project.name in [
254 'grpc-benchmarks',
Eric Andersonc30e5092018-07-20 17:59:19 -0700255 'grpc-interop-testing',
256 'grpc-gae-interop-testing-jdk7',
257 'grpc-gae-interop-testing-jdk8',
ZHANG Dapeng5ce10f02018-06-11 18:35:18 -0700258 ])) {
Eric Andersona3ff9cd2017-09-18 16:20:18 -0700259 resolutionStrategy.failOnVersionConflict()
260 }
261 }
nmittler74cfe6c2015-05-22 12:25:10 -0700262 }
263
nathanmittler164b7342014-12-15 09:58:05 -0800264 dependencies {
265 testCompile libraries.junit,
ZHANG Dapeng5ce10f02018-06-11 18:35:18 -0700266 libraries.mockito,
267 libraries.truth
nmittler74cfe6c2015-05-22 12:25:10 -0700268
ZHANG Dapengaed886d2016-05-02 14:01:36 -0700269 // Configuration for modules that use Jetty ALPN agent
270 alpnagent libraries.jetty_alpn_agent
Eric Anderson6164b7b2017-08-26 17:10:18 -0700271
272 jmh 'org.openjdk.jmh:jmh-core:1.19',
ZHANG Dapeng5ce10f02018-06-11 18:35:18 -0700273 'org.openjdk.jmh:jmh-generator-bytecode:1.19'
nathanmittler164b7342014-12-15 09:58:05 -0800274 }
Eric Anderson192144e2015-03-02 13:31:14 -0800275
276 signing {
277 required false
278 sign configurations.archives
279 }
280
nmittler732cfc02015-03-03 07:59:13 -0800281 // Disable JavaDoc doclint on Java 8. It's annoying.
282 if (JavaVersion.current().isJava8Compatible()) {
ZHANG Dapeng5ce10f02018-06-11 18:35:18 -0700283 allprojects {
284 tasks.withType(Javadoc) {
285 options.addStringOption('Xdoclint:none', '-quiet')
286 }
nmittler732cfc02015-03-03 07:59:13 -0800287 }
nmittler732cfc02015-03-03 07:59:13 -0800288 }
289
zpencer37e6f5f2018-07-19 13:35:27 -0700290 // For jdk10 we must explicitly choose between html4 and html5, otherwise we get a warning
291 if (JavaVersion.current().isJava10Compatible()) {
292 allprojects {
293 tasks.withType(Javadoc) {
294 options.addBooleanOption('html4', true)
295 }
296 }
297 }
298
Eric Andersonc3e8dae2015-01-30 14:58:07 -0800299 checkstyle {
Eric Anderson8188a3e2017-07-12 10:53:50 -0700300 configDir = file("$rootDir/buildscripts")
Eric Anderson6ab27ab2016-04-18 09:15:25 -0700301 toolVersion = "6.17"
Eric Andersonad44f0a2015-05-05 08:54:51 -0700302 ignoreFailures = false
Eric Anderson26141b42015-03-21 10:59:17 -0700303 if (rootProject.hasProperty("checkstyle.ignoreFailures")) {
304 ignoreFailures = rootProject.properties["checkstyle.ignoreFailures"].toBoolean()
305 }
Eric Andersonc3e8dae2015-01-30 14:58:07 -0800306 }
307
308 checkstyleMain {
Kun Zhang693a7d22015-05-06 11:35:08 -0700309 source = fileTree(dir: "src/main", include: "**/*.java")
Eric Andersonc3e8dae2015-01-30 14:58:07 -0800310 }
311
312 checkstyleTest {
Kun Zhang693a7d22015-05-06 11:35:08 -0700313 source = fileTree(dir: "src/test", include: "**/*.java")
Eric Andersonc3e8dae2015-01-30 14:58:07 -0800314 }
315
zpencer4f19f142018-03-13 17:46:03 -0700316 // invoke jmh on a single benchmark class like so:
317 // ./gradlew -PjmhIncludeSingleClass=StatsTraceContextBenchmark clean :grpc-core:jmh
Eric Anderson6164b7b2017-08-26 17:10:18 -0700318 jmh {
319 warmupIterations = 10
320 iterations = 10
321 fork = 1
322 // None of our benchmarks need the tests, and we have pseudo-circular
323 // dependencies that break when including them. (context's testCompile
324 // depends on core; core's testCompile depends on testing)
325 includeTests = false
zpencer4f19f142018-03-13 17:46:03 -0700326 if (project.hasProperty('jmhIncludeSingleClass')) {
ZHANG Dapeng5ce10f02018-06-11 18:35:18 -0700327 include = [
328 project.property('jmhIncludeSingleClass')
329 ]
zpencer4f19f142018-03-13 17:46:03 -0700330 }
Eric Anderson6164b7b2017-08-26 17:10:18 -0700331 }
332
Eric Anderson192144e2015-03-02 13:31:14 -0800333 task javadocJar(type: Jar) {
334 classifier = 'javadoc'
335 from javadoc
336 }
337
338 task sourcesJar(type: Jar) {
339 classifier = 'sources'
340 from sourceSets.main.allSource
341 }
342
ZHANG Dapeng5ce10f02018-06-11 18:35:18 -0700343 artifacts { archives javadocJar, sourcesJar }
Eric Anderson192144e2015-03-02 13:31:14 -0800344
345 uploadArchives.repositories.mavenDeployer {
346 beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
Eric Anderson4f4cedf2017-12-14 16:51:14 -0800347 if (rootProject.hasProperty('repositoryDir')) {
ZHANG Dapeng5ce10f02018-06-11 18:35:18 -0700348 repository(url: new File(rootProject.repositoryDir).toURI())
Eric Anderson4f4cedf2017-12-14 16:51:14 -0800349 } else {
ZHANG Dapeng5ce10f02018-06-11 18:35:18 -0700350 String stagingUrl
351 if (rootProject.hasProperty('repositoryId')) {
352 stagingUrl = 'https://oss.sonatype.org/service/local/staging/deployByRepositoryId/' +
353 rootProject.repositoryId
354 } else {
355 stagingUrl = 'https://oss.sonatype.org/service/local/staging/deploy/maven2/'
zpencer89259212018-02-13 11:17:53 -0800356 }
ZHANG Dapeng5ce10f02018-06-11 18:35:18 -0700357 def configureAuth = {
358 if (rootProject.hasProperty('ossrhUsername') && rootProject.hasProperty('ossrhPassword')) {
359 authentication(userName: rootProject.ossrhUsername, password: rootProject.ossrhPassword)
360 }
361 }
362 repository(url: stagingUrl, configureAuth)
363 snapshotRepository(url: 'https://oss.sonatype.org/content/repositories/snapshots/', configureAuth)
Eric Anderson4f4cedf2017-12-14 16:51:14 -0800364 }
Eric Anderson192144e2015-03-02 13:31:14 -0800365 }
zpencerb07c70a2017-10-06 10:44:58 -0700366 uploadArchives.onlyIf { !name.contains("grpc-gae-interop-testing") }
Eric Anderson192144e2015-03-02 13:31:14 -0800367
368 [
ZHANG Dapeng5ce10f02018-06-11 18:35:18 -0700369 install.repositories.mavenInstaller,
370 uploadArchives.repositories.mavenDeployer,
Eric Anderson192144e2015-03-02 13:31:14 -0800371 ]*.pom*.whenConfigured { pom ->
372 pom.project {
Eric Anderson7e8a02c2015-03-12 17:03:01 -0700373 name "$project.group:$project.name"
Eric Anderson192144e2015-03-02 13:31:14 -0800374 description project.description
375 url 'https://github.com/grpc/grpc-java'
376
377 scm {
Eric Andersonb7354952016-04-08 08:37:07 -0700378 connection 'scm:git:https://github.com/grpc/grpc-java.git'
379 developerConnection 'scm:git:git@github.com:grpc/grpc-java.git'
Eric Anderson192144e2015-03-02 13:31:14 -0800380 url 'https://github.com/grpc/grpc-java'
381 }
382
383 licenses {
384 license {
Carl Mastrangelo7b97df02017-05-31 14:37:42 -0700385 name 'Apache 2.0'
386 url 'https://opensource.org/licenses/Apache-2.0'
Eric Anderson192144e2015-03-02 13:31:14 -0800387 }
388 }
Eric Anderson7e8a02c2015-03-12 17:03:01 -0700389
390 developers {
391 developer {
392 id "grpc.io"
393 name "gRPC Contributors"
394 email "grpc-io@googlegroups.com"
Mehrdad Afshari8ce0bc22017-07-10 22:48:17 +0000395 url "https://grpc.io/"
Eric Anderson7e8a02c2015-03-12 17:03:01 -0700396 // https://issues.gradle.org/browse/GRADLE-2719
Carl Mastrangelo3bfd6302017-05-31 13:29:01 -0700397 organization = "gRPC Authors"
Eric Anderson7e8a02c2015-03-12 17:03:01 -0700398 organizationUrl "https://www.google.com"
399 }
400 }
Eric Anderson192144e2015-03-02 13:31:14 -0800401 }
Eric Anderson90db93b2016-04-08 13:47:30 -0700402 if (!(project.name in
ZHANG Dapeng5ce10f02018-06-11 18:35:18 -0700403 [
404 "grpc-stub",
405 "grpc-protobuf",
406 "grpc-protobuf-lite",
407 "grpc-protobuf-nano"
408 ])) {
409 def core = pom.dependencies.find {dep -> dep.artifactId == 'grpc-core'}
410 if (core != null) {
411 // Depend on specific version of grpc-core because internal package is unstable
412 core.version = "[" + core.version + "]"
413 }
Eric Anderson90db93b2016-04-08 13:47:30 -0700414 }
Eric Anderson192144e2015-03-02 13:31:14 -0800415 }
Kun Zhang3ddd1d52015-04-22 10:02:19 -0700416 // At a test failure, log the stack trace to the console so that we don't
417 // have to open the HTML in a browser.
418 test {
419 testLogging {
420 exceptionFormat = 'full'
nmittler4ee2a652015-06-01 16:20:08 -0700421 showExceptions true
422 showCauses true
423 showStackTraces true
Kun Zhang3ddd1d52015-04-22 10:02:19 -0700424 }
Eric Anderson56dca032016-02-12 08:48:41 -0800425 maxHeapSize = '1500m'
Kun Zhang3ddd1d52015-04-22 10:02:19 -0700426 }
nathanmittler164b7342014-12-15 09:58:05 -0800427}
zpencera62108a2017-09-27 08:31:43 -0700428
429// Run with: ./gradlew japicmp --continue
430def baselineGrpcVersion = '1.6.1'
431def publicApiSubprojects = [
ZHANG Dapeng5ce10f02018-06-11 18:35:18 -0700432 // TODO: uncomment after grpc-alts artifact is published.
433 // ':grpc-alts',
434 ':grpc-auth',
435 ':grpc-context',
436 ':grpc-core',
437 ':grpc-grpclb',
438 ':grpc-netty',
439 ':grpc-okhttp',
440 ':grpc-protobuf',
441 ':grpc-protobuf-lite',
442 ':grpc-protobuf-nano',
443 ':grpc-stub',
444 ':grpc-testing',
zpencera62108a2017-09-27 08:31:43 -0700445]
446
447publicApiSubprojects.each { name ->
448 project(":$name") {
449 apply plugin: 'me.champeau.gradle.japicmp'
450
451 // Get the baseline version's jar for this subproject
452 File baselineArtifact = null
453 // Use a detached configuration, otherwise the current version's jar will take precedence
454 // over the baseline jar.
455 // A necessary hack, the intuitive thing does NOT work:
456 // https://discuss.gradle.org/t/is-the-default-configuration-leaking-into-independent-configurations/2088/6
457 def oldGroup = project.group
458 try {
459 project.group = 'virtual_group_for_japicmp'
460 String depModule = "io.grpc:${project.name}:${baselineGrpcVersion}@jar"
461 String depJar = "${project.name}-${baselineGrpcVersion}.jar"
462 Configuration configuration = configurations.detachedConfiguration(
463 dependencies.create(depModule)
ZHANG Dapeng5ce10f02018-06-11 18:35:18 -0700464 )
zpencera62108a2017-09-27 08:31:43 -0700465 baselineArtifact = files(configuration.files).filter {
466 it.name.equals(depJar)
467 }.singleFile
468 } finally {
469 project.group = oldGroup
470 }
471
472 // Add a japicmp task that compares the current .jar with baseline .jar
473 task japicmp(type: me.champeau.gradle.japicmp.JapicmpTask, dependsOn: jar) {
474 oldClasspath = files(baselineArtifact)
475 newClasspath = files(jar.archivePath)
476 onlyBinaryIncompatibleModified = false
477 // Be quiet about things that did not change
478 onlyModified = true
479 // This task should fail if there are incompatible changes
480 failOnModification = true
481 ignoreMissingClasses = true
482 htmlOutputFile = file("$buildDir/reports/japi.html")
483
484 packageExcludes = ['io.grpc.internal']
485
486 // Also break on source incompatible changes, not just binary.
487 // Eg adding abstract method to public class.
488 // TODO(zpencer): enable after japicmp-gradle-plugin/pull/14
489 // breakOnSourceIncompatibility = true
490
491 // Ignore any classes or methods marked @ExperimentalApi
492 // TODO(zpencer): enable after japicmp-gradle-plugin/pull/15
493 // annotationExcludes = ['@io.grpc.ExperimentalApi']
494 }
495 }
496}
ZHANG Dapeng5ce10f02018-06-11 18:35:18 -0700497
498// format checkers
499apply plugin: "com.diffplug.gradle.spotless"
500apply plugin: 'groovy'
501spotless {
502 groovyGradle {
503 target '**/*.gradle'
504 greclipse()
505 indentWithSpaces()
506 paddedCell()
507 }
508}