blob: 24f647890a524203147540eb7d160dd9eb2f7e5e [file] [log] [blame]
Kun Zhang4bc2d6d2015-04-17 10:49:11 -07001buildscript {
2 repositories {
3 mavenCentral()
4 mavenLocal()
5 }
6 dependencies {
7 classpath 'com.google.gradle:osdetector-gradle-plugin:1.2.1'
8 }
9}
Eric Andersonb938ba52015-02-28 09:59:25 -080010
nathanmittler164b7342014-12-15 09:58:05 -080011subprojects {
Eric Andersonc3e8dae2015-01-30 14:58:07 -080012 apply plugin: "checkstyle"
nathanmittler164b7342014-12-15 09:58:05 -080013 apply plugin: "java"
14 apply plugin: "maven"
nmittler52f42202015-01-21 14:30:14 -080015 apply plugin: "idea"
Kun Zhang4bc2d6d2015-04-17 10:49:11 -070016 apply plugin: "osdetector"
Eric Anderson192144e2015-03-02 13:31:14 -080017 apply plugin: "signing"
Eric Anderson041cdb12015-05-05 12:29:26 -070018 apply plugin: "jacoco"
nathanmittler164b7342014-12-15 09:58:05 -080019
nmittlerf8314582015-01-27 10:25:39 -080020 group = "io.grpc"
nathanmittler164b7342014-12-15 09:58:05 -080021 version = "0.1.0-SNAPSHOT"
22
23 sourceCompatibility = 1.6
24 targetCompatibility = 1.6
25
26 repositories {
27 mavenCentral()
28 mavenLocal()
29 }
30
Eric Anderson76d09552015-03-12 15:25:11 -070031 [compileJava, compileTestJava].each() {
32 it.options.compilerArgs += ["-Xlint:unchecked", "-Xlint:deprecation", "-Xlint:-options"]
33 it.options.encoding = "UTF-8"
nmittler02c953e2015-01-26 14:03:11 -080034 }
35
Eric Anderson10fb2062015-05-05 10:28:38 -070036 javadoc.options {
37 encoding = 'UTF-8'
38 links 'https://docs.oracle.com/javase/8/docs/api/'
39 }
Eric Anderson14444a92015-03-11 16:44:38 -070040
Jakob Buchgraber7ddcdfd2015-02-13 16:21:53 -080041 ext {
Kun Zhang6b1e7d62015-05-07 15:20:44 -070042 def exeSuffix = osdetector.os == 'windows' ? ".exe" : ""
43 protocPluginBaseName = 'protoc-gen-grpc-java'
44 javaPluginPath = "$rootDir/compiler/build/binaries/java_pluginExecutable/$protocPluginBaseName$exeSuffix"
45
Kun Zhangc5b94c72015-05-06 16:44:55 -070046 protobufVersion = '3.0.0-alpha-2'
Kun Zhang6b1e7d62015-05-07 15:20:44 -070047
Kun Zhang111f6dd2015-05-05 16:11:27 -070048 configureProtoCompilation = {
Kun Zhang2cdc5e32015-05-11 16:58:28 -070049 String generatedSourcePath = 'src/generated'
Kun Zhang111f6dd2015-05-05 16:11:27 -070050 if (rootProject.childProjects.containsKey('grpc-compiler')) {
51 // Only when the codegen is built along with the project, will we be able to recompile
52 // the proto files.
53 project.apply plugin: 'com.google.protobuf'
Kun Zhang287a27a2015-05-07 17:32:31 -070054 project.protobufCodeGenPlugins = ["grpc:$javaPluginPath"]
Kun Zhang9805e272015-05-12 17:03:19 -070055 if (project.hasProperty('protoc')) {
56 project.protocPath = project.protoc
57 } else {
58 project.protocDep = "com.google.protobuf:protoc:${protobufVersion}"
59 }
Kun Zhang111f6dd2015-05-05 16:11:27 -070060 project.generatedFileDir = "${projectDir}/src/generated"
61 project.afterEvaluate {
62 generateProto.dependsOn ':grpc-compiler:java_pluginExecutable'
Kun Zhang6b1e7d62015-05-07 15:20:44 -070063 // Recompile protos when the codegen has been changed
64 generateProto.inputs.file javaPluginPath
65 // Recompile protos when build.gradle has been changed, because
66 // it's possible the version of protoc has been changed.
67 generateProto.inputs.file "${rootProject.projectDir}/build.gradle"
Kun Zhang111f6dd2015-05-05 16:11:27 -070068 }
Kun Zhang2cdc5e32015-05-11 16:58:28 -070069 // Delete the generated sources first, so that we can be alerted if they are not re-compiled.
70 project.delete project.fileTree(dir: generatedSourcePath)
71
72 project.sourceSets {
73 main {
74 proto {
75 plugins {
76 grpc { }
77 }
78 }
79 }
80 }
Kun Zhang111f6dd2015-05-05 16:11:27 -070081 } else {
82 // Otherwise, we just use the checked-in generated code.
83 project.sourceSets {
84 main {
85 java {
Kun Zhang2cdc5e32015-05-11 16:58:28 -070086 srcDir "${generatedSourcePath}/main"
Kun Zhang287a27a2015-05-07 17:32:31 -070087 }
Kun Zhang111f6dd2015-05-05 16:11:27 -070088 }
89 }
90 }
91 }
92
Jakob Buchgraber7ddcdfd2015-02-13 16:21:53 -080093 libraries = [
Jakob Buchgraber7ddcdfd2015-02-13 16:21:53 -080094 guava: 'com.google.guava:guava:18.0',
Jakob Buchgraber7ddcdfd2015-02-13 16:21:53 -080095 // used to collect benchmark results
96 hdrhistogram: 'org.hdrhistogram:HdrHistogram:2.1.4',
Jeff Pinnerb1cc7cc2015-02-25 10:17:23 -080097 hpack: 'com.twitter:hpack:0.10.1',
nmittlerb897a892015-02-23 12:03:59 -080098 javaee_api: 'javax:javaee-api:7.0',
99 jsonp: 'org.glassfish:javax.json:1.0.4',
100 jsr305: 'com.google.code.findbugs:jsr305:3.0.0',
Louis Ryan767a12c2015-03-02 15:05:09 -0800101 oauth_client: 'com.google.auth:google-auth-library-oauth2-http:0.1.0',
nmittlerb897a892015-02-23 12:03:59 -0800102 okhttp: 'com.squareup.okhttp:okhttp:2.2.0',
Kun Zhangc5b94c72015-05-06 16:44:55 -0700103 protobuf: "com.google.protobuf:protobuf-java:${protobufVersion}",
104 protobuf_nano: "com.google.protobuf.nano:protobuf-javanano:${protobufVersion}",
Kun Zhang9805e272015-05-12 17:03:19 -0700105 protobuf_plugin: 'com.google.protobuf:protobuf-gradle-plugin:0.4.1',
nathanmittler164b7342014-12-15 09:58:05 -0800106
Mark Kelly589afef2015-05-09 10:59:20 +0100107 netty: 'io.netty:netty-codec-http2:4.1.0.Beta5',
nathanmittler164b7342014-12-15 09:58:05 -0800108
Jakob Buchgraber7ddcdfd2015-02-13 16:21:53 -0800109 // Test dependencies.
110 junit: 'junit:junit:4.11',
Eric Anderson192144e2015-03-02 13:31:14 -0800111 mockito: 'org.mockito:mockito-core:1.10.19'
Jakob Buchgraber7ddcdfd2015-02-13 16:21:53 -0800112 ]
113
114 // Determine the correct version of Jetty ALPN boot to use based
115 // on the Java version.
116 def alpnboot_version = '8.1.2.v20141202'
117 if (JavaVersion.current().ordinal() < JavaVersion.VERSION_1_8.ordinal()) {
118 alpnboot_version = '7.1.2.v20141202'
119 }
120
121 alpnboot_package_name = 'org.mortbay.jetty.alpn:alpn-boot:' + alpnboot_version
122 }
nathanmittler164b7342014-12-15 09:58:05 -0800123
124 dependencies {
125 testCompile libraries.junit,
126 libraries.mockito
127 }
Eric Anderson192144e2015-03-02 13:31:14 -0800128
129 signing {
130 required false
131 sign configurations.archives
132 }
133
nmittler732cfc02015-03-03 07:59:13 -0800134 // Disable JavaDoc doclint on Java 8. It's annoying.
135 if (JavaVersion.current().isJava8Compatible()) {
136 allprojects {
137 tasks.withType(Javadoc) {
138 options.addStringOption('Xdoclint:none', '-quiet')
139 }
140 }
141 }
142
Eric Andersonc3e8dae2015-01-30 14:58:07 -0800143 checkstyle {
144 configFile = file("$rootDir/checkstyle.xml")
Xudong Ma9aae6f62015-04-06 21:04:56 +0800145 toolVersion = "6.5"
Eric Andersonad44f0a2015-05-05 08:54:51 -0700146 ignoreFailures = false
Eric Anderson26141b42015-03-21 10:59:17 -0700147 if (rootProject.hasProperty("checkstyle.ignoreFailures")) {
148 ignoreFailures = rootProject.properties["checkstyle.ignoreFailures"].toBoolean()
149 }
Eric Andersonc3e8dae2015-01-30 14:58:07 -0800150 }
151
152 checkstyleMain {
Kun Zhang693a7d22015-05-06 11:35:08 -0700153 source = fileTree(dir: "src/main", include: "**/*.java")
Eric Andersonc3e8dae2015-01-30 14:58:07 -0800154 }
155
156 checkstyleTest {
Kun Zhang693a7d22015-05-06 11:35:08 -0700157 source = fileTree(dir: "src/test", include: "**/*.java")
Eric Andersonc3e8dae2015-01-30 14:58:07 -0800158 }
159
Eric Anderson192144e2015-03-02 13:31:14 -0800160 task javadocJar(type: Jar) {
161 classifier = 'javadoc'
162 from javadoc
163 }
164
165 task sourcesJar(type: Jar) {
166 classifier = 'sources'
167 from sourceSets.main.allSource
168 }
169
170 artifacts {
171 archives javadocJar, sourcesJar
172 }
173
174 uploadArchives.repositories.mavenDeployer {
175 beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
zhangkun83da3c3f82015-03-11 18:03:31 -0700176 String stagingUrl
Kun Zhang2f749712015-05-06 13:10:28 -0700177 if (rootProject.hasProperty('repositoryId')) {
178 stagingUrl = 'https://oss.sonatype.org/service/local/staging/deployByRepositoryId/' +
179 rootProject.repositoryId
zhangkun83da3c3f82015-03-11 18:03:31 -0700180 } else {
181 stagingUrl = 'https://oss.sonatype.org/service/local/staging/deploy/maven2/'
182 }
Kun Zhang2f749712015-05-06 13:10:28 -0700183 def configureAuth = {
184 if (rootProject.hasProperty('ossrhUsername') && rootProject.hasProperty('ossrhPassword')) {
185 authentication(userName: rootProject.ossrhUsername, password: rootProject.ossrhPassword)
186 }
Eric Anderson192144e2015-03-02 13:31:14 -0800187 }
Kun Zhang2f749712015-05-06 13:10:28 -0700188 repository(url: stagingUrl, configureAuth)
189 snapshotRepository(url: 'https://oss.sonatype.org/content/repositories/snapshots/', configureAuth)
Eric Anderson192144e2015-03-02 13:31:14 -0800190 }
191
192 [
193 install.repositories.mavenInstaller,
194 uploadArchives.repositories.mavenDeployer,
195 ]*.pom*.whenConfigured { pom ->
196 pom.project {
Eric Anderson7e8a02c2015-03-12 17:03:01 -0700197 name "$project.group:$project.name"
Eric Anderson192144e2015-03-02 13:31:14 -0800198 description project.description
199 url 'https://github.com/grpc/grpc-java'
200
201 scm {
202 connection 'scm:svn:https://github.com/grpc/grpc-java.git'
203 developerConnection 'scm:svn:git@github.com:grpc/grpc-java.git'
204 url 'https://github.com/grpc/grpc-java'
205 }
206
207 licenses {
208 license {
209 name 'BSD 3-Clause'
210 url 'http://opensource.org/licenses/BSD-3-Clause'
211 }
212 }
Eric Anderson7e8a02c2015-03-12 17:03:01 -0700213
214 developers {
215 developer {
216 id "grpc.io"
217 name "gRPC Contributors"
218 email "grpc-io@googlegroups.com"
219 url "http://grpc.io/"
220 // https://issues.gradle.org/browse/GRADLE-2719
221 organization = "Google, Inc."
222 organizationUrl "https://www.google.com"
223 }
224 }
Eric Anderson192144e2015-03-02 13:31:14 -0800225 }
226 }
Kun Zhang3ddd1d52015-04-22 10:02:19 -0700227 // At a test failure, log the stack trace to the console so that we don't
228 // have to open the HTML in a browser.
229 test {
230 testLogging {
231 exceptionFormat = 'full'
232 }
233 }
nathanmittler164b7342014-12-15 09:58:05 -0800234}