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 | 111f6dd | 2015-05-05 16:11:27 -0700 | [diff] [blame^] | 42 | configureProtoCompilation = { |
| 43 | if (rootProject.childProjects.containsKey('grpc-compiler')) { |
| 44 | // Only when the codegen is built along with the project, will we be able to recompile |
| 45 | // the proto files. |
| 46 | project.apply plugin: 'com.google.protobuf' |
| 47 | project.protobufCodeGenPlugins = ["java_plugin:$javaPluginPath"] |
| 48 | project.generatedFileDir = "${projectDir}/src/generated" |
| 49 | project.afterEvaluate { |
| 50 | generateProto.dependsOn ':grpc-compiler:java_pluginExecutable' |
| 51 | } |
| 52 | } else { |
| 53 | // Otherwise, we just use the checked-in generated code. |
| 54 | project.sourceSets { |
| 55 | main { |
| 56 | java { |
| 57 | srcDir 'src/generated/main' |
| 58 | } |
| 59 | } |
| 60 | } |
| 61 | } |
| 62 | } |
| 63 | |
Jakob Buchgraber | 7ddcdfd | 2015-02-13 16:21:53 -0800 | [diff] [blame] | 64 | libraries = [ |
Jakob Buchgraber | 7ddcdfd | 2015-02-13 16:21:53 -0800 | [diff] [blame] | 65 | guava: 'com.google.guava:guava:18.0', |
Jakob Buchgraber | 7ddcdfd | 2015-02-13 16:21:53 -0800 | [diff] [blame] | 66 | // used to collect benchmark results |
| 67 | hdrhistogram: 'org.hdrhistogram:HdrHistogram:2.1.4', |
Jeff Pinner | b1cc7cc | 2015-02-25 10:17:23 -0800 | [diff] [blame] | 68 | hpack: 'com.twitter:hpack:0.10.1', |
nmittler | b897a89 | 2015-02-23 12:03:59 -0800 | [diff] [blame] | 69 | javaee_api: 'javax:javaee-api:7.0', |
| 70 | jsonp: 'org.glassfish:javax.json:1.0.4', |
| 71 | jsr305: 'com.google.code.findbugs:jsr305:3.0.0', |
Louis Ryan | 767a12c | 2015-03-02 15:05:09 -0800 | [diff] [blame] | 72 | oauth_client: 'com.google.auth:google-auth-library-oauth2-http:0.1.0', |
nmittler | b897a89 | 2015-02-23 12:03:59 -0800 | [diff] [blame] | 73 | okhttp: 'com.squareup.okhttp:okhttp:2.2.0', |
Eric Anderson | a6f5fff | 2015-02-26 07:53:17 -0800 | [diff] [blame] | 74 | protobuf: 'com.google.protobuf:protobuf-java:3.0.0-alpha-2', |
| 75 | protobuf_nano: 'com.google.protobuf.nano:protobuf-javanano:3.0.0-alpha-2', |
Kun Zhang | 41940f7 | 2015-04-28 18:14:34 -0700 | [diff] [blame] | 76 | protobuf_plugin: 'com.google.protobuf:protobuf-gradle-plugin:0.3.1', |
nathanmittler | 164b734 | 2014-12-15 09:58:05 -0800 | [diff] [blame] | 77 | |
Jakob Buchgraber | 7ddcdfd | 2015-02-13 16:21:53 -0800 | [diff] [blame] | 78 | // TODO: Unreleased dependencies. |
| 79 | // These must already be installed in the local maven repository. |
nmittler | 2a42509 | 2015-03-11 12:15:30 -0700 | [diff] [blame] | 80 | netty: 'io.netty:netty-codec-http2:4.1.0.Beta5-SNAPSHOT', |
nathanmittler | 164b734 | 2014-12-15 09:58:05 -0800 | [diff] [blame] | 81 | |
Jakob Buchgraber | 7ddcdfd | 2015-02-13 16:21:53 -0800 | [diff] [blame] | 82 | // Test dependencies. |
| 83 | junit: 'junit:junit:4.11', |
Eric Anderson | 192144e | 2015-03-02 13:31:14 -0800 | [diff] [blame] | 84 | mockito: 'org.mockito:mockito-core:1.10.19' |
Jakob Buchgraber | 7ddcdfd | 2015-02-13 16:21:53 -0800 | [diff] [blame] | 85 | ] |
| 86 | |
| 87 | // Determine the correct version of Jetty ALPN boot to use based |
| 88 | // on the Java version. |
| 89 | def alpnboot_version = '8.1.2.v20141202' |
| 90 | if (JavaVersion.current().ordinal() < JavaVersion.VERSION_1_8.ordinal()) { |
| 91 | alpnboot_version = '7.1.2.v20141202' |
| 92 | } |
| 93 | |
| 94 | alpnboot_package_name = 'org.mortbay.jetty.alpn:alpn-boot:' + alpnboot_version |
Eric Anderson | b938ba5 | 2015-02-28 09:59:25 -0800 | [diff] [blame] | 95 | |
Kun Zhang | 4bc2d6d | 2015-04-17 10:49:11 -0700 | [diff] [blame] | 96 | def exeSuffix = osdetector.os == 'windows' ? ".exe" : "" |
Kun Zhang | 90706dc | 2015-04-09 13:11:31 -0700 | [diff] [blame] | 97 | protocPluginBaseName = 'protoc-gen-grpc-java' |
Kun Zhang | 221c534 | 2015-04-29 18:16:15 -0700 | [diff] [blame] | 98 | javaPluginPath = "$rootDir/compiler/build/binaries/java_pluginExecutable/$protocPluginBaseName$exeSuffix" |
Jakob Buchgraber | 7ddcdfd | 2015-02-13 16:21:53 -0800 | [diff] [blame] | 99 | } |
nathanmittler | 164b734 | 2014-12-15 09:58:05 -0800 | [diff] [blame] | 100 | |
| 101 | dependencies { |
| 102 | testCompile libraries.junit, |
| 103 | libraries.mockito |
| 104 | } |
Eric Anderson | 192144e | 2015-03-02 13:31:14 -0800 | [diff] [blame] | 105 | |
| 106 | signing { |
| 107 | required false |
| 108 | sign configurations.archives |
| 109 | } |
| 110 | |
nmittler | 732cfc0 | 2015-03-03 07:59:13 -0800 | [diff] [blame] | 111 | // Disable JavaDoc doclint on Java 8. It's annoying. |
| 112 | if (JavaVersion.current().isJava8Compatible()) { |
| 113 | allprojects { |
| 114 | tasks.withType(Javadoc) { |
| 115 | options.addStringOption('Xdoclint:none', '-quiet') |
| 116 | } |
| 117 | } |
| 118 | } |
| 119 | |
Eric Anderson | c3e8dae | 2015-01-30 14:58:07 -0800 | [diff] [blame] | 120 | checkstyle { |
| 121 | configFile = file("$rootDir/checkstyle.xml") |
Xudong Ma | 9aae6f6 | 2015-04-06 21:04:56 +0800 | [diff] [blame] | 122 | toolVersion = "6.5" |
Eric Anderson | ad44f0a | 2015-05-05 08:54:51 -0700 | [diff] [blame] | 123 | ignoreFailures = false |
Eric Anderson | 26141b4 | 2015-03-21 10:59:17 -0700 | [diff] [blame] | 124 | if (rootProject.hasProperty("checkstyle.ignoreFailures")) { |
| 125 | ignoreFailures = rootProject.properties["checkstyle.ignoreFailures"].toBoolean() |
| 126 | } |
Eric Anderson | c3e8dae | 2015-01-30 14:58:07 -0800 | [diff] [blame] | 127 | } |
| 128 | |
| 129 | checkstyleMain { |
| 130 | source = fileTree(dir: "src", include: "**/*.java", |
| 131 | excludes: ["${buildDir}/generated-sources", "**/TestServiceGrpc.java"]) |
| 132 | } |
| 133 | |
| 134 | checkstyleTest { |
| 135 | source = fileTree(dir: "test", include: "**/*.java", |
| 136 | exclude: "${buildDir}/generated-sources") |
| 137 | } |
| 138 | |
Eric Anderson | 192144e | 2015-03-02 13:31:14 -0800 | [diff] [blame] | 139 | task javadocJar(type: Jar) { |
| 140 | classifier = 'javadoc' |
| 141 | from javadoc |
| 142 | } |
| 143 | |
| 144 | task sourcesJar(type: Jar) { |
| 145 | classifier = 'sources' |
| 146 | from sourceSets.main.allSource |
| 147 | } |
| 148 | |
| 149 | artifacts { |
| 150 | archives javadocJar, sourcesJar |
| 151 | } |
| 152 | |
| 153 | uploadArchives.repositories.mavenDeployer { |
| 154 | beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } |
zhangkun83 | da3c3f8 | 2015-03-11 18:03:31 -0700 | [diff] [blame] | 155 | String stagingUrl |
| 156 | if (System.getProperty('repositoryId')) { |
| 157 | stagingUrl = 'https://oss.sonatype.org/service/local/staging/deployByRepositoryId/' + System.getProperty('repositoryId') |
| 158 | } else { |
| 159 | stagingUrl = 'https://oss.sonatype.org/service/local/staging/deploy/maven2/' |
| 160 | } |
| 161 | repository(url: stagingUrl) { |
Eric Anderson | 192144e | 2015-03-02 13:31:14 -0800 | [diff] [blame] | 162 | if (rootProject.hasProperty("ossrhUsername") |
| 163 | && rootProject.hasProperty("ossrhPassword")) { |
| 164 | authentication(userName: ossrhUsername, password: ossrhPassword) |
| 165 | } |
| 166 | } |
| 167 | |
| 168 | snapshotRepository(url: "https://oss.sonatype.org/content/repositories/snapshots/") { |
| 169 | if (rootProject.hasProperty("ossrhUsername") |
| 170 | && rootProject.hasProperty("ossrhPassword")) { |
| 171 | authentication(userName: ossrhUsername, password: ossrhPassword) |
| 172 | } |
| 173 | } |
| 174 | } |
| 175 | |
| 176 | [ |
| 177 | install.repositories.mavenInstaller, |
| 178 | uploadArchives.repositories.mavenDeployer, |
| 179 | ]*.pom*.whenConfigured { pom -> |
| 180 | pom.project { |
Eric Anderson | 7e8a02c | 2015-03-12 17:03:01 -0700 | [diff] [blame] | 181 | name "$project.group:$project.name" |
Eric Anderson | 192144e | 2015-03-02 13:31:14 -0800 | [diff] [blame] | 182 | description project.description |
| 183 | url 'https://github.com/grpc/grpc-java' |
| 184 | |
| 185 | scm { |
| 186 | connection 'scm:svn:https://github.com/grpc/grpc-java.git' |
| 187 | developerConnection 'scm:svn:git@github.com:grpc/grpc-java.git' |
| 188 | url 'https://github.com/grpc/grpc-java' |
| 189 | } |
| 190 | |
| 191 | licenses { |
| 192 | license { |
| 193 | name 'BSD 3-Clause' |
| 194 | url 'http://opensource.org/licenses/BSD-3-Clause' |
| 195 | } |
| 196 | } |
Eric Anderson | 7e8a02c | 2015-03-12 17:03:01 -0700 | [diff] [blame] | 197 | |
| 198 | developers { |
| 199 | developer { |
| 200 | id "grpc.io" |
| 201 | name "gRPC Contributors" |
| 202 | email "grpc-io@googlegroups.com" |
| 203 | url "http://grpc.io/" |
| 204 | // https://issues.gradle.org/browse/GRADLE-2719 |
| 205 | organization = "Google, Inc." |
| 206 | organizationUrl "https://www.google.com" |
| 207 | } |
| 208 | } |
Eric Anderson | 192144e | 2015-03-02 13:31:14 -0800 | [diff] [blame] | 209 | } |
| 210 | } |
Kun Zhang | 3ddd1d5 | 2015-04-22 10:02:19 -0700 | [diff] [blame] | 211 | // At a test failure, log the stack trace to the console so that we don't |
| 212 | // have to open the HTML in a browser. |
| 213 | test { |
| 214 | testLogging { |
| 215 | exceptionFormat = 'full' |
| 216 | } |
| 217 | } |
nathanmittler | 164b734 | 2014-12-15 09:58:05 -0800 | [diff] [blame] | 218 | } |