2015-04-18 01:49:11 +08:00
|
|
|
buildscript {
|
|
|
|
repositories {
|
|
|
|
mavenCentral()
|
|
|
|
mavenLocal()
|
|
|
|
}
|
|
|
|
dependencies {
|
2015-09-17 06:15:10 +08:00
|
|
|
classpath 'com.google.gradle:osdetector-gradle-plugin:1.4.0'
|
2017-02-03 05:48:12 +08:00
|
|
|
classpath "ru.vyarus:gradle-animalsniffer-plugin:1.2.0"
|
2015-04-18 01:49:11 +08:00
|
|
|
}
|
|
|
|
}
|
2015-03-01 01:59:25 +08:00
|
|
|
|
2015-09-05 04:26:24 +08:00
|
|
|
subprojects {
|
2015-01-31 06:58:07 +08:00
|
|
|
apply plugin: "checkstyle"
|
2014-12-16 01:58:05 +08:00
|
|
|
apply plugin: "java"
|
|
|
|
apply plugin: "maven"
|
2015-01-22 06:30:14 +08:00
|
|
|
apply plugin: "idea"
|
2015-03-03 05:31:14 +08:00
|
|
|
apply plugin: "signing"
|
2015-05-06 03:29:26 +08:00
|
|
|
apply plugin: "jacoco"
|
2014-12-16 01:58:05 +08:00
|
|
|
|
2015-09-17 06:15:10 +08:00
|
|
|
apply plugin: "com.google.osdetector"
|
2017-02-03 05:48:12 +08:00
|
|
|
// The plugin only has an effect if a signature is specified
|
|
|
|
apply plugin: "ru.vyarus.animalsniffer"
|
2015-09-17 06:15:10 +08:00
|
|
|
|
2015-01-28 02:25:39 +08:00
|
|
|
group = "io.grpc"
|
2017-01-31 08:40:12 +08:00
|
|
|
version = "1.2.0-SNAPSHOT" // CURRENT_GRPC_VERSION
|
2014-12-16 01:58:05 +08:00
|
|
|
|
|
|
|
sourceCompatibility = 1.6
|
|
|
|
targetCompatibility = 1.6
|
|
|
|
|
|
|
|
repositories {
|
|
|
|
mavenCentral()
|
|
|
|
mavenLocal()
|
|
|
|
}
|
|
|
|
|
2015-03-13 06:25:11 +08:00
|
|
|
[compileJava, compileTestJava].each() {
|
2016-05-25 05:29:52 +08:00
|
|
|
it.options.compilerArgs += ["-Xlint:all", "-Xlint:-options"]
|
2015-03-13 06:25:11 +08:00
|
|
|
it.options.encoding = "UTF-8"
|
2016-07-11 02:40:12 +08:00
|
|
|
if (rootProject.hasProperty('failOnWarnings') && rootProject.failOnWarnings.toBoolean()) {
|
|
|
|
it.options.compilerArgs += ["-Werror"]
|
|
|
|
}
|
2015-01-27 06:03:11 +08:00
|
|
|
}
|
|
|
|
|
2016-05-25 05:29:52 +08:00
|
|
|
compileTestJava {
|
|
|
|
// serialVersionUID is basically guaranteed to be useless in our tests
|
|
|
|
options.compilerArgs += ["-Xlint:-serial"]
|
|
|
|
}
|
|
|
|
|
2015-06-01 23:31:00 +08:00
|
|
|
jar.manifest {
|
|
|
|
attributes('Implementation-Title': name,
|
|
|
|
'Implementation-Version': version,
|
|
|
|
'Built-By': System.getProperty('user.name'),
|
|
|
|
'Built-JDK': System.getProperty('java.version'),
|
|
|
|
'Source-Compatibility': sourceCompatibility,
|
|
|
|
'Target-Compatibility': targetCompatibility)
|
|
|
|
}
|
|
|
|
|
2015-05-06 01:28:38 +08:00
|
|
|
javadoc.options {
|
|
|
|
encoding = 'UTF-8'
|
|
|
|
links 'https://docs.oracle.com/javase/8/docs/api/'
|
|
|
|
}
|
2015-03-12 07:44:38 +08:00
|
|
|
|
2015-02-14 08:21:53 +08:00
|
|
|
ext {
|
2015-05-08 06:20:44 +08:00
|
|
|
def exeSuffix = osdetector.os == 'windows' ? ".exe" : ""
|
|
|
|
protocPluginBaseName = 'protoc-gen-grpc-java'
|
2016-01-27 04:13:06 +08:00
|
|
|
javaPluginPath = "$rootDir/compiler/build/exe/java_plugin/$protocPluginBaseName$exeSuffix"
|
2015-05-08 06:20:44 +08:00
|
|
|
|
2016-12-17 07:15:17 +08:00
|
|
|
guavaVersion = '20.0'
|
2017-02-08 01:47:15 +08:00
|
|
|
protobufVersion = '3.2.0'
|
2016-01-28 00:26:19 +08:00
|
|
|
protobufNanoVersion = '3.0.0-alpha-5'
|
2015-05-08 06:20:44 +08:00
|
|
|
|
2015-05-06 07:11:27 +08:00
|
|
|
configureProtoCompilation = {
|
2015-06-23 07:29:30 +08:00
|
|
|
String generatedSourcePath = "${projectDir}/src/generated"
|
2015-05-06 07:11:27 +08:00
|
|
|
if (rootProject.childProjects.containsKey('grpc-compiler')) {
|
|
|
|
// Only when the codegen is built along with the project, will we be able to recompile
|
|
|
|
// the proto files.
|
|
|
|
project.apply plugin: 'com.google.protobuf'
|
2015-06-23 07:29:30 +08:00
|
|
|
project.protobuf {
|
|
|
|
protoc {
|
|
|
|
if (project.hasProperty('protoc')) {
|
|
|
|
path = project.protoc
|
|
|
|
} else {
|
|
|
|
artifact = "com.google.protobuf:protoc:${protobufVersion}"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
plugins {
|
|
|
|
grpc {
|
|
|
|
path = javaPluginPath
|
|
|
|
}
|
|
|
|
}
|
|
|
|
generateProtoTasks {
|
|
|
|
all().each { task ->
|
|
|
|
task.dependsOn ':grpc-compiler:java_pluginExecutable'
|
|
|
|
// Delete the generated sources first, so that we can be alerted if they are not re-compiled.
|
2016-04-20 02:54:04 +08:00
|
|
|
task.dependsOn 'deleteGeneratedSource' + task.sourceSet.name
|
2015-06-23 07:29:30 +08:00
|
|
|
// Recompile protos when the codegen has been changed
|
|
|
|
task.inputs.file javaPluginPath
|
|
|
|
// Recompile protos when build.gradle has been changed, because
|
|
|
|
// it's possible the version of protoc has been changed.
|
|
|
|
task.inputs.file "${rootProject.projectDir}/build.gradle"
|
|
|
|
task.plugins {
|
2016-07-22 07:35:18 +08:00
|
|
|
grpc {
|
|
|
|
// To generate deprecated interfaces and static bindService method,
|
|
|
|
// turn the enable_deprecated option to true below:
|
|
|
|
option 'enable_deprecated=false'
|
|
|
|
}
|
2015-05-08 08:32:31 +08:00
|
|
|
}
|
|
|
|
}
|
2015-05-06 07:11:27 +08:00
|
|
|
}
|
2015-06-23 07:29:30 +08:00
|
|
|
generatedFilesBaseDir = generatedSourcePath
|
|
|
|
}
|
|
|
|
|
2016-04-20 02:54:04 +08:00
|
|
|
sourceSets.each { sourceSet ->
|
|
|
|
task "deleteGeneratedSource${sourceSet.name}" << {
|
|
|
|
project.delete project.fileTree(dir: generatedSourcePath + '/' + sourceSet.name)
|
|
|
|
}
|
2015-05-06 07:11:27 +08:00
|
|
|
}
|
2015-05-12 07:58:28 +08:00
|
|
|
} else {
|
|
|
|
// Otherwise, we just use the checked-in generated code.
|
|
|
|
project.sourceSets {
|
|
|
|
main {
|
|
|
|
java {
|
2015-06-23 07:29:30 +08:00
|
|
|
srcDir "${generatedSourcePath}/main/java"
|
2015-10-28 10:53:18 +08:00
|
|
|
srcDir "${generatedSourcePath}/main/javanano"
|
2015-06-23 07:29:30 +08:00
|
|
|
srcDir "${generatedSourcePath}/main/grpc"
|
2015-05-12 07:58:28 +08:00
|
|
|
}
|
|
|
|
}
|
2015-10-28 10:53:18 +08:00
|
|
|
test {
|
|
|
|
java {
|
|
|
|
srcDir "${generatedSourcePath}/test/java"
|
|
|
|
srcDir "${generatedSourcePath}/test/javanano"
|
|
|
|
srcDir "${generatedSourcePath}/test/grpc"
|
|
|
|
}
|
|
|
|
}
|
2015-05-12 07:58:28 +08:00
|
|
|
}
|
2015-05-06 07:11:27 +08:00
|
|
|
}
|
2016-05-24 03:05:41 +08:00
|
|
|
|
2016-11-29 05:20:55 +08:00
|
|
|
[compileJava, compileTestJava].each() {
|
2016-05-24 03:05:41 +08:00
|
|
|
// Protobuf-generated code produces some warnings.
|
2016-11-29 05:20:55 +08:00
|
|
|
it.options.compilerArgs += ["-Xlint:-cast"]
|
2016-05-24 03:05:41 +08:00
|
|
|
}
|
2015-05-06 07:11:27 +08:00
|
|
|
}
|
|
|
|
|
2015-05-22 02:54:04 +08:00
|
|
|
def epoll_suffix = "";
|
|
|
|
if (osdetector.classifier in ["linux-x86_64"]) {
|
|
|
|
// The native code is only pre-compiled on certain platforms.
|
|
|
|
epoll_suffix = ":" + osdetector.classifier
|
|
|
|
}
|
2015-02-14 08:21:53 +08:00
|
|
|
libraries = [
|
2016-08-19 09:57:50 +08:00
|
|
|
errorprone: "com.google.errorprone:error_prone_annotations:2.0.11",
|
2016-05-17 01:23:53 +08:00
|
|
|
guava: "com.google.guava:guava:${guavaVersion}",
|
2015-02-26 02:17:23 +08:00
|
|
|
hpack: 'com.twitter:hpack:0.10.1',
|
2015-02-14 08:21:53 +08:00
|
|
|
jsr305: 'com.google.code.findbugs:jsr305:3.0.0',
|
2016-06-15 04:51:24 +08:00
|
|
|
oauth_client: 'com.google.auth:google-auth-library-oauth2-http:0.4.0',
|
|
|
|
google_auth_credentials: 'com.google.auth:google-auth-library-credentials:0.4.0',
|
2015-09-22 01:39:00 +08:00
|
|
|
okhttp: 'com.squareup.okhttp:okhttp:2.5.0',
|
2015-09-22 03:54:06 +08:00
|
|
|
okio: 'com.squareup.okio:okio:1.6.0',
|
2017-01-06 02:48:13 +08:00
|
|
|
instrumentation_api: 'com.google.instrumentation:instrumentation-api:0.3.0',
|
2015-05-07 07:44:55 +08:00
|
|
|
protobuf: "com.google.protobuf:protobuf-java:${protobufVersion}",
|
2016-07-30 02:57:41 +08:00
|
|
|
// swap to ${protobufVersion} after versions align again
|
|
|
|
protobuf_lite: "com.google.protobuf:protobuf-lite:3.0.1",
|
2016-09-28 08:15:12 +08:00
|
|
|
// swap to ${protobufVersion} after versions align again
|
|
|
|
protoc_lite: "com.google.protobuf:protoc-gen-javalite:3.0.0",
|
2015-08-29 09:47:06 +08:00
|
|
|
protobuf_nano: "com.google.protobuf.nano:protobuf-javanano:${protobufNanoVersion}",
|
2016-08-19 04:06:18 +08:00
|
|
|
protobuf_plugin: 'com.google.protobuf:protobuf-gradle-plugin:0.8.0',
|
2016-03-03 01:30:35 +08:00
|
|
|
protobuf_util: "com.google.protobuf:protobuf-java-util:${protobufVersion}",
|
2015-02-14 08:21:53 +08:00
|
|
|
|
2017-01-31 04:40:46 +08:00
|
|
|
netty: 'io.netty:netty-codec-http2:[4.1.8.Final]',
|
|
|
|
netty_epoll: 'io.netty:netty-transport-native-epoll:4.1.8.Final' + epoll_suffix,
|
|
|
|
netty_proxy_handler: 'io.netty:netty-handler-proxy:4.1.8.Final',
|
|
|
|
netty_tcnative: 'io.netty:netty-tcnative-boringssl-static:1.1.33.Fork26',
|
2015-02-14 08:21:53 +08:00
|
|
|
|
|
|
|
// Test dependencies.
|
|
|
|
junit: 'junit:junit:4.11',
|
2016-04-02 06:18:23 +08:00
|
|
|
mockito: 'org.mockito:mockito-core:1.9.5',
|
2016-03-24 04:18:04 +08:00
|
|
|
truth: 'com.google.truth:truth:0.28',
|
|
|
|
|
|
|
|
// Benchmark dependencies
|
|
|
|
hdrhistogram: 'org.hdrhistogram:HdrHistogram:2.1.8',
|
|
|
|
math: 'org.apache.commons:commons-math3:3.6',
|
2015-02-14 08:21:53 +08:00
|
|
|
|
2016-05-03 05:01:36 +08:00
|
|
|
// Jetty ALPN dependencies
|
2016-05-20 02:41:03 +08:00
|
|
|
jetty_alpn_agent: 'org.mortbay.jetty.alpn:jetty-alpn-agent:2.0.3'
|
2016-05-03 05:01:36 +08:00
|
|
|
]
|
2015-02-14 08:21:53 +08:00
|
|
|
}
|
2014-12-16 01:58:05 +08:00
|
|
|
|
2016-05-03 05:01:36 +08:00
|
|
|
// Define a separate configuration for managing the dependency on Jetty ALPN agent.
|
2015-05-23 03:25:10 +08:00
|
|
|
configurations {
|
2016-05-03 05:01:36 +08:00
|
|
|
alpnagent
|
2015-09-05 06:13:46 +08:00
|
|
|
tcnative
|
2015-05-23 03:25:10 +08:00
|
|
|
}
|
|
|
|
|
2014-12-16 01:58:05 +08:00
|
|
|
dependencies {
|
|
|
|
testCompile libraries.junit,
|
|
|
|
libraries.mockito
|
2015-05-23 03:25:10 +08:00
|
|
|
|
2016-05-03 05:01:36 +08:00
|
|
|
// Configuration for modules that use Jetty ALPN agent
|
|
|
|
alpnagent libraries.jetty_alpn_agent
|
2015-09-05 06:13:46 +08:00
|
|
|
|
|
|
|
// Configuration for modules that use Netty tcnative (for OpenSSL).
|
|
|
|
tcnative libraries.netty_tcnative
|
2014-12-16 01:58:05 +08:00
|
|
|
}
|
2015-03-03 05:31:14 +08:00
|
|
|
|
|
|
|
signing {
|
|
|
|
required false
|
|
|
|
sign configurations.archives
|
|
|
|
}
|
|
|
|
|
2015-03-03 23:59:13 +08:00
|
|
|
// Disable JavaDoc doclint on Java 8. It's annoying.
|
|
|
|
if (JavaVersion.current().isJava8Compatible()) {
|
|
|
|
allprojects {
|
|
|
|
tasks.withType(Javadoc) {
|
|
|
|
options.addStringOption('Xdoclint:none', '-quiet')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-31 06:58:07 +08:00
|
|
|
checkstyle {
|
|
|
|
configFile = file("$rootDir/checkstyle.xml")
|
2016-04-19 00:15:25 +08:00
|
|
|
toolVersion = "6.17"
|
2015-05-05 23:54:51 +08:00
|
|
|
ignoreFailures = false
|
2015-03-22 01:59:17 +08:00
|
|
|
if (rootProject.hasProperty("checkstyle.ignoreFailures")) {
|
|
|
|
ignoreFailures = rootProject.properties["checkstyle.ignoreFailures"].toBoolean()
|
|
|
|
}
|
2015-09-16 01:34:14 +08:00
|
|
|
configProperties["rootDir"] = rootDir
|
2015-01-31 06:58:07 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
checkstyleMain {
|
2015-05-07 02:35:08 +08:00
|
|
|
source = fileTree(dir: "src/main", include: "**/*.java")
|
2015-01-31 06:58:07 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
checkstyleTest {
|
2015-05-07 02:35:08 +08:00
|
|
|
source = fileTree(dir: "src/test", include: "**/*.java")
|
2015-01-31 06:58:07 +08:00
|
|
|
}
|
|
|
|
|
2015-03-03 05:31:14 +08:00
|
|
|
task javadocJar(type: Jar) {
|
|
|
|
classifier = 'javadoc'
|
|
|
|
from javadoc
|
|
|
|
}
|
|
|
|
|
|
|
|
task sourcesJar(type: Jar) {
|
|
|
|
classifier = 'sources'
|
|
|
|
from sourceSets.main.allSource
|
|
|
|
}
|
|
|
|
|
|
|
|
artifacts {
|
|
|
|
archives javadocJar, sourcesJar
|
|
|
|
}
|
|
|
|
|
|
|
|
uploadArchives.repositories.mavenDeployer {
|
|
|
|
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
|
2015-03-12 09:03:31 +08:00
|
|
|
String stagingUrl
|
2015-05-07 04:10:28 +08:00
|
|
|
if (rootProject.hasProperty('repositoryId')) {
|
|
|
|
stagingUrl = 'https://oss.sonatype.org/service/local/staging/deployByRepositoryId/' +
|
|
|
|
rootProject.repositoryId
|
2015-03-12 09:03:31 +08:00
|
|
|
} else {
|
|
|
|
stagingUrl = 'https://oss.sonatype.org/service/local/staging/deploy/maven2/'
|
|
|
|
}
|
2015-05-07 04:10:28 +08:00
|
|
|
def configureAuth = {
|
|
|
|
if (rootProject.hasProperty('ossrhUsername') && rootProject.hasProperty('ossrhPassword')) {
|
|
|
|
authentication(userName: rootProject.ossrhUsername, password: rootProject.ossrhPassword)
|
|
|
|
}
|
2015-03-03 05:31:14 +08:00
|
|
|
}
|
2015-05-07 04:10:28 +08:00
|
|
|
repository(url: stagingUrl, configureAuth)
|
|
|
|
snapshotRepository(url: 'https://oss.sonatype.org/content/repositories/snapshots/', configureAuth)
|
2015-03-03 05:31:14 +08:00
|
|
|
}
|
2017-01-20 04:48:55 +08:00
|
|
|
uploadArchives.onlyIf { !name.contains("thrift") }
|
2015-03-03 05:31:14 +08:00
|
|
|
|
|
|
|
[
|
|
|
|
install.repositories.mavenInstaller,
|
|
|
|
uploadArchives.repositories.mavenDeployer,
|
|
|
|
]*.pom*.whenConfigured { pom ->
|
|
|
|
pom.project {
|
2015-03-13 08:03:01 +08:00
|
|
|
name "$project.group:$project.name"
|
2015-03-03 05:31:14 +08:00
|
|
|
description project.description
|
|
|
|
url 'https://github.com/grpc/grpc-java'
|
|
|
|
|
|
|
|
scm {
|
2016-04-08 23:37:07 +08:00
|
|
|
connection 'scm:git:https://github.com/grpc/grpc-java.git'
|
|
|
|
developerConnection 'scm:git:git@github.com:grpc/grpc-java.git'
|
2015-03-03 05:31:14 +08:00
|
|
|
url 'https://github.com/grpc/grpc-java'
|
|
|
|
}
|
|
|
|
|
|
|
|
licenses {
|
|
|
|
license {
|
|
|
|
name 'BSD 3-Clause'
|
|
|
|
url 'http://opensource.org/licenses/BSD-3-Clause'
|
|
|
|
}
|
|
|
|
}
|
2015-03-13 08:03:01 +08:00
|
|
|
|
|
|
|
developers {
|
|
|
|
developer {
|
|
|
|
id "grpc.io"
|
|
|
|
name "gRPC Contributors"
|
|
|
|
email "grpc-io@googlegroups.com"
|
|
|
|
url "http://grpc.io/"
|
|
|
|
// https://issues.gradle.org/browse/GRADLE-2719
|
|
|
|
organization = "Google, Inc."
|
|
|
|
organizationUrl "https://www.google.com"
|
|
|
|
}
|
|
|
|
}
|
2015-03-03 05:31:14 +08:00
|
|
|
}
|
2016-04-09 04:47:30 +08:00
|
|
|
if (!(project.name in
|
2016-07-28 23:48:27 +08:00
|
|
|
["grpc-stub", "grpc-protobuf", "grpc-protobuf-lite", "grpc-protobuf-nano", "grpc-thrift"])) {
|
2016-04-09 04:47:30 +08:00
|
|
|
def core = pom.dependencies.find {dep -> dep.artifactId == 'grpc-core'}
|
|
|
|
if (core != null) {
|
|
|
|
// Depend on specific version of grpc-core because internal package is unstable
|
|
|
|
core.version = "[" + core.version + "]"
|
|
|
|
}
|
|
|
|
}
|
2015-03-03 05:31:14 +08:00
|
|
|
}
|
2015-04-23 01:02:19 +08:00
|
|
|
// At a test failure, log the stack trace to the console so that we don't
|
|
|
|
// have to open the HTML in a browser.
|
|
|
|
test {
|
|
|
|
testLogging {
|
|
|
|
exceptionFormat = 'full'
|
2015-06-02 07:20:08 +08:00
|
|
|
showExceptions true
|
|
|
|
showCauses true
|
|
|
|
showStackTraces true
|
2015-04-23 01:02:19 +08:00
|
|
|
}
|
2016-02-13 00:48:41 +08:00
|
|
|
maxHeapSize = '1500m'
|
2015-04-23 01:02:19 +08:00
|
|
|
}
|
2014-12-16 01:58:05 +08:00
|
|
|
}
|