2015-04-18 01:49:11 +08:00
|
|
|
buildscript {
|
|
|
|
repositories {
|
|
|
|
mavenCentral()
|
|
|
|
mavenLocal()
|
|
|
|
}
|
|
|
|
dependencies {
|
|
|
|
classpath 'com.google.gradle:osdetector-gradle-plugin:1.2.1'
|
|
|
|
}
|
|
|
|
}
|
2015-03-01 01:59:25 +08:00
|
|
|
|
2014-12-16 01:58:05 +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-04-18 01:49:11 +08:00
|
|
|
apply plugin: "osdetector"
|
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-01-28 02:25:39 +08:00
|
|
|
group = "io.grpc"
|
2015-05-27 04:40:13 +08:00
|
|
|
version = "0.8.0-SNAPSHOT"
|
2014-12-16 01:58:05 +08:00
|
|
|
|
|
|
|
sourceCompatibility = 1.6
|
|
|
|
targetCompatibility = 1.6
|
|
|
|
|
|
|
|
repositories {
|
|
|
|
mavenCentral()
|
|
|
|
mavenLocal()
|
|
|
|
}
|
|
|
|
|
2015-06-01 23:31:00 +08:00
|
|
|
|
2015-03-13 06:25:11 +08:00
|
|
|
[compileJava, compileTestJava].each() {
|
|
|
|
it.options.compilerArgs += ["-Xlint:unchecked", "-Xlint:deprecation", "-Xlint:-options"]
|
|
|
|
it.options.encoding = "UTF-8"
|
2015-01-27 06:03:11 +08:00
|
|
|
}
|
|
|
|
|
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'
|
|
|
|
javaPluginPath = "$rootDir/compiler/build/binaries/java_pluginExecutable/$protocPluginBaseName$exeSuffix"
|
|
|
|
|
2015-07-01 07:08:46 +08:00
|
|
|
protobufVersion = '3.0.0-alpha-3.1'
|
2015-05-08 06:20:44 +08:00
|
|
|
|
2015-05-06 07:11:27 +08:00
|
|
|
configureProtoCompilation = {
|
2015-05-12 07:58:28 +08:00
|
|
|
String generatedSourcePath = '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-05-08 08:32:31 +08:00
|
|
|
project.protobufCodeGenPlugins = ["grpc:$javaPluginPath"]
|
2015-05-13 08:03:19 +08:00
|
|
|
if (project.hasProperty('protoc')) {
|
|
|
|
project.protocPath = project.protoc
|
|
|
|
} else {
|
|
|
|
project.protocDep = "com.google.protobuf:protoc:${protobufVersion}"
|
|
|
|
}
|
2015-05-06 07:11:27 +08:00
|
|
|
project.generatedFileDir = "${projectDir}/src/generated"
|
2015-05-16 01:37:57 +08:00
|
|
|
task deleteGeneratedSource << {
|
|
|
|
project.delete project.fileTree(dir: generatedSourcePath)
|
|
|
|
}
|
2015-05-06 07:11:27 +08:00
|
|
|
project.afterEvaluate {
|
|
|
|
generateProto.dependsOn ':grpc-compiler:java_pluginExecutable'
|
2015-05-16 01:37:57 +08:00
|
|
|
// Delete the generated sources first, so that we can be alerted if they are not re-compiled.
|
|
|
|
generateProto.dependsOn deleteGeneratedSource
|
2015-05-08 06:20:44 +08:00
|
|
|
// Recompile protos when the codegen has been changed
|
|
|
|
generateProto.inputs.file javaPluginPath
|
|
|
|
// Recompile protos when build.gradle has been changed, because
|
|
|
|
// it's possible the version of protoc has been changed.
|
|
|
|
generateProto.inputs.file "${rootProject.projectDir}/build.gradle"
|
2015-05-06 07:11:27 +08:00
|
|
|
}
|
2015-05-12 07:58:28 +08:00
|
|
|
|
2015-05-06 07:11:27 +08:00
|
|
|
project.sourceSets {
|
|
|
|
main {
|
2015-05-08 08:32:31 +08:00
|
|
|
proto {
|
|
|
|
plugins {
|
|
|
|
grpc { }
|
|
|
|
}
|
|
|
|
}
|
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 {
|
|
|
|
srcDir "${generatedSourcePath}/main"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-05-06 07:11:27 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-05-22 02:54:04 +08:00
|
|
|
def tcnative_suffix = "";
|
|
|
|
if (osdetector.classifier in ["linux-x86_64", "osx-x86_64", "windows-x86_64"]) {
|
|
|
|
// The native code is only pre-compiled on certain platforms.
|
|
|
|
tcnative_suffix = ":" + osdetector.classifier
|
|
|
|
}
|
|
|
|
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 = [
|
|
|
|
guava: 'com.google.guava:guava:18.0',
|
2015-02-24 04:03:59 +08:00
|
|
|
// used to collect benchmark results
|
|
|
|
hdrhistogram: 'org.hdrhistogram:HdrHistogram:2.1.4',
|
2015-02-26 02:17:23 +08:00
|
|
|
hpack: 'com.twitter:hpack:0.10.1',
|
2015-02-24 04:03:59 +08:00
|
|
|
javaee_api: 'javax:javaee-api:7.0',
|
|
|
|
jsonp: 'org.glassfish:javax.json:1.0.4',
|
2015-02-14 08:21:53 +08:00
|
|
|
jsr305: 'com.google.code.findbugs:jsr305:3.0.0',
|
2015-03-03 07:05:09 +08:00
|
|
|
oauth_client: 'com.google.auth:google-auth-library-oauth2-http:0.1.0',
|
2015-05-27 09:14:49 +08:00
|
|
|
okhttp: 'com.squareup.okhttp:okhttp:2.4.0',
|
2015-05-07 07:44:55 +08:00
|
|
|
protobuf: "com.google.protobuf:protobuf-java:${protobufVersion}",
|
|
|
|
protobuf_nano: "com.google.protobuf.nano:protobuf-javanano:${protobufVersion}",
|
2015-05-13 08:03:19 +08:00
|
|
|
protobuf_plugin: 'com.google.protobuf:protobuf-gradle-plugin:0.4.1',
|
2015-02-14 08:21:53 +08:00
|
|
|
|
2015-05-09 17:59:20 +08:00
|
|
|
netty: 'io.netty:netty-codec-http2:4.1.0.Beta5',
|
2015-05-22 02:54:04 +08:00
|
|
|
netty_tcnative: 'io.netty:netty-tcnative:1.1.33.Fork2' + tcnative_suffix,
|
|
|
|
netty_transport_native_epoll: 'io.netty:netty-transport-native-epoll:4.1.0.Beta5' + epoll_suffix,
|
2015-02-14 08:21:53 +08:00
|
|
|
|
|
|
|
// Test dependencies.
|
|
|
|
junit: 'junit:junit:4.11',
|
2015-03-03 05:31:14 +08:00
|
|
|
mockito: 'org.mockito:mockito-core:1.10.19'
|
2015-02-14 08:21:53 +08:00
|
|
|
]
|
|
|
|
|
|
|
|
// Determine the correct version of Jetty ALPN boot to use based
|
|
|
|
// on the Java version.
|
|
|
|
def alpnboot_version = '8.1.2.v20141202'
|
|
|
|
if (JavaVersion.current().ordinal() < JavaVersion.VERSION_1_8.ordinal()) {
|
|
|
|
alpnboot_version = '7.1.2.v20141202'
|
|
|
|
}
|
|
|
|
|
|
|
|
alpnboot_package_name = 'org.mortbay.jetty.alpn:alpn-boot:' + alpnboot_version
|
|
|
|
}
|
2014-12-16 01:58:05 +08:00
|
|
|
|
2015-05-23 03:25:10 +08:00
|
|
|
// Define a separate configuration for managing the dependency on Jetty alpnboot jar.
|
|
|
|
configurations {
|
|
|
|
alpnboot
|
|
|
|
}
|
|
|
|
|
2014-12-16 01:58:05 +08:00
|
|
|
dependencies {
|
|
|
|
testCompile libraries.junit,
|
|
|
|
libraries.mockito
|
2015-05-23 03:25:10 +08:00
|
|
|
|
|
|
|
// Make the Jetty alpnboot jar available to submodules via the alpnboot configuration.
|
|
|
|
alpnboot alpnboot_package_name
|
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")
|
2015-04-06 21:04:56 +08:00
|
|
|
toolVersion = "6.5"
|
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-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
|
|
|
}
|
|
|
|
|
|
|
|
[
|
|
|
|
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 {
|
|
|
|
connection 'scm:svn:https://github.com/grpc/grpc-java.git'
|
|
|
|
developerConnection 'scm:svn:git@github.com:grpc/grpc-java.git'
|
|
|
|
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
|
|
|
}
|
|
|
|
}
|
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
|
|
|
}
|
|
|
|
}
|
2014-12-16 01:58:05 +08:00
|
|
|
}
|