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