blob: f3ce21adbc360edd1675d653f581edf2414eaca2 [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',
nmittler8f537e32015-05-12 11:49:37 -0700108 netty_tcnative: "io.netty:netty-tcnative:1.1.33.Fork2:${osdetector.classifier}",
109 netty_transport_native_epoll: "io.netty:netty-transport-native-epoll:4.1.0.Beta5:${osdetector.classifier}",
nathanmittler164b7342014-12-15 09:58:05 -0800110
Jakob Buchgraber7ddcdfd2015-02-13 16:21:53 -0800111 // Test dependencies.
112 junit: 'junit:junit:4.11',
Eric Anderson192144e2015-03-02 13:31:14 -0800113 mockito: 'org.mockito:mockito-core:1.10.19'
Jakob Buchgraber7ddcdfd2015-02-13 16:21:53 -0800114 ]
115
116 // Determine the correct version of Jetty ALPN boot to use based
117 // on the Java version.
118 def alpnboot_version = '8.1.2.v20141202'
119 if (JavaVersion.current().ordinal() < JavaVersion.VERSION_1_8.ordinal()) {
120 alpnboot_version = '7.1.2.v20141202'
121 }
122
123 alpnboot_package_name = 'org.mortbay.jetty.alpn:alpn-boot:' + alpnboot_version
124 }
nathanmittler164b7342014-12-15 09:58:05 -0800125
126 dependencies {
127 testCompile libraries.junit,
128 libraries.mockito
129 }
Eric Anderson192144e2015-03-02 13:31:14 -0800130
131 signing {
132 required false
133 sign configurations.archives
134 }
135
nmittler732cfc02015-03-03 07:59:13 -0800136 // Disable JavaDoc doclint on Java 8. It's annoying.
137 if (JavaVersion.current().isJava8Compatible()) {
138 allprojects {
139 tasks.withType(Javadoc) {
140 options.addStringOption('Xdoclint:none', '-quiet')
141 }
142 }
143 }
144
Eric Andersonc3e8dae2015-01-30 14:58:07 -0800145 checkstyle {
146 configFile = file("$rootDir/checkstyle.xml")
Xudong Ma9aae6f62015-04-06 21:04:56 +0800147 toolVersion = "6.5"
Eric Andersonad44f0a2015-05-05 08:54:51 -0700148 ignoreFailures = false
Eric Anderson26141b42015-03-21 10:59:17 -0700149 if (rootProject.hasProperty("checkstyle.ignoreFailures")) {
150 ignoreFailures = rootProject.properties["checkstyle.ignoreFailures"].toBoolean()
151 }
Eric Andersonc3e8dae2015-01-30 14:58:07 -0800152 }
153
154 checkstyleMain {
Kun Zhang693a7d22015-05-06 11:35:08 -0700155 source = fileTree(dir: "src/main", include: "**/*.java")
Eric Andersonc3e8dae2015-01-30 14:58:07 -0800156 }
157
158 checkstyleTest {
Kun Zhang693a7d22015-05-06 11:35:08 -0700159 source = fileTree(dir: "src/test", include: "**/*.java")
Eric Andersonc3e8dae2015-01-30 14:58:07 -0800160 }
161
Eric Anderson192144e2015-03-02 13:31:14 -0800162 task javadocJar(type: Jar) {
163 classifier = 'javadoc'
164 from javadoc
165 }
166
167 task sourcesJar(type: Jar) {
168 classifier = 'sources'
169 from sourceSets.main.allSource
170 }
171
172 artifacts {
173 archives javadocJar, sourcesJar
174 }
175
176 uploadArchives.repositories.mavenDeployer {
177 beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
zhangkun83da3c3f82015-03-11 18:03:31 -0700178 String stagingUrl
Kun Zhang2f749712015-05-06 13:10:28 -0700179 if (rootProject.hasProperty('repositoryId')) {
180 stagingUrl = 'https://oss.sonatype.org/service/local/staging/deployByRepositoryId/' +
181 rootProject.repositoryId
zhangkun83da3c3f82015-03-11 18:03:31 -0700182 } else {
183 stagingUrl = 'https://oss.sonatype.org/service/local/staging/deploy/maven2/'
184 }
Kun Zhang2f749712015-05-06 13:10:28 -0700185 def configureAuth = {
186 if (rootProject.hasProperty('ossrhUsername') && rootProject.hasProperty('ossrhPassword')) {
187 authentication(userName: rootProject.ossrhUsername, password: rootProject.ossrhPassword)
188 }
Eric Anderson192144e2015-03-02 13:31:14 -0800189 }
Kun Zhang2f749712015-05-06 13:10:28 -0700190 repository(url: stagingUrl, configureAuth)
191 snapshotRepository(url: 'https://oss.sonatype.org/content/repositories/snapshots/', configureAuth)
Eric Anderson192144e2015-03-02 13:31:14 -0800192 }
193
194 [
195 install.repositories.mavenInstaller,
196 uploadArchives.repositories.mavenDeployer,
197 ]*.pom*.whenConfigured { pom ->
198 pom.project {
Eric Anderson7e8a02c2015-03-12 17:03:01 -0700199 name "$project.group:$project.name"
Eric Anderson192144e2015-03-02 13:31:14 -0800200 description project.description
201 url 'https://github.com/grpc/grpc-java'
202
203 scm {
204 connection 'scm:svn:https://github.com/grpc/grpc-java.git'
205 developerConnection 'scm:svn:git@github.com:grpc/grpc-java.git'
206 url 'https://github.com/grpc/grpc-java'
207 }
208
209 licenses {
210 license {
211 name 'BSD 3-Clause'
212 url 'http://opensource.org/licenses/BSD-3-Clause'
213 }
214 }
Eric Anderson7e8a02c2015-03-12 17:03:01 -0700215
216 developers {
217 developer {
218 id "grpc.io"
219 name "gRPC Contributors"
220 email "grpc-io@googlegroups.com"
221 url "http://grpc.io/"
222 // https://issues.gradle.org/browse/GRADLE-2719
223 organization = "Google, Inc."
224 organizationUrl "https://www.google.com"
225 }
226 }
Eric Anderson192144e2015-03-02 13:31:14 -0800227 }
228 }
Kun Zhang3ddd1d52015-04-22 10:02:19 -0700229 // At a test failure, log the stack trace to the console so that we don't
230 // have to open the HTML in a browser.
231 test {
232 testLogging {
233 exceptionFormat = 'full'
234 }
235 }
nathanmittler164b7342014-12-15 09:58:05 -0800236}