Kun Zhang | 4bc2d6d | 2015-04-17 10:49:11 -0700 | [diff] [blame] | 1 | buildscript { |
| 2 | repositories { |
| 3 | mavenCentral() |
| 4 | mavenLocal() |
| 5 | } |
| 6 | dependencies { |
| 7 | classpath 'com.google.gradle:osdetector-gradle-plugin:1.2.1' |
| 8 | } |
| 9 | } |
Eric Anderson | b938ba5 | 2015-02-28 09:59:25 -0800 | [diff] [blame] | 10 | |
nathanmittler | 164b734 | 2014-12-15 09:58:05 -0800 | [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" |
Kun Zhang | 4bc2d6d | 2015-04-17 10:49:11 -0700 | [diff] [blame] | 16 | apply plugin: "osdetector" |
Eric Anderson | 192144e | 2015-03-02 13:31:14 -0800 | [diff] [blame] | 17 | apply plugin: "signing" |
Eric Anderson | 041cdb1 | 2015-05-05 12:29:26 -0700 | [diff] [blame] | 18 | apply plugin: "jacoco" |
nathanmittler | 164b734 | 2014-12-15 09:58:05 -0800 | [diff] [blame] | 19 | |
nmittler | f831458 | 2015-01-27 10:25:39 -0800 | [diff] [blame] | 20 | group = "io.grpc" |
nathanmittler | 164b734 | 2014-12-15 09:58:05 -0800 | [diff] [blame] | 21 | version = "0.1.0-SNAPSHOT" |
| 22 | |
| 23 | sourceCompatibility = 1.6 |
| 24 | targetCompatibility = 1.6 |
| 25 | |
| 26 | repositories { |
| 27 | mavenCentral() |
| 28 | mavenLocal() |
| 29 | } |
| 30 | |
Eric Anderson | 76d0955 | 2015-03-12 15:25:11 -0700 | [diff] [blame] | 31 | [compileJava, compileTestJava].each() { |
| 32 | it.options.compilerArgs += ["-Xlint:unchecked", "-Xlint:deprecation", "-Xlint:-options"] |
| 33 | it.options.encoding = "UTF-8" |
nmittler | 02c953e | 2015-01-26 14:03:11 -0800 | [diff] [blame] | 34 | } |
| 35 | |
Eric Anderson | 10fb206 | 2015-05-05 10:28:38 -0700 | [diff] [blame] | 36 | javadoc.options { |
| 37 | encoding = 'UTF-8' |
| 38 | links 'https://docs.oracle.com/javase/8/docs/api/' |
| 39 | } |
Eric Anderson | 14444a9 | 2015-03-11 16:44:38 -0700 | [diff] [blame] | 40 | |
Jakob Buchgraber | 7ddcdfd | 2015-02-13 16:21:53 -0800 | [diff] [blame] | 41 | ext { |
Kun Zhang | 6b1e7d6 | 2015-05-07 15:20:44 -0700 | [diff] [blame] | 42 | def exeSuffix = osdetector.os == 'windows' ? ".exe" : "" |
| 43 | protocPluginBaseName = 'protoc-gen-grpc-java' |
| 44 | javaPluginPath = "$rootDir/compiler/build/binaries/java_pluginExecutable/$protocPluginBaseName$exeSuffix" |
| 45 | |
Kun Zhang | c5b94c7 | 2015-05-06 16:44:55 -0700 | [diff] [blame] | 46 | protobufVersion = '3.0.0-alpha-2' |
Kun Zhang | 6b1e7d6 | 2015-05-07 15:20:44 -0700 | [diff] [blame] | 47 | |
Kun Zhang | 111f6dd | 2015-05-05 16:11:27 -0700 | [diff] [blame] | 48 | 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 Zhang | c5b94c7 | 2015-05-06 16:44:55 -0700 | [diff] [blame] | 54 | project.protocDep = "com.google.protobuf:protoc:${protobufVersion}" |
Kun Zhang | 111f6dd | 2015-05-05 16:11:27 -0700 | [diff] [blame] | 55 | project.generatedFileDir = "${projectDir}/src/generated" |
| 56 | project.afterEvaluate { |
| 57 | generateProto.dependsOn ':grpc-compiler:java_pluginExecutable' |
Kun Zhang | 6b1e7d6 | 2015-05-07 15:20:44 -0700 | [diff] [blame] | 58 | // 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 Zhang | 111f6dd | 2015-05-05 16:11:27 -0700 | [diff] [blame] | 63 | } |
| 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 Buchgraber | 7ddcdfd | 2015-02-13 16:21:53 -0800 | [diff] [blame] | 76 | libraries = [ |
Jakob Buchgraber | 7ddcdfd | 2015-02-13 16:21:53 -0800 | [diff] [blame] | 77 | guava: 'com.google.guava:guava:18.0', |
Jakob Buchgraber | 7ddcdfd | 2015-02-13 16:21:53 -0800 | [diff] [blame] | 78 | // used to collect benchmark results |
| 79 | hdrhistogram: 'org.hdrhistogram:HdrHistogram:2.1.4', |
Jeff Pinner | b1cc7cc | 2015-02-25 10:17:23 -0800 | [diff] [blame] | 80 | hpack: 'com.twitter:hpack:0.10.1', |
nmittler | b897a89 | 2015-02-23 12:03:59 -0800 | [diff] [blame] | 81 | 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 Ryan | 767a12c | 2015-03-02 15:05:09 -0800 | [diff] [blame] | 84 | oauth_client: 'com.google.auth:google-auth-library-oauth2-http:0.1.0', |
nmittler | b897a89 | 2015-02-23 12:03:59 -0800 | [diff] [blame] | 85 | okhttp: 'com.squareup.okhttp:okhttp:2.2.0', |
Kun Zhang | c5b94c7 | 2015-05-06 16:44:55 -0700 | [diff] [blame] | 86 | protobuf: "com.google.protobuf:protobuf-java:${protobufVersion}", |
| 87 | protobuf_nano: "com.google.protobuf.nano:protobuf-javanano:${protobufVersion}", |
Kun Zhang | 41940f7 | 2015-04-28 18:14:34 -0700 | [diff] [blame] | 88 | protobuf_plugin: 'com.google.protobuf:protobuf-gradle-plugin:0.3.1', |
nathanmittler | 164b734 | 2014-12-15 09:58:05 -0800 | [diff] [blame] | 89 | |
Mark Kelly | 589afef | 2015-05-09 10:59:20 +0100 | [diff] [blame^] | 90 | netty: 'io.netty:netty-codec-http2:4.1.0.Beta5', |
nathanmittler | 164b734 | 2014-12-15 09:58:05 -0800 | [diff] [blame] | 91 | |
Jakob Buchgraber | 7ddcdfd | 2015-02-13 16:21:53 -0800 | [diff] [blame] | 92 | // Test dependencies. |
| 93 | junit: 'junit:junit:4.11', |
Eric Anderson | 192144e | 2015-03-02 13:31:14 -0800 | [diff] [blame] | 94 | mockito: 'org.mockito:mockito-core:1.10.19' |
Jakob Buchgraber | 7ddcdfd | 2015-02-13 16:21:53 -0800 | [diff] [blame] | 95 | ] |
| 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 | } |
nathanmittler | 164b734 | 2014-12-15 09:58:05 -0800 | [diff] [blame] | 106 | |
| 107 | dependencies { |
| 108 | testCompile libraries.junit, |
| 109 | libraries.mockito |
| 110 | } |
Eric Anderson | 192144e | 2015-03-02 13:31:14 -0800 | [diff] [blame] | 111 | |
| 112 | signing { |
| 113 | required false |
| 114 | sign configurations.archives |
| 115 | } |
| 116 | |
nmittler | 732cfc0 | 2015-03-03 07:59:13 -0800 | [diff] [blame] | 117 | // 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 Anderson | c3e8dae | 2015-01-30 14:58:07 -0800 | [diff] [blame] | 126 | checkstyle { |
| 127 | configFile = file("$rootDir/checkstyle.xml") |
Xudong Ma | 9aae6f6 | 2015-04-06 21:04:56 +0800 | [diff] [blame] | 128 | toolVersion = "6.5" |
Eric Anderson | ad44f0a | 2015-05-05 08:54:51 -0700 | [diff] [blame] | 129 | ignoreFailures = false |
Eric Anderson | 26141b4 | 2015-03-21 10:59:17 -0700 | [diff] [blame] | 130 | if (rootProject.hasProperty("checkstyle.ignoreFailures")) { |
| 131 | ignoreFailures = rootProject.properties["checkstyle.ignoreFailures"].toBoolean() |
| 132 | } |
Eric Anderson | c3e8dae | 2015-01-30 14:58:07 -0800 | [diff] [blame] | 133 | } |
| 134 | |
| 135 | checkstyleMain { |
Kun Zhang | 693a7d2 | 2015-05-06 11:35:08 -0700 | [diff] [blame] | 136 | source = fileTree(dir: "src/main", include: "**/*.java") |
Eric Anderson | c3e8dae | 2015-01-30 14:58:07 -0800 | [diff] [blame] | 137 | } |
| 138 | |
| 139 | checkstyleTest { |
Kun Zhang | 693a7d2 | 2015-05-06 11:35:08 -0700 | [diff] [blame] | 140 | source = fileTree(dir: "src/test", include: "**/*.java") |
Eric Anderson | c3e8dae | 2015-01-30 14:58:07 -0800 | [diff] [blame] | 141 | } |
| 142 | |
Eric Anderson | 192144e | 2015-03-02 13:31:14 -0800 | [diff] [blame] | 143 | 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) } |
zhangkun83 | da3c3f8 | 2015-03-11 18:03:31 -0700 | [diff] [blame] | 159 | String stagingUrl |
Kun Zhang | 2f74971 | 2015-05-06 13:10:28 -0700 | [diff] [blame] | 160 | if (rootProject.hasProperty('repositoryId')) { |
| 161 | stagingUrl = 'https://oss.sonatype.org/service/local/staging/deployByRepositoryId/' + |
| 162 | rootProject.repositoryId |
zhangkun83 | da3c3f8 | 2015-03-11 18:03:31 -0700 | [diff] [blame] | 163 | } else { |
| 164 | stagingUrl = 'https://oss.sonatype.org/service/local/staging/deploy/maven2/' |
| 165 | } |
Kun Zhang | 2f74971 | 2015-05-06 13:10:28 -0700 | [diff] [blame] | 166 | def configureAuth = { |
| 167 | if (rootProject.hasProperty('ossrhUsername') && rootProject.hasProperty('ossrhPassword')) { |
| 168 | authentication(userName: rootProject.ossrhUsername, password: rootProject.ossrhPassword) |
| 169 | } |
Eric Anderson | 192144e | 2015-03-02 13:31:14 -0800 | [diff] [blame] | 170 | } |
Kun Zhang | 2f74971 | 2015-05-06 13:10:28 -0700 | [diff] [blame] | 171 | repository(url: stagingUrl, configureAuth) |
| 172 | snapshotRepository(url: 'https://oss.sonatype.org/content/repositories/snapshots/', configureAuth) |
Eric Anderson | 192144e | 2015-03-02 13:31:14 -0800 | [diff] [blame] | 173 | } |
| 174 | |
| 175 | [ |
| 176 | install.repositories.mavenInstaller, |
| 177 | uploadArchives.repositories.mavenDeployer, |
| 178 | ]*.pom*.whenConfigured { pom -> |
| 179 | pom.project { |
Eric Anderson | 7e8a02c | 2015-03-12 17:03:01 -0700 | [diff] [blame] | 180 | name "$project.group:$project.name" |
Eric Anderson | 192144e | 2015-03-02 13:31:14 -0800 | [diff] [blame] | 181 | 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 Anderson | 7e8a02c | 2015-03-12 17:03:01 -0700 | [diff] [blame] | 196 | |
| 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 Anderson | 192144e | 2015-03-02 13:31:14 -0800 | [diff] [blame] | 208 | } |
| 209 | } |
Kun Zhang | 3ddd1d5 | 2015-04-22 10:02:19 -0700 | [diff] [blame] | 210 | // 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 | } |
nathanmittler | 164b734 | 2014-12-15 09:58:05 -0800 | [diff] [blame] | 217 | } |