blob: 6fe645f185e64f58cb051d6947ed6f24850b5942 [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 = {
49 if (rootProject.childProjects.containsKey('grpc-compiler')) {
50 // Only when the codegen is built along with the project, will we be able to recompile
51 // the proto files.
52 project.apply plugin: 'com.google.protobuf'
53 project.protobufCodeGenPlugins = ["java_plugin:$javaPluginPath"]
Kun Zhangc5b94c72015-05-06 16:44:55 -070054 project.protocDep = "com.google.protobuf:protoc:${protobufVersion}"
Kun Zhang111f6dd2015-05-05 16:11:27 -070055 project.generatedFileDir = "${projectDir}/src/generated"
56 project.afterEvaluate {
57 generateProto.dependsOn ':grpc-compiler:java_pluginExecutable'
Kun Zhang6b1e7d62015-05-07 15:20:44 -070058 // Recompile protos when the codegen has been changed
59 generateProto.inputs.file javaPluginPath
60 // Recompile protos when build.gradle has been changed, because
61 // it's possible the version of protoc has been changed.
62 generateProto.inputs.file "${rootProject.projectDir}/build.gradle"
Kun Zhang111f6dd2015-05-05 16:11:27 -070063 }
64 } else {
65 // Otherwise, we just use the checked-in generated code.
66 project.sourceSets {
67 main {
68 java {
69 srcDir 'src/generated/main'
70 }
71 }
72 }
73 }
74 }
75
Jakob Buchgraber7ddcdfd2015-02-13 16:21:53 -080076 libraries = [
Jakob Buchgraber7ddcdfd2015-02-13 16:21:53 -080077 guava: 'com.google.guava:guava:18.0',
Jakob Buchgraber7ddcdfd2015-02-13 16:21:53 -080078 // used to collect benchmark results
79 hdrhistogram: 'org.hdrhistogram:HdrHistogram:2.1.4',
Jeff Pinnerb1cc7cc2015-02-25 10:17:23 -080080 hpack: 'com.twitter:hpack:0.10.1',
nmittlerb897a892015-02-23 12:03:59 -080081 javaee_api: 'javax:javaee-api:7.0',
82 jsonp: 'org.glassfish:javax.json:1.0.4',
83 jsr305: 'com.google.code.findbugs:jsr305:3.0.0',
Louis Ryan767a12c2015-03-02 15:05:09 -080084 oauth_client: 'com.google.auth:google-auth-library-oauth2-http:0.1.0',
nmittlerb897a892015-02-23 12:03:59 -080085 okhttp: 'com.squareup.okhttp:okhttp:2.2.0',
Kun Zhangc5b94c72015-05-06 16:44:55 -070086 protobuf: "com.google.protobuf:protobuf-java:${protobufVersion}",
87 protobuf_nano: "com.google.protobuf.nano:protobuf-javanano:${protobufVersion}",
Kun Zhang41940f72015-04-28 18:14:34 -070088 protobuf_plugin: 'com.google.protobuf:protobuf-gradle-plugin:0.3.1',
nathanmittler164b7342014-12-15 09:58:05 -080089
Mark Kelly589afef2015-05-09 10:59:20 +010090 netty: 'io.netty:netty-codec-http2:4.1.0.Beta5',
nathanmittler164b7342014-12-15 09:58:05 -080091
Jakob Buchgraber7ddcdfd2015-02-13 16:21:53 -080092 // Test dependencies.
93 junit: 'junit:junit:4.11',
Eric Anderson192144e2015-03-02 13:31:14 -080094 mockito: 'org.mockito:mockito-core:1.10.19'
Jakob Buchgraber7ddcdfd2015-02-13 16:21:53 -080095 ]
96
97 // Determine the correct version of Jetty ALPN boot to use based
98 // on the Java version.
99 def alpnboot_version = '8.1.2.v20141202'
100 if (JavaVersion.current().ordinal() < JavaVersion.VERSION_1_8.ordinal()) {
101 alpnboot_version = '7.1.2.v20141202'
102 }
103
104 alpnboot_package_name = 'org.mortbay.jetty.alpn:alpn-boot:' + alpnboot_version
105 }
nathanmittler164b7342014-12-15 09:58:05 -0800106
107 dependencies {
108 testCompile libraries.junit,
109 libraries.mockito
110 }
Eric Anderson192144e2015-03-02 13:31:14 -0800111
112 signing {
113 required false
114 sign configurations.archives
115 }
116
nmittler732cfc02015-03-03 07:59:13 -0800117 // Disable JavaDoc doclint on Java 8. It's annoying.
118 if (JavaVersion.current().isJava8Compatible()) {
119 allprojects {
120 tasks.withType(Javadoc) {
121 options.addStringOption('Xdoclint:none', '-quiet')
122 }
123 }
124 }
125
Eric Andersonc3e8dae2015-01-30 14:58:07 -0800126 checkstyle {
127 configFile = file("$rootDir/checkstyle.xml")
Xudong Ma9aae6f62015-04-06 21:04:56 +0800128 toolVersion = "6.5"
Eric Andersonad44f0a2015-05-05 08:54:51 -0700129 ignoreFailures = false
Eric Anderson26141b42015-03-21 10:59:17 -0700130 if (rootProject.hasProperty("checkstyle.ignoreFailures")) {
131 ignoreFailures = rootProject.properties["checkstyle.ignoreFailures"].toBoolean()
132 }
Eric Andersonc3e8dae2015-01-30 14:58:07 -0800133 }
134
135 checkstyleMain {
Kun Zhang693a7d22015-05-06 11:35:08 -0700136 source = fileTree(dir: "src/main", include: "**/*.java")
Eric Andersonc3e8dae2015-01-30 14:58:07 -0800137 }
138
139 checkstyleTest {
Kun Zhang693a7d22015-05-06 11:35:08 -0700140 source = fileTree(dir: "src/test", include: "**/*.java")
Eric Andersonc3e8dae2015-01-30 14:58:07 -0800141 }
142
Eric Anderson192144e2015-03-02 13:31:14 -0800143 task javadocJar(type: Jar) {
144 classifier = 'javadoc'
145 from javadoc
146 }
147
148 task sourcesJar(type: Jar) {
149 classifier = 'sources'
150 from sourceSets.main.allSource
151 }
152
153 artifacts {
154 archives javadocJar, sourcesJar
155 }
156
157 uploadArchives.repositories.mavenDeployer {
158 beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
zhangkun83da3c3f82015-03-11 18:03:31 -0700159 String stagingUrl
Kun Zhang2f749712015-05-06 13:10:28 -0700160 if (rootProject.hasProperty('repositoryId')) {
161 stagingUrl = 'https://oss.sonatype.org/service/local/staging/deployByRepositoryId/' +
162 rootProject.repositoryId
zhangkun83da3c3f82015-03-11 18:03:31 -0700163 } else {
164 stagingUrl = 'https://oss.sonatype.org/service/local/staging/deploy/maven2/'
165 }
Kun Zhang2f749712015-05-06 13:10:28 -0700166 def configureAuth = {
167 if (rootProject.hasProperty('ossrhUsername') && rootProject.hasProperty('ossrhPassword')) {
168 authentication(userName: rootProject.ossrhUsername, password: rootProject.ossrhPassword)
169 }
Eric Anderson192144e2015-03-02 13:31:14 -0800170 }
Kun Zhang2f749712015-05-06 13:10:28 -0700171 repository(url: stagingUrl, configureAuth)
172 snapshotRepository(url: 'https://oss.sonatype.org/content/repositories/snapshots/', configureAuth)
Eric Anderson192144e2015-03-02 13:31:14 -0800173 }
174
175 [
176 install.repositories.mavenInstaller,
177 uploadArchives.repositories.mavenDeployer,
178 ]*.pom*.whenConfigured { pom ->
179 pom.project {
Eric Anderson7e8a02c2015-03-12 17:03:01 -0700180 name "$project.group:$project.name"
Eric Anderson192144e2015-03-02 13:31:14 -0800181 description project.description
182 url 'https://github.com/grpc/grpc-java'
183
184 scm {
185 connection 'scm:svn:https://github.com/grpc/grpc-java.git'
186 developerConnection 'scm:svn:git@github.com:grpc/grpc-java.git'
187 url 'https://github.com/grpc/grpc-java'
188 }
189
190 licenses {
191 license {
192 name 'BSD 3-Clause'
193 url 'http://opensource.org/licenses/BSD-3-Clause'
194 }
195 }
Eric Anderson7e8a02c2015-03-12 17:03:01 -0700196
197 developers {
198 developer {
199 id "grpc.io"
200 name "gRPC Contributors"
201 email "grpc-io@googlegroups.com"
202 url "http://grpc.io/"
203 // https://issues.gradle.org/browse/GRADLE-2719
204 organization = "Google, Inc."
205 organizationUrl "https://www.google.com"
206 }
207 }
Eric Anderson192144e2015-03-02 13:31:14 -0800208 }
209 }
Kun Zhang3ddd1d52015-04-22 10:02:19 -0700210 // At a test failure, log the stack trace to the console so that we don't
211 // have to open the HTML in a browser.
212 test {
213 testLogging {
214 exceptionFormat = 'full'
215 }
216 }
nathanmittler164b7342014-12-15 09:58:05 -0800217}