Kun Zhang | 4bc2d6d | 2015-04-17 10:49:11 -0700 | [diff] [blame] | 1 | buildscript { |
| 2 | repositories { |
| 3 | mavenCentral() |
| 4 | mavenLocal() |
| 5 | } |
| 6 | dependencies { |
nmittler | c4bcf14 | 2015-09-16 15:15:10 -0700 | [diff] [blame] | 7 | classpath 'com.google.gradle:osdetector-gradle-plugin:1.4.0' |
Kun Zhang | 4bc2d6d | 2015-04-17 10:49:11 -0700 | [diff] [blame] | 8 | } |
| 9 | } |
Eric Anderson | b938ba5 | 2015-02-28 09:59:25 -0800 | [diff] [blame] | 10 | |
Louis Ryan | 540b4d3 | 2015-09-04 13:26:24 -0700 | [diff] [blame] | 11 | subprojects { |
Eric Anderson | c3e8dae | 2015-01-30 14:58:07 -0800 | [diff] [blame] | 12 | apply plugin: "checkstyle" |
nathanmittler | 164b734 | 2014-12-15 09:58:05 -0800 | [diff] [blame] | 13 | apply plugin: "java" |
| 14 | apply plugin: "maven" |
nmittler | 52f4220 | 2015-01-21 14:30:14 -0800 | [diff] [blame] | 15 | apply plugin: "idea" |
Eric Anderson | 192144e | 2015-03-02 13:31:14 -0800 | [diff] [blame] | 16 | apply plugin: "signing" |
Eric Anderson | 041cdb1 | 2015-05-05 12:29:26 -0700 | [diff] [blame] | 17 | apply plugin: "jacoco" |
nathanmittler | 164b734 | 2014-12-15 09:58:05 -0800 | [diff] [blame] | 18 | |
nmittler | c4bcf14 | 2015-09-16 15:15:10 -0700 | [diff] [blame] | 19 | apply plugin: "com.google.osdetector" |
nmittler | c4bcf14 | 2015-09-16 15:15:10 -0700 | [diff] [blame] | 20 | |
nmittler | f831458 | 2015-01-27 10:25:39 -0800 | [diff] [blame] | 21 | group = "io.grpc" |
Eric Anderson | b824565 | 2016-02-17 11:34:50 -0800 | [diff] [blame] | 22 | version = "0.14.0-SNAPSHOT" // CURRENT_GRPC_VERSION |
nathanmittler | 164b734 | 2014-12-15 09:58:05 -0800 | [diff] [blame] | 23 | |
| 24 | sourceCompatibility = 1.6 |
| 25 | targetCompatibility = 1.6 |
| 26 | |
| 27 | repositories { |
| 28 | mavenCentral() |
| 29 | mavenLocal() |
| 30 | } |
| 31 | |
Eric Anderson | 76d0955 | 2015-03-12 15:25:11 -0700 | [diff] [blame] | 32 | [compileJava, compileTestJava].each() { |
Eric Anderson | ec965ca | 2015-06-18 12:40:08 -0700 | [diff] [blame] | 33 | it.options.compilerArgs += ["-Xlint:unchecked", "-Xlint:deprecation", "-Xlint:-options", |
| 34 | "-Xlint:rawtypes"] |
Eric Anderson | 76d0955 | 2015-03-12 15:25:11 -0700 | [diff] [blame] | 35 | it.options.encoding = "UTF-8" |
nmittler | 02c953e | 2015-01-26 14:03:11 -0800 | [diff] [blame] | 36 | } |
| 37 | |
nmittler | 8c1d38a | 2015-06-01 08:31:00 -0700 | [diff] [blame] | 38 | jar.manifest { |
| 39 | attributes('Implementation-Title': name, |
| 40 | 'Implementation-Version': version, |
| 41 | 'Built-By': System.getProperty('user.name'), |
| 42 | 'Built-JDK': System.getProperty('java.version'), |
| 43 | 'Source-Compatibility': sourceCompatibility, |
| 44 | 'Target-Compatibility': targetCompatibility) |
| 45 | } |
| 46 | |
Eric Anderson | 10fb206 | 2015-05-05 10:28:38 -0700 | [diff] [blame] | 47 | javadoc.options { |
| 48 | encoding = 'UTF-8' |
| 49 | links 'https://docs.oracle.com/javase/8/docs/api/' |
| 50 | } |
Eric Anderson | 14444a9 | 2015-03-11 16:44:38 -0700 | [diff] [blame] | 51 | |
Jakob Buchgraber | 7ddcdfd | 2015-02-13 16:21:53 -0800 | [diff] [blame] | 52 | ext { |
Kun Zhang | 6b1e7d6 | 2015-05-07 15:20:44 -0700 | [diff] [blame] | 53 | def exeSuffix = osdetector.os == 'windows' ? ".exe" : "" |
| 54 | protocPluginBaseName = 'protoc-gen-grpc-java' |
Eric Anderson | 46ce409 | 2016-01-26 12:13:06 -0800 | [diff] [blame] | 55 | javaPluginPath = "$rootDir/compiler/build/exe/java_plugin/$protocPluginBaseName$exeSuffix" |
Kun Zhang | 6b1e7d6 | 2015-05-07 15:20:44 -0700 | [diff] [blame] | 56 | |
Kun Zhang | e2ed2e8 | 2016-01-27 08:26:19 -0800 | [diff] [blame] | 57 | protobufVersion = '3.0.0-beta-2' |
| 58 | protobufNanoVersion = '3.0.0-alpha-5' |
Kun Zhang | 6b1e7d6 | 2015-05-07 15:20:44 -0700 | [diff] [blame] | 59 | |
Kun Zhang | 111f6dd | 2015-05-05 16:11:27 -0700 | [diff] [blame] | 60 | configureProtoCompilation = { |
Kun Zhang | 35f77ee | 2015-06-22 16:29:30 -0700 | [diff] [blame] | 61 | String generatedSourcePath = "${projectDir}/src/generated" |
Kun Zhang | 111f6dd | 2015-05-05 16:11:27 -0700 | [diff] [blame] | 62 | if (rootProject.childProjects.containsKey('grpc-compiler')) { |
| 63 | // Only when the codegen is built along with the project, will we be able to recompile |
| 64 | // the proto files. |
| 65 | project.apply plugin: 'com.google.protobuf' |
Kun Zhang | 35f77ee | 2015-06-22 16:29:30 -0700 | [diff] [blame] | 66 | project.protobuf { |
| 67 | protoc { |
| 68 | if (project.hasProperty('protoc')) { |
| 69 | path = project.protoc |
| 70 | } else { |
| 71 | artifact = "com.google.protobuf:protoc:${protobufVersion}" |
| 72 | } |
| 73 | } |
| 74 | plugins { |
| 75 | grpc { |
| 76 | path = javaPluginPath |
| 77 | } |
| 78 | } |
| 79 | generateProtoTasks { |
| 80 | all().each { task -> |
| 81 | task.dependsOn ':grpc-compiler:java_pluginExecutable' |
| 82 | // Delete the generated sources first, so that we can be alerted if they are not re-compiled. |
| 83 | task.dependsOn deleteGeneratedSource |
| 84 | // Recompile protos when the codegen has been changed |
| 85 | task.inputs.file javaPluginPath |
| 86 | // Recompile protos when build.gradle has been changed, because |
| 87 | // it's possible the version of protoc has been changed. |
| 88 | task.inputs.file "${rootProject.projectDir}/build.gradle" |
| 89 | task.plugins { |
| 90 | grpc {} |
Kun Zhang | 2cdc5e3 | 2015-05-11 16:58:28 -0700 | [diff] [blame] | 91 | } |
| 92 | } |
| 93 | } |
Kun Zhang | 35f77ee | 2015-06-22 16:29:30 -0700 | [diff] [blame] | 94 | generatedFilesBaseDir = generatedSourcePath |
| 95 | } |
| 96 | |
| 97 | task deleteGeneratedSource << { |
| 98 | project.delete project.fileTree(dir: generatedSourcePath) |
Kun Zhang | 2cdc5e3 | 2015-05-11 16:58:28 -0700 | [diff] [blame] | 99 | } |
Kun Zhang | 111f6dd | 2015-05-05 16:11:27 -0700 | [diff] [blame] | 100 | } else { |
| 101 | // Otherwise, we just use the checked-in generated code. |
| 102 | project.sourceSets { |
| 103 | main { |
| 104 | java { |
Kun Zhang | 35f77ee | 2015-06-22 16:29:30 -0700 | [diff] [blame] | 105 | srcDir "${generatedSourcePath}/main/java" |
Eric Anderson | cea8e8e | 2015-10-27 19:53:18 -0700 | [diff] [blame] | 106 | srcDir "${generatedSourcePath}/main/javanano" |
Kun Zhang | 35f77ee | 2015-06-22 16:29:30 -0700 | [diff] [blame] | 107 | srcDir "${generatedSourcePath}/main/grpc" |
Kun Zhang | 287a27a | 2015-05-07 17:32:31 -0700 | [diff] [blame] | 108 | } |
Kun Zhang | 111f6dd | 2015-05-05 16:11:27 -0700 | [diff] [blame] | 109 | } |
Eric Anderson | cea8e8e | 2015-10-27 19:53:18 -0700 | [diff] [blame] | 110 | test { |
| 111 | java { |
| 112 | srcDir "${generatedSourcePath}/test/java" |
| 113 | srcDir "${generatedSourcePath}/test/javanano" |
| 114 | srcDir "${generatedSourcePath}/test/grpc" |
| 115 | } |
| 116 | } |
Kun Zhang | 111f6dd | 2015-05-05 16:11:27 -0700 | [diff] [blame] | 117 | } |
| 118 | } |
| 119 | } |
| 120 | |
Eric Anderson | 65d73c0 | 2015-05-21 11:54:04 -0700 | [diff] [blame] | 121 | def epoll_suffix = ""; |
| 122 | if (osdetector.classifier in ["linux-x86_64"]) { |
| 123 | // The native code is only pre-compiled on certain platforms. |
| 124 | epoll_suffix = ":" + osdetector.classifier |
| 125 | } |
Jakob Buchgraber | 7ddcdfd | 2015-02-13 16:21:53 -0800 | [diff] [blame] | 126 | libraries = [ |
Carl Mastrangelo | a959126 | 2016-02-23 15:51:20 -0800 | [diff] [blame] | 127 | guava: 'com.google.guava:guava:19.0', |
Jakob Buchgraber | 7ddcdfd | 2015-02-13 16:21:53 -0800 | [diff] [blame] | 128 | // used to collect benchmark results |
| 129 | hdrhistogram: 'org.hdrhistogram:HdrHistogram:2.1.4', |
Jeff Pinner | b1cc7cc | 2015-02-25 10:17:23 -0800 | [diff] [blame] | 130 | hpack: 'com.twitter:hpack:0.10.1', |
nmittler | b897a89 | 2015-02-23 12:03:59 -0800 | [diff] [blame] | 131 | jsr305: 'com.google.code.findbugs:jsr305:3.0.0', |
Eric Anderson | d52a7a2 | 2015-09-03 16:44:48 -0700 | [diff] [blame] | 132 | oauth_client: 'com.google.auth:google-auth-library-oauth2-http:0.3.0', |
Xudong Ma | 6d296e8 | 2015-09-21 10:39:00 -0700 | [diff] [blame] | 133 | okhttp: 'com.squareup.okhttp:okhttp:2.5.0', |
Xudong Ma | b121c46 | 2015-09-21 12:54:06 -0700 | [diff] [blame] | 134 | okio: 'com.squareup.okio:okio:1.6.0', |
Kun Zhang | c5b94c7 | 2015-05-06 16:44:55 -0700 | [diff] [blame] | 135 | protobuf: "com.google.protobuf:protobuf-java:${protobufVersion}", |
Kun Zhang | bd23a8d | 2015-08-28 18:47:06 -0700 | [diff] [blame] | 136 | protobuf_nano: "com.google.protobuf.nano:protobuf-javanano:${protobufNanoVersion}", |
Kun Zhang | d3d253e | 2016-01-26 15:31:53 -0800 | [diff] [blame] | 137 | protobuf_plugin: 'com.google.protobuf:protobuf-gradle-plugin:0.7.4', |
Carl Mastrangelo | 8e1fba7 | 2016-03-02 09:30:35 -0800 | [diff] [blame] | 138 | protobuf_util: "com.google.protobuf:protobuf-java-util:${protobufVersion}", |
nathanmittler | 164b734 | 2014-12-15 09:58:05 -0800 | [diff] [blame] | 139 | |
buchgr | c9de5d8 | 2016-04-04 20:37:39 +0200 | [diff] [blame] | 140 | netty: 'io.netty:netty-codec-http2:4.1.0.CR6', |
| 141 | netty_epoll: 'io.netty:netty-transport-native-epoll:4.1.0.CR6' + epoll_suffix, |
buchgr | 88d3174 | 2016-03-23 22:58:23 +0100 | [diff] [blame] | 142 | netty_tcnative: 'io.netty:netty-tcnative-boringssl-static:1.1.33.Fork15:' + osdetector.classifier, |
nathanmittler | 164b734 | 2014-12-15 09:58:05 -0800 | [diff] [blame] | 143 | |
Jakob Buchgraber | 7ddcdfd | 2015-02-13 16:21:53 -0800 | [diff] [blame] | 144 | // Test dependencies. |
| 145 | junit: 'junit:junit:4.11', |
Carl Mastrangelo | b3bc7fc | 2016-04-01 15:18:23 -0700 | [diff] [blame] | 146 | mockito: 'org.mockito:mockito-core:1.9.5', |
| 147 | truth: 'com.google.truth:truth:0.28' |
Jakob Buchgraber | 7ddcdfd | 2015-02-13 16:21:53 -0800 | [diff] [blame] | 148 | ] |
| 149 | |
| 150 | // Determine the correct version of Jetty ALPN boot to use based |
| 151 | // on the Java version. |
| 152 | def alpnboot_version = '8.1.2.v20141202' |
| 153 | if (JavaVersion.current().ordinal() < JavaVersion.VERSION_1_8.ordinal()) { |
nmittler | 247ffb1 | 2015-07-24 11:19:34 -0700 | [diff] [blame] | 154 | alpnboot_version = '7.1.3.v20150130' |
Jakob Buchgraber | 7ddcdfd | 2015-02-13 16:21:53 -0800 | [diff] [blame] | 155 | } |
| 156 | |
| 157 | alpnboot_package_name = 'org.mortbay.jetty.alpn:alpn-boot:' + alpnboot_version |
| 158 | } |
nathanmittler | 164b734 | 2014-12-15 09:58:05 -0800 | [diff] [blame] | 159 | |
nmittler | 74cfe6c | 2015-05-22 12:25:10 -0700 | [diff] [blame] | 160 | // Define a separate configuration for managing the dependency on Jetty alpnboot jar. |
| 161 | configurations { |
| 162 | alpnboot |
nmittler | 9466eb5 | 2015-09-04 15:13:46 -0700 | [diff] [blame] | 163 | tcnative |
nmittler | 74cfe6c | 2015-05-22 12:25:10 -0700 | [diff] [blame] | 164 | } |
| 165 | |
nathanmittler | 164b734 | 2014-12-15 09:58:05 -0800 | [diff] [blame] | 166 | dependencies { |
| 167 | testCompile libraries.junit, |
| 168 | libraries.mockito |
nmittler | 74cfe6c | 2015-05-22 12:25:10 -0700 | [diff] [blame] | 169 | |
nmittler | 9466eb5 | 2015-09-04 15:13:46 -0700 | [diff] [blame] | 170 | // Configuration for modules that use Jetty ALPN |
nmittler | 74cfe6c | 2015-05-22 12:25:10 -0700 | [diff] [blame] | 171 | alpnboot alpnboot_package_name |
nmittler | 9466eb5 | 2015-09-04 15:13:46 -0700 | [diff] [blame] | 172 | |
| 173 | // Configuration for modules that use Netty tcnative (for OpenSSL). |
| 174 | tcnative libraries.netty_tcnative |
nathanmittler | 164b734 | 2014-12-15 09:58:05 -0800 | [diff] [blame] | 175 | } |
Eric Anderson | 192144e | 2015-03-02 13:31:14 -0800 | [diff] [blame] | 176 | |
| 177 | signing { |
| 178 | required false |
| 179 | sign configurations.archives |
| 180 | } |
| 181 | |
nmittler | 732cfc0 | 2015-03-03 07:59:13 -0800 | [diff] [blame] | 182 | // Disable JavaDoc doclint on Java 8. It's annoying. |
| 183 | if (JavaVersion.current().isJava8Compatible()) { |
| 184 | allprojects { |
| 185 | tasks.withType(Javadoc) { |
| 186 | options.addStringOption('Xdoclint:none', '-quiet') |
| 187 | } |
| 188 | } |
| 189 | } |
| 190 | |
Eric Anderson | c3e8dae | 2015-01-30 14:58:07 -0800 | [diff] [blame] | 191 | checkstyle { |
| 192 | configFile = file("$rootDir/checkstyle.xml") |
Xudong Ma | 9aae6f6 | 2015-04-06 21:04:56 +0800 | [diff] [blame] | 193 | toolVersion = "6.5" |
Eric Anderson | ad44f0a | 2015-05-05 08:54:51 -0700 | [diff] [blame] | 194 | ignoreFailures = false |
Eric Anderson | 26141b4 | 2015-03-21 10:59:17 -0700 | [diff] [blame] | 195 | if (rootProject.hasProperty("checkstyle.ignoreFailures")) { |
| 196 | ignoreFailures = rootProject.properties["checkstyle.ignoreFailures"].toBoolean() |
| 197 | } |
Eric Anderson | efa774b | 2015-09-15 10:34:14 -0700 | [diff] [blame] | 198 | configProperties["rootDir"] = rootDir |
Eric Anderson | c3e8dae | 2015-01-30 14:58:07 -0800 | [diff] [blame] | 199 | } |
| 200 | |
| 201 | checkstyleMain { |
Kun Zhang | 693a7d2 | 2015-05-06 11:35:08 -0700 | [diff] [blame] | 202 | source = fileTree(dir: "src/main", include: "**/*.java") |
Eric Anderson | c3e8dae | 2015-01-30 14:58:07 -0800 | [diff] [blame] | 203 | } |
| 204 | |
| 205 | checkstyleTest { |
Kun Zhang | 693a7d2 | 2015-05-06 11:35:08 -0700 | [diff] [blame] | 206 | source = fileTree(dir: "src/test", include: "**/*.java") |
Eric Anderson | c3e8dae | 2015-01-30 14:58:07 -0800 | [diff] [blame] | 207 | } |
| 208 | |
Eric Anderson | 192144e | 2015-03-02 13:31:14 -0800 | [diff] [blame] | 209 | task javadocJar(type: Jar) { |
| 210 | classifier = 'javadoc' |
| 211 | from javadoc |
| 212 | } |
| 213 | |
| 214 | task sourcesJar(type: Jar) { |
| 215 | classifier = 'sources' |
| 216 | from sourceSets.main.allSource |
| 217 | } |
| 218 | |
| 219 | artifacts { |
| 220 | archives javadocJar, sourcesJar |
| 221 | } |
| 222 | |
| 223 | uploadArchives.repositories.mavenDeployer { |
| 224 | beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } |
zhangkun83 | da3c3f8 | 2015-03-11 18:03:31 -0700 | [diff] [blame] | 225 | String stagingUrl |
Kun Zhang | 2f74971 | 2015-05-06 13:10:28 -0700 | [diff] [blame] | 226 | if (rootProject.hasProperty('repositoryId')) { |
| 227 | stagingUrl = 'https://oss.sonatype.org/service/local/staging/deployByRepositoryId/' + |
| 228 | rootProject.repositoryId |
zhangkun83 | da3c3f8 | 2015-03-11 18:03:31 -0700 | [diff] [blame] | 229 | } else { |
| 230 | stagingUrl = 'https://oss.sonatype.org/service/local/staging/deploy/maven2/' |
| 231 | } |
Kun Zhang | 2f74971 | 2015-05-06 13:10:28 -0700 | [diff] [blame] | 232 | def configureAuth = { |
| 233 | if (rootProject.hasProperty('ossrhUsername') && rootProject.hasProperty('ossrhPassword')) { |
| 234 | authentication(userName: rootProject.ossrhUsername, password: rootProject.ossrhPassword) |
| 235 | } |
Eric Anderson | 192144e | 2015-03-02 13:31:14 -0800 | [diff] [blame] | 236 | } |
Kun Zhang | 2f74971 | 2015-05-06 13:10:28 -0700 | [diff] [blame] | 237 | repository(url: stagingUrl, configureAuth) |
| 238 | snapshotRepository(url: 'https://oss.sonatype.org/content/repositories/snapshots/', configureAuth) |
Eric Anderson | 192144e | 2015-03-02 13:31:14 -0800 | [diff] [blame] | 239 | } |
| 240 | |
| 241 | [ |
| 242 | install.repositories.mavenInstaller, |
| 243 | uploadArchives.repositories.mavenDeployer, |
| 244 | ]*.pom*.whenConfigured { pom -> |
| 245 | pom.project { |
Eric Anderson | 7e8a02c | 2015-03-12 17:03:01 -0700 | [diff] [blame] | 246 | name "$project.group:$project.name" |
Eric Anderson | 192144e | 2015-03-02 13:31:14 -0800 | [diff] [blame] | 247 | description project.description |
| 248 | url 'https://github.com/grpc/grpc-java' |
| 249 | |
| 250 | scm { |
Eric Anderson | b735495 | 2016-04-08 08:37:07 -0700 | [diff] [blame^] | 251 | connection 'scm:git:https://github.com/grpc/grpc-java.git' |
| 252 | developerConnection 'scm:git:git@github.com:grpc/grpc-java.git' |
Eric Anderson | 192144e | 2015-03-02 13:31:14 -0800 | [diff] [blame] | 253 | url 'https://github.com/grpc/grpc-java' |
| 254 | } |
| 255 | |
| 256 | licenses { |
| 257 | license { |
| 258 | name 'BSD 3-Clause' |
| 259 | url 'http://opensource.org/licenses/BSD-3-Clause' |
| 260 | } |
| 261 | } |
Eric Anderson | 7e8a02c | 2015-03-12 17:03:01 -0700 | [diff] [blame] | 262 | |
| 263 | developers { |
| 264 | developer { |
| 265 | id "grpc.io" |
| 266 | name "gRPC Contributors" |
| 267 | email "grpc-io@googlegroups.com" |
| 268 | url "http://grpc.io/" |
| 269 | // https://issues.gradle.org/browse/GRADLE-2719 |
| 270 | organization = "Google, Inc." |
| 271 | organizationUrl "https://www.google.com" |
| 272 | } |
| 273 | } |
Eric Anderson | 192144e | 2015-03-02 13:31:14 -0800 | [diff] [blame] | 274 | } |
| 275 | } |
Kun Zhang | 3ddd1d5 | 2015-04-22 10:02:19 -0700 | [diff] [blame] | 276 | // At a test failure, log the stack trace to the console so that we don't |
| 277 | // have to open the HTML in a browser. |
| 278 | test { |
| 279 | testLogging { |
| 280 | exceptionFormat = 'full' |
nmittler | 4ee2a65 | 2015-06-01 16:20:08 -0700 | [diff] [blame] | 281 | showExceptions true |
| 282 | showCauses true |
| 283 | showStackTraces true |
Kun Zhang | 3ddd1d5 | 2015-04-22 10:02:19 -0700 | [diff] [blame] | 284 | } |
Eric Anderson | 56dca03 | 2016-02-12 08:48:41 -0800 | [diff] [blame] | 285 | maxHeapSize = '1500m' |
Kun Zhang | 3ddd1d5 | 2015-04-22 10:02:19 -0700 | [diff] [blame] | 286 | } |
nathanmittler | 164b734 | 2014-12-15 09:58:05 -0800 | [diff] [blame] | 287 | } |