all: add gradle format checker

This PR adds an automatic gradle format checker and reformats all the *.gradle files. After this, new changes to *.gradle files will fail to build if not in good format, just like checkStyle failure.
This commit is contained in:
ZHANG Dapeng 2018-06-11 18:35:18 -07:00 committed by GitHub
parent 9d26c5c405
commit 5ce10f0146
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
32 changed files with 930 additions and 1051 deletions

View File

@ -4,27 +4,23 @@ description = "gRPC: All"
buildscript { buildscript {
repositories { repositories {
maven { maven { // The google mirror is less flaky than mavenCentral()
// The google mirror is less flaky than mavenCentral() url "https://maven-central.storage-download.googleapis.com/repos/central/data/" }
url "https://maven-central.storage-download.googleapis.com/repos/central/data/"
}
}
dependencies {
classpath 'org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.0.1'
} }
dependencies { classpath 'org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.0.1' }
} }
def subprojects = [ def subprojects = [
project(':grpc-auth'), project(':grpc-auth'),
project(':grpc-core'), project(':grpc-core'),
project(':grpc-context'), project(':grpc-context'),
project(':grpc-netty'), project(':grpc-netty'),
project(':grpc-okhttp'), project(':grpc-okhttp'),
project(':grpc-protobuf'), project(':grpc-protobuf'),
project(':grpc-protobuf-lite'), project(':grpc-protobuf-lite'),
project(':grpc-protobuf-nano'), project(':grpc-protobuf-nano'),
project(':grpc-stub'), project(':grpc-stub'),
project(':grpc-testing'), project(':grpc-testing'),
] ]
for (subproject in rootProject.subprojects) { for (subproject in rootProject.subprojects) {
@ -56,8 +52,8 @@ task jacocoMerge(type: JacocoMerge) {
mustRunAfter(subprojects.jacocoTestReport.mustRunAfter) mustRunAfter(subprojects.jacocoTestReport.mustRunAfter)
destinationFile = file("${buildDir}/jacoco/test.exec") destinationFile = file("${buildDir}/jacoco/test.exec")
executionData = files(subprojects.jacocoTestReport.executionData) executionData = files(subprojects.jacocoTestReport.executionData)
.plus(project(':grpc-interop-testing').jacocoTestReport.executionData) .plus(project(':grpc-interop-testing').jacocoTestReport.executionData)
.filter { f -> f.exists() } .filter { f -> f.exists() }
} }
jacocoTestReport { jacocoTestReport {
@ -72,7 +68,9 @@ jacocoTestReport {
classDirectories = files(subprojects.sourceSets.main.output) classDirectories = files(subprojects.sourceSets.main.output)
classDirectories = files(classDirectories.files.collect { classDirectories = files(classDirectories.files.collect {
fileTree(dir: it, fileTree(dir: it,
exclude: ['**/io/grpc/okhttp/internal/**']) exclude: [
'**/io/grpc/okhttp/internal/**'
])
}) })
} }
@ -80,6 +78,4 @@ coveralls {
sourceDirs = subprojects.sourceSets.main.allSource.srcDirs.flatten() sourceDirs = subprojects.sourceSets.main.allSource.srcDirs.flatten()
} }
tasks.coveralls { tasks.coveralls { dependsOn(jacocoTestReport) }
dependsOn(jacocoTestReport)
}

View File

@ -5,14 +5,10 @@ targetCompatibility = 1.7
buildscript { buildscript {
repositories { repositories {
maven { maven { // The google mirror is less flaky than mavenCentral()
// The google mirror is less flaky than mavenCentral() url "https://maven-central.storage-download.googleapis.com/repos/central/data/" }
url "https://maven-central.storage-download.googleapis.com/repos/central/data/"
}
}
dependencies {
classpath libraries.protobuf_plugin
} }
dependencies { classpath libraries.protobuf_plugin }
} }
dependencies { dependencies {
@ -24,10 +20,10 @@ dependencies {
libraries.protobuf libraries.protobuf
runtime project(':grpc-grpclb') runtime project(':grpc-grpclb')
testCompile libraries.guava, testCompile libraries.guava,
libraries.guava_testlib, libraries.guava_testlib,
libraries.junit, libraries.junit,
libraries.mockito, libraries.mockito,
libraries.truth libraries.truth
signature 'org.codehaus.mojo.signature:java17:1.0@signature' signature 'org.codehaus.mojo.signature:java17:1.0@signature'
} }
@ -36,9 +32,10 @@ configureProtoCompilation()
[compileJava, compileTestJava].each() { [compileJava, compileTestJava].each() {
// ALTS retuns a lot of futures that we mostly don't care about. // ALTS retuns a lot of futures that we mostly don't care about.
// protobuf calls valueof. Will be fixed in next release (google/protobuf#4046) // protobuf calls valueof. Will be fixed in next release (google/protobuf#4046)
it.options.compilerArgs += ["-Xlint:-deprecation", "-Xep:FutureReturnValueIgnored:OFF"] it.options.compilerArgs += [
"-Xlint:-deprecation",
"-Xep:FutureReturnValueIgnored:OFF"
]
} }
javadoc { javadoc { exclude 'io/grpc/alts/internal/**' }
exclude 'io/grpc/alts/internal/**'
}

View File

@ -14,26 +14,19 @@ android {
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
} }
buildTypes { buildTypes {
debug { debug { minifyEnabled false }
minifyEnabled false
}
release { release {
minifyEnabled true minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
} }
} }
lintOptions { lintOptions { disable 'InvalidPackage', 'HardcodedText' }
disable 'InvalidPackage', 'HardcodedText'
}
} }
protobuf { protobuf {
protoc { protoc { artifact = 'com.google.protobuf:protoc:3.5.1-1' }
artifact = 'com.google.protobuf:protoc:3.5.1-1'
}
plugins { plugins {
grpc { grpc { artifact = 'io.grpc:protoc-gen-grpc-java:1.14.0-SNAPSHOT' // CURRENT_GRPC_VERSION
artifact = 'io.grpc:protoc-gen-grpc-java:1.14.0-SNAPSHOT' // CURRENT_GRPC_VERSION
} }
} }
generateProtoTasks { generateProtoTasks {
@ -47,10 +40,8 @@ protobuf {
} }
task.plugins { task.plugins {
grpc { grpc { // Options added to --grpc_out
// Options added to --grpc_out option 'nano' }
option 'nano'
}
} }
} }
} }
@ -73,7 +64,5 @@ dependencies {
} }
gradle.projectsEvaluated { gradle.projectsEvaluated {
tasks.withType(JavaCompile) { tasks.withType(JavaCompile) { options.compilerArgs << "-Xlint:deprecation" }
options.compilerArgs << "-Xlint:deprecation"
}
} }

View File

@ -9,9 +9,7 @@ buildscript {
google() google()
jcenter() jcenter()
mavenCentral() mavenCentral()
maven { maven { url "https://plugins.gradle.org/m2/" }
url "https://plugins.gradle.org/m2/"
}
} }
dependencies { dependencies {
classpath 'com.android.tools.build:gradle:3.0.1' classpath 'com.android.tools.build:gradle:3.0.1'
@ -33,9 +31,7 @@ android {
versionName "1.0" versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
} }
lintOptions { lintOptions { abortOnError false }
abortOnError false
}
} }
repositories { repositories {

View File

@ -3,6 +3,6 @@ dependencies {
compile project(':grpc-core'), compile project(':grpc-core'),
libraries.google_auth_credentials libraries.google_auth_credentials
testCompile project(':grpc-testing'), testCompile project(':grpc-testing'),
libraries.oauth_client libraries.oauth_client
signature "org.codehaus.mojo.signature:java16:1.1@signature" signature "org.codehaus.mojo.signature:java16:1.1@signature"
} }

View File

@ -1,13 +1,9 @@
buildscript { buildscript {
repositories { repositories {
maven { maven { // The google mirror is less flaky than mavenCentral()
// The google mirror is less flaky than mavenCentral() url "https://maven-central.storage-download.googleapis.com/repos/central/data/" }
url "https://maven-central.storage-download.googleapis.com/repos/central/data/"
}
}
dependencies {
classpath libraries.protobuf_plugin
} }
dependencies { classpath libraries.protobuf_plugin }
} }
apply plugin: 'application' apply plugin: 'application'
@ -41,23 +37,25 @@ dependencies {
} }
compileJava { compileJava {
// The Control.Void protobuf clashes // The Control.Void protobuf clashes
options.compilerArgs += ["-Xep:JavaLangClash:OFF"] options.compilerArgs += ["-Xep:JavaLangClash:OFF"]
} }
configureProtoCompilation() configureProtoCompilation()
def vmArgs = [ def vmArgs = [
"-server", "-server",
"-Xms2g", "-Xms2g",
"-Xmx2g", "-Xmx2g",
"-XX:+PrintGCDetails" "-XX:+PrintGCDetails"
] ]
task qps_client(type: CreateStartScripts) { task qps_client(type: CreateStartScripts) {
mainClassName = "io.grpc.benchmarks.qps.AsyncClient" mainClassName = "io.grpc.benchmarks.qps.AsyncClient"
applicationName = "qps_client" applicationName = "qps_client"
defaultJvmOpts = ["-javaagent:" + configurations.alpnagent.asPath] + vmArgs defaultJvmOpts = [
"-javaagent:" + configurations.alpnagent.asPath
].plus(vmArgs)
outputDir = new File(project.buildDir, 'tmp') outputDir = new File(project.buildDir, 'tmp')
classpath = jar.outputs.files + project.configurations.runtime classpath = jar.outputs.files + project.configurations.runtime
} }
@ -65,7 +63,9 @@ task qps_client(type: CreateStartScripts) {
task openloop_client(type: CreateStartScripts) { task openloop_client(type: CreateStartScripts) {
mainClassName = "io.grpc.benchmarks.qps.OpenLoopClient" mainClassName = "io.grpc.benchmarks.qps.OpenLoopClient"
applicationName = "openloop_client" applicationName = "openloop_client"
defaultJvmOpts = ["-javaagent:" + configurations.alpnagent.asPath] + vmArgs defaultJvmOpts = [
"-javaagent:" + configurations.alpnagent.asPath
].plus(vmArgs)
outputDir = new File(project.buildDir, 'tmp') outputDir = new File(project.buildDir, 'tmp')
classpath = jar.outputs.files + project.configurations.runtime classpath = jar.outputs.files + project.configurations.runtime
} }
@ -80,7 +80,9 @@ task qps_server(type: CreateStartScripts) {
task benchmark_worker(type: CreateStartScripts) { task benchmark_worker(type: CreateStartScripts) {
mainClassName = "io.grpc.benchmarks.driver.LoadWorker" mainClassName = "io.grpc.benchmarks.driver.LoadWorker"
applicationName = "benchmark_worker" applicationName = "benchmark_worker"
defaultJvmOpts = ["-javaagent:" + configurations.alpnagent.asPath] + vmArgs defaultJvmOpts = [
"-javaagent:" + configurations.alpnagent.asPath
].plus(vmArgs)
outputDir = new File(project.buildDir, 'tmp') outputDir = new File(project.buildDir, 'tmp')
classpath = jar.outputs.files + project.configurations.runtime classpath = jar.outputs.files + project.configurations.runtime
} }

View File

@ -1,18 +1,17 @@
buildscript { buildscript {
repositories { repositories {
mavenLocal() mavenLocal()
maven { maven { url "https://plugins.gradle.org/m2/" }
url "https://plugins.gradle.org/m2/" }
dependencies {
classpath "com.diffplug.spotless:spotless-plugin-gradle:3.13.0"
classpath 'com.google.gradle:osdetector-gradle-plugin:1.4.0'
classpath 'ru.vyarus:gradle-animalsniffer-plugin:1.4.0'
classpath 'net.ltgt.gradle:gradle-errorprone-plugin:0.0.13'
classpath 'net.ltgt.gradle:gradle-apt-plugin:0.13'
classpath "me.champeau.gradle:jmh-gradle-plugin:0.4.5"
classpath 'me.champeau.gradle:japicmp-gradle-plugin:0.2.5'
} }
}
dependencies {
classpath 'com.google.gradle:osdetector-gradle-plugin:1.4.0'
classpath 'ru.vyarus:gradle-animalsniffer-plugin:1.4.0'
classpath 'net.ltgt.gradle:gradle-errorprone-plugin:0.0.13'
classpath 'net.ltgt.gradle:gradle-apt-plugin:0.13'
classpath "me.champeau.gradle:jmh-gradle-plugin:0.4.5"
classpath 'me.champeau.gradle:japicmp-gradle-plugin:0.2.5'
}
} }
subprojects { subprojects {
@ -28,24 +27,24 @@ subprojects {
// The plugin only has an effect if a signature is specified // The plugin only has an effect if a signature is specified
apply plugin: "ru.vyarus.animalsniffer" apply plugin: "ru.vyarus.animalsniffer"
if (!rootProject.hasProperty('errorProne') || rootProject.errorProne.toBoolean()) { if (!rootProject.hasProperty('errorProne') || rootProject.errorProne.toBoolean()) {
apply plugin: "net.ltgt.errorprone" apply plugin: "net.ltgt.errorprone"
apply plugin: "net.ltgt.apt" apply plugin: "net.ltgt.apt"
dependencies { dependencies {
// The ErrorProne plugin defaults to the latest, which would break our // The ErrorProne plugin defaults to the latest, which would break our
// build if error prone releases a new version with a new check // build if error prone releases a new version with a new check
errorprone 'com.google.errorprone:error_prone_core:2.2.0' errorprone 'com.google.errorprone:error_prone_core:2.2.0'
apt 'com.google.guava:guava-beta-checker:1.0' apt 'com.google.guava:guava-beta-checker:1.0'
} }
} else { } else {
// Remove per-project error-prone checker config // Remove per-project error-prone checker config
allprojects { allprojects {
afterEvaluate { project -> afterEvaluate { project ->
project.tasks.withType(JavaCompile) { project.tasks.withType(JavaCompile) {
options.compilerArgs.removeAll { it.startsWith("-Xep") } options.compilerArgs.removeAll { it.startsWith("-Xep") }
} }
}
} }
}
} }
// TODO(zpencer): remove when intellij 2017.2 is released // TODO(zpencer): remove when intellij 2017.2 is released
// https://github.com/gradle/gradle/issues/2315 // https://github.com/gradle/gradle/issues/2315
@ -58,15 +57,21 @@ subprojects {
targetCompatibility = 1.6 targetCompatibility = 1.6
repositories { repositories {
maven { maven { // The google mirror is less flaky than mavenCentral()
// The google mirror is less flaky than mavenCentral() url "https://maven-central.storage-download.googleapis.com/repos/central/data/" }
url "https://maven-central.storage-download.googleapis.com/repos/central/data/"
}
mavenLocal() mavenLocal()
} }
[compileJava, compileTestJava, compileJmhJava].each() { [
it.options.compilerArgs += ["-Xlint:all", "-Xlint:-options", "-Xlint:-path"] compileJava,
compileTestJava,
compileJmhJava
].each() {
it.options.compilerArgs += [
"-Xlint:all",
"-Xlint:-options",
"-Xlint:-path"
]
it.options.encoding = "UTF-8" it.options.encoding = "UTF-8"
if (rootProject.hasProperty('failOnWarnings') && rootProject.failOnWarnings.toBoolean()) { if (rootProject.hasProperty('failOnWarnings') && rootProject.failOnWarnings.toBoolean()) {
it.options.compilerArgs += ["-Werror"] it.options.compilerArgs += ["-Werror"]
@ -74,18 +79,21 @@ subprojects {
} }
compileTestJava { compileTestJava {
// serialVersionUID is basically guaranteed to be useless in our tests // serialVersionUID is basically guaranteed to be useless in our tests
// LinkedList doesn't hurt much in tests and has lots of usages // LinkedList doesn't hurt much in tests and has lots of usages
options.compilerArgs += ["-Xlint:-serial", "-Xep:JdkObsolete:OFF"] options.compilerArgs += [
"-Xlint:-serial",
"-Xep:JdkObsolete:OFF"
]
} }
jar.manifest { jar.manifest {
attributes('Implementation-Title': name, attributes('Implementation-Title': name,
'Implementation-Version': version, 'Implementation-Version': version,
'Built-By': System.getProperty('user.name'), 'Built-By': System.getProperty('user.name'),
'Built-JDK': System.getProperty('java.version'), 'Built-JDK': System.getProperty('java.version'),
'Source-Compatibility': sourceCompatibility, 'Source-Compatibility': sourceCompatibility,
'Target-Compatibility': targetCompatibility) 'Target-Compatibility': targetCompatibility)
} }
javadoc.options { javadoc.options {
@ -107,79 +115,75 @@ subprojects {
opencensusVersion = '0.12.3' opencensusVersion = '0.12.3'
configureProtoCompilation = { configureProtoCompilation = {
String generatedSourcePath = "${projectDir}/src/generated" String generatedSourcePath = "${projectDir}/src/generated"
if (rootProject.childProjects.containsKey('grpc-compiler')) { if (rootProject.childProjects.containsKey('grpc-compiler')) {
// Only when the codegen is built along with the project, will we be able to recompile // Only when the codegen is built along with the project, will we be able to recompile
// the proto files. // the proto files.
project.apply plugin: 'com.google.protobuf' project.apply plugin: 'com.google.protobuf'
project.protobuf { project.protobuf {
protoc { protoc {
if (project.hasProperty('protoc')) { if (project.hasProperty('protoc')) {
path = project.protoc path = project.protoc
} else { } else {
artifact = "com.google.protobuf:protoc:${protocVersion}" artifact = "com.google.protobuf:protoc:${protocVersion}"
} }
} }
plugins { plugins { grpc { path = javaPluginPath } }
grpc { generateProtoTasks {
path = javaPluginPath 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.
generateProtoTasks { task.dependsOn 'deleteGeneratedSource' + task.sourceSet.name
all().each { task -> // Recompile protos when the codegen has been changed
task.dependsOn ':grpc-compiler:java_pluginExecutable' task.inputs.file javaPluginPath
// Delete the generated sources first, so that we can be alerted if they are not re-compiled. // Recompile protos when build.gradle has been changed, because
task.dependsOn 'deleteGeneratedSource' + task.sourceSet.name // it's possible the version of protoc has been changed.
// Recompile protos when the codegen has been changed task.inputs.file "${rootProject.projectDir}/build.gradle"
task.inputs.file javaPluginPath task.plugins { grpc { option 'noversion' } }
// 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" generatedFilesBaseDir = generatedSourcePath
task.plugins { }
grpc {
option 'noversion' sourceSets.each { sourceSet ->
task "deleteGeneratedSource${sourceSet.name}" {
doLast {
project.delete project.fileTree(dir: generatedSourcePath + '/' + sourceSet.name)
}
}
}
} else {
// Otherwise, we just use the checked-in generated code.
project.sourceSets {
main {
java {
srcDir "${generatedSourcePath}/main/java"
srcDir "${generatedSourcePath}/main/javanano"
srcDir "${generatedSourcePath}/main/grpc"
}
}
test {
java {
srcDir "${generatedSourcePath}/test/java"
srcDir "${generatedSourcePath}/test/javanano"
srcDir "${generatedSourcePath}/test/grpc"
}
} }
}
} }
}
generatedFilesBaseDir = generatedSourcePath
} }
sourceSets.each { sourceSet -> [
task "deleteGeneratedSource${sourceSet.name}" { compileJava,
doLast { compileTestJava,
project.delete project.fileTree(dir: generatedSourcePath + '/' + sourceSet.name) compileJmhJava
} ].each() {
} // Protobuf-generated code produces some warnings.
// https://github.com/google/protobuf/issues/2718
it.options.compilerArgs += [
"-Xlint:-cast",
"-XepExcludedPaths:.*/src/generated/[^/]+/java/.*",
]
} }
} else {
// Otherwise, we just use the checked-in generated code.
project.sourceSets {
main {
java {
srcDir "${generatedSourcePath}/main/java"
srcDir "${generatedSourcePath}/main/javanano"
srcDir "${generatedSourcePath}/main/grpc"
}
}
test {
java {
srcDir "${generatedSourcePath}/test/java"
srcDir "${generatedSourcePath}/test/javanano"
srcDir "${generatedSourcePath}/test/grpc"
}
}
}
}
[compileJava, compileTestJava, compileJmhJava].each() {
// Protobuf-generated code produces some warnings.
// https://github.com/google/protobuf/issues/2718
it.options.compilerArgs += [
"-Xlint:-cast",
"-XepExcludedPaths:.*/src/generated/[^/]+/java/.*",
]
}
} }
def epoll_suffix = ""; def epoll_suffix = "";
@ -188,50 +192,50 @@ subprojects {
epoll_suffix = ":" + osdetector.classifier epoll_suffix = ":" + osdetector.classifier
} }
libraries = [ libraries = [
errorprone: "com.google.errorprone:error_prone_annotations:2.1.2", errorprone: "com.google.errorprone:error_prone_annotations:2.1.2",
gson: "com.google.code.gson:gson:2.7", gson: "com.google.code.gson:gson:2.7",
guava: "com.google.guava:guava:${guavaVersion}", guava: "com.google.guava:guava:${guavaVersion}",
hpack: 'com.twitter:hpack:0.10.1', hpack: 'com.twitter:hpack:0.10.1',
javax_annotation: 'javax.annotation:javax.annotation-api:1.2', javax_annotation: 'javax.annotation:javax.annotation-api:1.2',
jsr305: 'com.google.code.findbugs:jsr305:3.0.0', jsr305: 'com.google.code.findbugs:jsr305:3.0.0',
oauth_client: 'com.google.auth:google-auth-library-oauth2-http:0.9.0', oauth_client: 'com.google.auth:google-auth-library-oauth2-http:0.9.0',
google_api_protos: 'com.google.api.grpc:proto-google-common-protos:1.0.0', google_api_protos: 'com.google.api.grpc:proto-google-common-protos:1.0.0',
google_auth_credentials: 'com.google.auth:google-auth-library-credentials:0.9.0', google_auth_credentials: 'com.google.auth:google-auth-library-credentials:0.9.0',
okhttp: 'com.squareup.okhttp:okhttp:2.5.0', okhttp: 'com.squareup.okhttp:okhttp:2.5.0',
okio: 'com.squareup.okio:okio:1.13.0', okio: 'com.squareup.okio:okio:1.13.0',
opencensus_api: "io.opencensus:opencensus-api:${opencensusVersion}", opencensus_api: "io.opencensus:opencensus-api:${opencensusVersion}",
opencensus_contrib_grpc_metrics: "io.opencensus:opencensus-contrib-grpc-metrics:${opencensusVersion}", opencensus_contrib_grpc_metrics: "io.opencensus:opencensus-contrib-grpc-metrics:${opencensusVersion}",
opencensus_impl: "io.opencensus:opencensus-impl:${opencensusVersion}", opencensus_impl: "io.opencensus:opencensus-impl:${opencensusVersion}",
opencensus_impl_lite: "io.opencensus:opencensus-impl-lite:${opencensusVersion}", opencensus_impl_lite: "io.opencensus:opencensus-impl-lite:${opencensusVersion}",
instrumentation_api: 'com.google.instrumentation:instrumentation-api:0.4.3', instrumentation_api: 'com.google.instrumentation:instrumentation-api:0.4.3',
protobuf: "com.google.protobuf:protobuf-java:${protobufVersion}", protobuf: "com.google.protobuf:protobuf-java:${protobufVersion}",
protobuf_lite: "com.google.protobuf:protobuf-lite:3.0.1", protobuf_lite: "com.google.protobuf:protobuf-lite:3.0.1",
protoc_lite: "com.google.protobuf:protoc-gen-javalite:3.0.0", protoc_lite: "com.google.protobuf:protoc-gen-javalite:3.0.0",
protobuf_nano: "com.google.protobuf.nano:protobuf-javanano:${protobufNanoVersion}", protobuf_nano: "com.google.protobuf.nano:protobuf-javanano:${protobufNanoVersion}",
protobuf_plugin: 'com.google.protobuf:protobuf-gradle-plugin:0.8.5', protobuf_plugin: 'com.google.protobuf:protobuf-gradle-plugin:0.8.5',
protobuf_util: "com.google.protobuf:protobuf-java-util:${protobufVersion}", protobuf_util: "com.google.protobuf:protobuf-java-util:${protobufVersion}",
lang: "org.apache.commons:commons-lang3:3.5", lang: "org.apache.commons:commons-lang3:3.5",
netty: "io.netty:netty-codec-http2:[${nettyVersion}]", netty: "io.netty:netty-codec-http2:[${nettyVersion}]",
netty_epoll: "io.netty:netty-transport-native-epoll:${nettyVersion}" + epoll_suffix, netty_epoll: "io.netty:netty-transport-native-epoll:${nettyVersion}" + epoll_suffix,
netty_proxy_handler: "io.netty:netty-handler-proxy:${nettyVersion}", netty_proxy_handler: "io.netty:netty-handler-proxy:${nettyVersion}",
netty_tcnative: 'io.netty:netty-tcnative-boringssl-static:2.0.8.Final', netty_tcnative: 'io.netty:netty-tcnative-boringssl-static:2.0.8.Final',
conscrypt: 'org.conscrypt:conscrypt-openjdk-uber:1.0.1', conscrypt: 'org.conscrypt:conscrypt-openjdk-uber:1.0.1',
re2j: 'com.google.re2j:re2j:1.2', re2j: 'com.google.re2j:re2j:1.2',
// Test dependencies. // Test dependencies.
junit: 'junit:junit:4.12', junit: 'junit:junit:4.12',
mockito: 'org.mockito:mockito-core:1.9.5', mockito: 'org.mockito:mockito-core:1.9.5',
truth: 'com.google.truth:truth:0.36', truth: 'com.google.truth:truth:0.36',
guava_testlib: 'com.google.guava:guava-testlib:20.0', guava_testlib: 'com.google.guava:guava-testlib:20.0',
// Benchmark dependencies // Benchmark dependencies
hdrhistogram: 'org.hdrhistogram:HdrHistogram:2.1.10', hdrhistogram: 'org.hdrhistogram:HdrHistogram:2.1.10',
math: 'org.apache.commons:commons-math3:3.6', math: 'org.apache.commons:commons-math3:3.6',
// Jetty ALPN dependencies // Jetty ALPN dependencies
jetty_alpn_agent: 'org.mortbay.jetty.alpn:jetty-alpn-agent:2.0.7' jetty_alpn_agent: 'org.mortbay.jetty.alpn:jetty-alpn-agent:2.0.7'
] ]
} }
@ -242,7 +246,10 @@ subprojects {
compile { compile {
// Detect Maven Enforcer's dependencyConvergence failures. We only // Detect Maven Enforcer's dependencyConvergence failures. We only
// care for artifacts used as libraries by others. // care for artifacts used as libraries by others.
if (!(project.name in ['grpc-benchmarks', 'grpc-interop-testing'])) { if (!(project.name in [
'grpc-benchmarks',
'grpc-interop-testing'
])) {
resolutionStrategy.failOnVersionConflict() resolutionStrategy.failOnVersionConflict()
} }
} }
@ -250,14 +257,14 @@ subprojects {
dependencies { dependencies {
testCompile libraries.junit, testCompile libraries.junit,
libraries.mockito, libraries.mockito,
libraries.truth libraries.truth
// Configuration for modules that use Jetty ALPN agent // Configuration for modules that use Jetty ALPN agent
alpnagent libraries.jetty_alpn_agent alpnagent libraries.jetty_alpn_agent
jmh 'org.openjdk.jmh:jmh-core:1.19', jmh 'org.openjdk.jmh:jmh-core:1.19',
'org.openjdk.jmh:jmh-generator-bytecode:1.19' 'org.openjdk.jmh:jmh-generator-bytecode:1.19'
} }
signing { signing {
@ -267,11 +274,11 @@ subprojects {
// Disable JavaDoc doclint on Java 8. It's annoying. // Disable JavaDoc doclint on Java 8. It's annoying.
if (JavaVersion.current().isJava8Compatible()) { if (JavaVersion.current().isJava8Compatible()) {
allprojects { allprojects {
tasks.withType(Javadoc) { tasks.withType(Javadoc) {
options.addStringOption('Xdoclint:none', '-quiet') options.addStringOption('Xdoclint:none', '-quiet')
}
} }
}
} }
checkstyle { checkstyle {
@ -303,7 +310,9 @@ subprojects {
// depends on core; core's testCompile depends on testing) // depends on core; core's testCompile depends on testing)
includeTests = false includeTests = false
if (project.hasProperty('jmhIncludeSingleClass')) { if (project.hasProperty('jmhIncludeSingleClass')) {
include = [project.property('jmhIncludeSingleClass')] include = [
project.property('jmhIncludeSingleClass')
]
} }
} }
@ -317,36 +326,34 @@ subprojects {
from sourceSets.main.allSource from sourceSets.main.allSource
} }
artifacts { artifacts { archives javadocJar, sourcesJar }
archives javadocJar, sourcesJar
}
uploadArchives.repositories.mavenDeployer { uploadArchives.repositories.mavenDeployer {
beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) } beforeDeployment { MavenDeployment deployment -> signing.signPom(deployment) }
if (rootProject.hasProperty('repositoryDir')) { if (rootProject.hasProperty('repositoryDir')) {
repository(url: new File(rootProject.repositoryDir).toURI()) repository(url: new File(rootProject.repositoryDir).toURI())
} else { } else {
String stagingUrl String stagingUrl
if (rootProject.hasProperty('repositoryId')) { if (rootProject.hasProperty('repositoryId')) {
stagingUrl = 'https://oss.sonatype.org/service/local/staging/deployByRepositoryId/' + stagingUrl = 'https://oss.sonatype.org/service/local/staging/deployByRepositoryId/' +
rootProject.repositoryId rootProject.repositoryId
} else { } else {
stagingUrl = 'https://oss.sonatype.org/service/local/staging/deploy/maven2/' stagingUrl = 'https://oss.sonatype.org/service/local/staging/deploy/maven2/'
}
def configureAuth = {
if (rootProject.hasProperty('ossrhUsername') && rootProject.hasProperty('ossrhPassword')) {
authentication(userName: rootProject.ossrhUsername, password: rootProject.ossrhPassword)
} }
} def configureAuth = {
repository(url: stagingUrl, configureAuth) if (rootProject.hasProperty('ossrhUsername') && rootProject.hasProperty('ossrhPassword')) {
snapshotRepository(url: 'https://oss.sonatype.org/content/repositories/snapshots/', configureAuth) authentication(userName: rootProject.ossrhUsername, password: rootProject.ossrhPassword)
}
}
repository(url: stagingUrl, configureAuth)
snapshotRepository(url: 'https://oss.sonatype.org/content/repositories/snapshots/', configureAuth)
} }
} }
uploadArchives.onlyIf { !name.contains("grpc-gae-interop-testing") } uploadArchives.onlyIf { !name.contains("grpc-gae-interop-testing") }
[ [
install.repositories.mavenInstaller, install.repositories.mavenInstaller,
uploadArchives.repositories.mavenDeployer, uploadArchives.repositories.mavenDeployer,
]*.pom*.whenConfigured { pom -> ]*.pom*.whenConfigured { pom ->
pom.project { pom.project {
name "$project.group:$project.name" name "$project.group:$project.name"
@ -379,12 +386,17 @@ subprojects {
} }
} }
if (!(project.name in if (!(project.name in
["grpc-stub", "grpc-protobuf", "grpc-protobuf-lite", "grpc-protobuf-nano"])) { [
def core = pom.dependencies.find {dep -> dep.artifactId == 'grpc-core'} "grpc-stub",
if (core != null) { "grpc-protobuf",
// Depend on specific version of grpc-core because internal package is unstable "grpc-protobuf-lite",
core.version = "[" + core.version + "]" "grpc-protobuf-nano"
} ])) {
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 + "]"
}
} }
} }
// At a test failure, log the stack trace to the console so that we don't // At a test failure, log the stack trace to the console so that we don't
@ -403,19 +415,19 @@ subprojects {
// Run with: ./gradlew japicmp --continue // Run with: ./gradlew japicmp --continue
def baselineGrpcVersion = '1.6.1' def baselineGrpcVersion = '1.6.1'
def publicApiSubprojects = [ def publicApiSubprojects = [
// TODO: uncomment after grpc-alts artifact is published. // TODO: uncomment after grpc-alts artifact is published.
// ':grpc-alts', // ':grpc-alts',
':grpc-auth', ':grpc-auth',
':grpc-context', ':grpc-context',
':grpc-core', ':grpc-core',
':grpc-grpclb', ':grpc-grpclb',
':grpc-netty', ':grpc-netty',
':grpc-okhttp', ':grpc-okhttp',
':grpc-protobuf', ':grpc-protobuf',
':grpc-protobuf-lite', ':grpc-protobuf-lite',
':grpc-protobuf-nano', ':grpc-protobuf-nano',
':grpc-stub', ':grpc-stub',
':grpc-testing', ':grpc-testing',
] ]
publicApiSubprojects.each { name -> publicApiSubprojects.each { name ->
@ -435,7 +447,7 @@ publicApiSubprojects.each { name ->
String depJar = "${project.name}-${baselineGrpcVersion}.jar" String depJar = "${project.name}-${baselineGrpcVersion}.jar"
Configuration configuration = configurations.detachedConfiguration( Configuration configuration = configurations.detachedConfiguration(
dependencies.create(depModule) dependencies.create(depModule)
) )
baselineArtifact = files(configuration.files).filter { baselineArtifact = files(configuration.files).filter {
it.name.equals(depJar) it.name.equals(depJar)
}.singleFile }.singleFile
@ -468,3 +480,15 @@ publicApiSubprojects.each { name ->
} }
} }
} }
// format checkers
apply plugin: "com.diffplug.gradle.spotless"
apply plugin: 'groovy'
spotless {
groovyGradle {
target '**/*.gradle'
greclipse()
indentWithSpaces()
paddedCell()
}
}

View File

@ -5,25 +5,21 @@ description = 'The protoc plugin for gRPC Java'
buildscript { buildscript {
repositories { repositories {
maven { maven { // The google mirror is less flaky than mavenCentral()
// The google mirror is less flaky than mavenCentral() url "https://maven-central.storage-download.googleapis.com/repos/central/data/" }
url "https://maven-central.storage-download.googleapis.com/repos/central/data/"
}
mavenLocal() mavenLocal()
} }
dependencies { dependencies { classpath libraries.protobuf_plugin }
classpath libraries.protobuf_plugin
}
} }
def artifactStagingPath = "$buildDir/artifacts" as File def artifactStagingPath = "$buildDir/artifacts" as File
// Adds space-delimited arguments from the environment variable env to the // Adds space-delimited arguments from the environment variable env to the
// argList. // argList.
def addEnvArgs = { env, argList -> def addEnvArgs = { env, argList ->
def value = System.getenv(env) def value = System.getenv(env)
if (value != null) { if (value != null) {
value.split(' +').each() { it -> argList.add(it) } value.split(' +').each() { it -> argList.add(it) }
} }
} }
// Adds corresponding "-l" option to the argList if libName is not found in // Adds corresponding "-l" option to the argList if libName is not found in
@ -32,10 +28,10 @@ def addEnvArgs = { env, argList ->
// order to get statically linked, otherwise we add the libraries through "-l" // order to get statically linked, otherwise we add the libraries through "-l"
// so that they can be searched for in default search paths. // so that they can be searched for in default search paths.
def addLibraryIfNotLinked = { libName, argList -> def addLibraryIfNotLinked = { libName, argList ->
def ldflags = System.env.LDFLAGS def ldflags = System.env.LDFLAGS
if (ldflags == null || !ldflags.contains('lib' + libName + '.a')) { if (ldflags == null || !ldflags.contains('lib' + libName + '.a')) {
argList.add('-l' + libName) argList.add('-l' + libName)
} }
} }
def String arch = rootProject.hasProperty('targetArch') ? rootProject.targetArch : osdetector.arch def String arch = rootProject.hasProperty('targetArch') ? rootProject.targetArch : osdetector.arch
@ -43,298 +39,281 @@ def boolean vcDisable = rootProject.hasProperty('vcDisable') ? rootProject.vcDis
def boolean usingVisualCpp // Whether VisualCpp is actually available and selected def boolean usingVisualCpp // Whether VisualCpp is actually available and selected
model { model {
toolChains { toolChains {
// If you have both VC and Gcc installed, VC will be selected, unless you // If you have both VC and Gcc installed, VC will be selected, unless you
// set 'vcDisable=true' // set 'vcDisable=true'
if (!vcDisable) { if (!vcDisable) {
visualCpp(VisualCpp) { visualCpp(VisualCpp) {
// Prefer vcvars-provided environment over registry-discovered environment // Prefer vcvars-provided environment over registry-discovered environment
def String vsDir = System.getenv("VSINSTALLDIR") def String vsDir = System.getenv("VSINSTALLDIR")
def String winDir = System.getenv("WindowsSdkDir") def String winDir = System.getenv("WindowsSdkDir")
if (vsDir != null && winDir != null) { if (vsDir != null && winDir != null) {
installDir = vsDir installDir = vsDir
windowsSdkDir = winDir windowsSdkDir = winDir
}
}
}
gcc(Gcc) {
target("ppcle_64")
target("aarch_64")
}
clang(Clang) {
} }
}
} }
gcc(Gcc) {
target("ppcle_64")
target("aarch_64")
}
clang(Clang) {
}
}
platforms { platforms {
x86_32 { x86_32 { architecture "x86" }
architecture "x86" x86_64 { architecture "x86_64" }
ppcle_64 { architecture "ppcle_64" }
aarch_64 { architecture "aarch_64" }
} }
x86_64 {
architecture "x86_64"
}
ppcle_64 {
architecture "ppcle_64"
}
aarch_64 {
architecture "aarch_64"
}
}
components { components {
java_plugin(NativeExecutableSpec) { java_plugin(NativeExecutableSpec) {
if (arch in ['x86_32', 'x86_64', 'ppcle_64', 'aarch_64']) { if (arch in [
// If arch is not within the defined platforms, we do not specify the 'x86_32',
// targetPlatform so that Gradle will choose what is appropriate. 'x86_64',
targetPlatform arch 'ppcle_64',
} 'aarch_64'
baseName "$protocPluginBaseName" ]) {
// If arch is not within the defined platforms, we do not specify the
// targetPlatform so that Gradle will choose what is appropriate.
targetPlatform arch
}
baseName "$protocPluginBaseName"
}
} }
}
binaries { binaries {
all { all {
if (toolChain in Gcc || toolChain in Clang) { if (toolChain in Gcc || toolChain in Clang) {
cppCompiler.define("GRPC_VERSION", version) cppCompiler.define("GRPC_VERSION", version)
cppCompiler.args "--std=c++0x" cppCompiler.args "--std=c++0x"
addEnvArgs("CXXFLAGS", cppCompiler.args) addEnvArgs("CXXFLAGS", cppCompiler.args)
addEnvArgs("CPPFLAGS", cppCompiler.args) addEnvArgs("CPPFLAGS", cppCompiler.args)
if (osdetector.os == "osx") { if (osdetector.os == "osx") {
cppCompiler.args "-mmacosx-version-min=10.7", "-stdlib=libc++" cppCompiler.args "-mmacosx-version-min=10.7", "-stdlib=libc++"
addLibraryIfNotLinked('protoc', linker.args) addLibraryIfNotLinked('protoc', linker.args)
addLibraryIfNotLinked('protobuf', linker.args) addLibraryIfNotLinked('protobuf', linker.args)
} else if (osdetector.os == "windows") { } else if (osdetector.os == "windows") {
linker.args "-static", "-lprotoc", "-lprotobuf", "-static-libgcc", "-static-libstdc++", linker.args "-static", "-lprotoc", "-lprotobuf", "-static-libgcc", "-static-libstdc++",
"-s" "-s"
} else { } else {
// Link protoc, protobuf, libgcc and libstdc++ statically. // Link protoc, protobuf, libgcc and libstdc++ statically.
// Link other (system) libraries dynamically. // Link other (system) libraries dynamically.
// Clang under OSX doesn't support these options. // Clang under OSX doesn't support these options.
linker.args "-Wl,-Bstatic", "-lprotoc", "-lprotobuf", "-static-libgcc", linker.args "-Wl,-Bstatic", "-lprotoc", "-lprotobuf", "-static-libgcc",
"-static-libstdc++", "-static-libstdc++",
"-Wl,-Bdynamic", "-lpthread", "-s" "-Wl,-Bdynamic", "-lpthread", "-s"
}
addEnvArgs("LDFLAGS", linker.args)
} else if (toolChain in VisualCpp) {
usingVisualCpp = true
cppCompiler.define("GRPC_VERSION", version)
cppCompiler.args "/EHsc", "/MT"
if (rootProject.hasProperty('vcProtobufInclude')) {
cppCompiler.args "/I${rootProject.vcProtobufInclude}"
}
linker.args "libprotobuf.lib", "libprotoc.lib"
if (rootProject.hasProperty('vcProtobufLibs')) {
linker.args "/LIBPATH:${rootProject.vcProtobufLibs}"
}
}
} }
addEnvArgs("LDFLAGS", linker.args)
} else if (toolChain in VisualCpp) {
usingVisualCpp = true
cppCompiler.define("GRPC_VERSION", version)
cppCompiler.args "/EHsc", "/MT"
if (rootProject.hasProperty('vcProtobufInclude')) {
cppCompiler.args "/I${rootProject.vcProtobufInclude}"
}
linker.args "libprotobuf.lib", "libprotoc.lib"
if (rootProject.hasProperty('vcProtobufLibs')) {
linker.args "/LIBPATH:${rootProject.vcProtobufLibs}"
}
}
} }
}
} }
configurations { configurations {
testLiteCompile testLiteCompile
testNanoCompile testNanoCompile
} }
dependencies { dependencies {
testCompile project(':grpc-protobuf'), testCompile project(':grpc-protobuf'),
project(':grpc-stub') project(':grpc-stub')
testLiteCompile project(':grpc-protobuf-lite'), testLiteCompile project(':grpc-protobuf-lite'),
project(':grpc-stub') project(':grpc-stub')
testNanoCompile project(':grpc-protobuf-nano'), testNanoCompile project(':grpc-protobuf-nano'),
project(':grpc-stub') project(':grpc-stub')
} }
sourceSets { sourceSets {
testLite { testLite {
proto { proto { setSrcDirs(['src/test/proto']) }
setSrcDirs(['src/test/proto'])
} }
} testNano {
testNano { proto { setSrcDirs(['src/test/proto']) }
proto {
setSrcDirs(['src/test/proto'])
} }
}
} }
compileTestJava { compileTestJava {
options.compilerArgs += [ options.compilerArgs += [
"-Xlint:-cast", "-Xlint:-cast",
"-XepExcludedPaths:.*/build/generated/source/proto/.*", "-XepExcludedPaths:.*/build/generated/source/proto/.*",
] ]
} }
compileTestLiteJava { compileTestLiteJava {
options.compilerArgs = compileTestJava.options.compilerArgs options.compilerArgs = compileTestJava.options.compilerArgs
// Protobuf-generated Lite produces quite a few warnings. // Protobuf-generated Lite produces quite a few warnings.
options.compilerArgs += ["-Xlint:-rawtypes", "-Xlint:-unchecked", "-Xlint:-fallthrough"] options.compilerArgs += [
"-Xlint:-rawtypes",
"-Xlint:-unchecked",
"-Xlint:-fallthrough"
]
} }
compileTestNanoJava { compileTestNanoJava {
options.compilerArgs = compileTestJava.options.compilerArgs options.compilerArgs = compileTestJava.options.compilerArgs
} }
protobuf { protobuf {
protoc { protoc {
if (project.hasProperty('protoc')) { if (project.hasProperty('protoc')) {
path = project.protoc path = project.protoc
} else { } else {
artifact = "com.google.protobuf:protoc:${protocVersion}" artifact = "com.google.protobuf:protoc:${protocVersion}"
}
}
plugins {
javalite {
if (project.hasProperty('protoc-gen-javalite')) {
path = project['protoc-gen-javalite']
} else {
artifact = libraries.protoc_lite
}
}
grpc {
path = javaPluginPath
}
}
generateProtoTasks {
all().each { task ->
task.dependsOn 'java_pluginExecutable'
task.inputs.file javaPluginPath
}
ofSourceSet('test')*.plugins {
grpc {}
}
ofSourceSet('testLite')*.each { task ->
task.builtins {
remove java
}
task.plugins {
javalite {}
grpc {
option 'lite'
} }
}
} }
ofSourceSet('testNano').each { task -> plugins {
task.builtins { javalite {
remove java if (project.hasProperty('protoc-gen-javalite')) {
javanano { path = project['protoc-gen-javalite']
option 'ignore_services=true' } else {
artifact = libraries.protoc_lite
}
}
grpc { path = javaPluginPath }
}
generateProtoTasks {
all().each { task ->
task.dependsOn 'java_pluginExecutable'
task.inputs.file javaPluginPath
}
ofSourceSet('test')*.plugins { grpc {} }
ofSourceSet('testLite')*.each { task ->
task.builtins { remove java }
task.plugins {
javalite {}
grpc { option 'lite' }
}
}
ofSourceSet('testNano').each { task ->
task.builtins {
remove java
javanano { option 'ignore_services=true' }
}
task.plugins { grpc { option 'nano' } }
} }
}
task.plugins {
grpc {
option 'nano'
}
}
} }
}
} }
checkstyleTestNano { checkstyleTestNano {
source = fileTree(dir: "src/testNano", include: "**/*.java") source = fileTree(dir: "src/testNano", include: "**/*.java")
} }
println "*** Building codegen requires Protobuf version ${protocVersion}" println "*** Building codegen requires Protobuf version ${protocVersion}"
println "*** Please refer to https://github.com/grpc/grpc-java/blob/master/COMPILING.md#how-to-build-code-generation-plugin" println "*** Please refer to https://github.com/grpc/grpc-java/blob/master/COMPILING.md#how-to-build-code-generation-plugin"
task buildArtifacts(type: Copy) { task buildArtifacts(type: Copy) {
dependsOn 'java_pluginExecutable' dependsOn 'java_pluginExecutable'
from("$buildDir/exe") { from("$buildDir/exe") {
if (osdetector.os != 'windows') { if (osdetector.os != 'windows') {
rename 'protoc-gen-grpc-java', '$0.exe' rename 'protoc-gen-grpc-java', '$0.exe'
}
} }
} into artifactStagingPath
into artifactStagingPath
} }
archivesBaseName = "$protocPluginBaseName" archivesBaseName = "$protocPluginBaseName"
artifacts { artifacts {
archives("$artifactStagingPath/java_plugin/${protocPluginBaseName}.exe" as File) { archives("$artifactStagingPath/java_plugin/${protocPluginBaseName}.exe" as File) {
classifier osdetector.os + "-" + arch classifier osdetector.os + "-" + arch
type "exe" type "exe"
extension "exe" extension "exe"
builtBy buildArtifacts builtBy buildArtifacts
} }
} }
// Exe files are skipped by Maven by default. Override it. // Exe files are skipped by Maven by default. Override it.
// Also skip jar files that is generated by the java plugin. // Also skip jar files that is generated by the java plugin.
[ [
install.repositories.mavenInstaller, install.repositories.mavenInstaller,
uploadArchives.repositories.mavenDeployer, uploadArchives.repositories.mavenDeployer,
]*.setFilter {artifact, file -> ]*.setFilter {artifact, file ->
! (file.getName().endsWith('jar') || file.getName().endsWith('jar.asc')) ! (file.getName().endsWith('jar') || file.getName().endsWith('jar.asc'))
} }
[ [
uploadArchives.repositories.mavenDeployer, uploadArchives.repositories.mavenDeployer,
]*.beforeDeployment { it -> ]*.beforeDeployment { it ->
if (!usingVisualCpp) { if (!usingVisualCpp) {
def ret = exec { def ret = exec {
executable 'bash' executable 'bash'
args 'check-artifact.sh', osdetector.os, arch args 'check-artifact.sh', osdetector.os, arch
}
if (ret.exitValue != 0) {
throw new GradleException("check-artifact.sh exited with " + ret.exitValue)
}
} else {
def exeName = "$artifactStagingPath/java_plugin/${protocPluginBaseName}.exe"
def os = new ByteArrayOutputStream()
def ret = exec {
executable 'dumpbin'
args '/nologo', '/dependents', exeName
standardOutput = os
}
if (ret.exitValue != 0) {
throw new GradleException("dumpbin exited with " + ret.exitValue)
}
def dlls = os.toString() =~ /Image has the following dependencies:\s+(.*)\s+Summary/
if (dlls[0][1] != "KERNEL32.dll") {
throw new Exception("unexpected dll deps: " + dlls[0][1]);
}
os.reset()
ret = exec {
executable 'dumpbin'
args '/nologo', '/headers', exeName
standardOutput = os
}
if (ret.exitValue != 0) {
throw new GradleException("dumpbin exited with " + ret.exitValue)
}
def machine = os.toString() =~ / machine \(([^)]+)\)/
def expectedArch = [x86_32: "x86", x86_64: "x64"][arch]
if (machine[0][1] != expectedArch) {
throw new Exception("unexpected architecture: " + machine[0][1]);
}
} }
if (ret.exitValue != 0) {
throw new GradleException("check-artifact.sh exited with " + ret.exitValue)
}
} else {
def exeName = "$artifactStagingPath/java_plugin/${protocPluginBaseName}.exe"
def os = new ByteArrayOutputStream()
def ret = exec {
executable 'dumpbin'
args '/nologo', '/dependents', exeName
standardOutput = os
}
if (ret.exitValue != 0) {
throw new GradleException("dumpbin exited with " + ret.exitValue)
}
def dlls = os.toString() =~ /Image has the following dependencies:\s+(.*)\s+Summary/
if (dlls[0][1] != "KERNEL32.dll") {
throw new Exception("unexpected dll deps: " + dlls[0][1]);
}
os.reset()
ret = exec {
executable 'dumpbin'
args '/nologo', '/headers', exeName
standardOutput = os
}
if (ret.exitValue != 0) {
throw new GradleException("dumpbin exited with " + ret.exitValue)
}
def machine = os.toString() =~ / machine \(([^)]+)\)/
def expectedArch = [x86_32: "x86", x86_64: "x64"][arch]
if (machine[0][1] != expectedArch) {
throw new Exception("unexpected architecture: " + machine[0][1]);
}
}
} }
[ [
install.repositories.mavenInstaller, install.repositories.mavenInstaller,
uploadArchives.repositories.mavenDeployer, uploadArchives.repositories.mavenDeployer,
]*.pom*.whenConfigured { pom -> ]*.pom*.whenConfigured { pom ->
pom.project { pom.project {
// This isn't any sort of Java archive artifact, and OSSRH doesn't enforce // This isn't any sort of Java archive artifact, and OSSRH doesn't enforce
// javadoc for 'pom' packages. 'exe' would be a more appropriate packaging // javadoc for 'pom' packages. 'exe' would be a more appropriate packaging
// value, but it isn't clear how that will be interpreted. In addition, // value, but it isn't clear how that will be interpreted. In addition,
// 'pom' is typically the value used when building an exe with Maven. // 'pom' is typically the value used when building an exe with Maven.
packaging = "pom" packaging = "pom"
} }
} }
def configureTestTask(Task task, String dep, String extraPackage) { def configureTestTask(Task task, String dep, String extraPackage) {
test.dependsOn task test.dependsOn task
task.dependsOn "generateTest${dep}Proto" task.dependsOn "generateTest${dep}Proto"
if (osdetector.os != 'windows') { if (osdetector.os != 'windows') {
task.executable "diff" task.executable "diff"
task.args "-u" task.args "-u"
} else { } else {
task.executable "fc" task.executable "fc"
} }
// File isn't found on Windows if last slash is forward-slash // File isn't found on Windows if last slash is forward-slash
def slash = System.getProperty("file.separator") def slash = System.getProperty("file.separator")
task.args "$buildDir/generated/source/proto/test${dep}/grpc/io/grpc/testing/compiler${extraPackage}${slash}TestServiceGrpc.java", task.args "$buildDir/generated/source/proto/test${dep}/grpc/io/grpc/testing/compiler${extraPackage}${slash}TestServiceGrpc.java",
"$projectDir/src/test${dep}/golden/TestService.java.txt" "$projectDir/src/test${dep}/golden/TestService.java.txt"
} }
task testGolden(type: Exec) task testGolden(type: Exec)

View File

@ -28,7 +28,7 @@ dependencies {
} }
testCompile project(':grpc-context').sourceSets.test.output, testCompile project(':grpc-context').sourceSets.test.output,
project(':grpc-testing') project(':grpc-testing')
signature "org.codehaus.mojo.signature:java16:1.1@signature" signature "org.codehaus.mojo.signature:java16:1.1@signature"
} }
@ -41,5 +41,8 @@ javadoc {
animalsniffer { animalsniffer {
// Don't check sourceSets.jmh // Don't check sourceSets.jmh
sourceSets = [sourceSets.main, sourceSets.test] sourceSets = [
sourceSets.main,
sourceSets.test
]
} }

View File

@ -7,9 +7,7 @@ buildscript {
google() google()
jcenter() jcenter()
} }
dependencies { dependencies { classpath 'com.android.tools.build:gradle:3.0.1' }
classpath 'com.android.tools.build:gradle:3.0.1'
}
} }
allprojects { allprojects {
@ -30,22 +28,14 @@ android {
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
} }
buildTypes { buildTypes {
debug { debug { minifyEnabled false }
minifyEnabled false
}
release { release {
minifyEnabled true minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
} }
} }
testOptions { testOptions { unitTests { includeAndroidResources = true } }
unitTests { lintOptions { disable 'InvalidPackage' }
includeAndroidResources = true
}
}
lintOptions {
disable 'InvalidPackage'
}
} }
dependencies { dependencies {

View File

@ -14,9 +14,7 @@ android {
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
} }
buildTypes { buildTypes {
debug { debug { minifyEnabled false }
minifyEnabled false
}
release { release {
minifyEnabled true minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
@ -30,25 +28,18 @@ android {
} }
protobuf { protobuf {
protoc { protoc { artifact = 'com.google.protobuf:protoc:3.4.0' }
artifact = 'com.google.protobuf:protoc:3.4.0'
}
plugins { plugins {
javalite { javalite { artifact = "com.google.protobuf:protoc-gen-javalite:3.0.0" }
artifact = "com.google.protobuf:protoc-gen-javalite:3.0.0" grpc { artifact = 'io.grpc:protoc-gen-grpc-java:1.14.0-SNAPSHOT' // CURRENT_GRPC_VERSION
}
grpc {
artifact = 'io.grpc:protoc-gen-grpc-java:1.14.0-SNAPSHOT' // CURRENT_GRPC_VERSION
} }
} }
generateProtoTasks { generateProtoTasks {
all().each { task -> all().each { task ->
task.plugins { task.plugins {
javalite {} javalite {}
grpc { grpc { // Options added to --grpc_out
// Options added to --grpc_out option 'lite' }
option 'lite'
}
} }
} }
} }

View File

@ -13,9 +13,7 @@ android {
versionName "1.0" versionName "1.0"
} }
buildTypes { buildTypes {
debug { debug { minifyEnabled false }
minifyEnabled false
}
release { release {
minifyEnabled true minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
@ -29,25 +27,18 @@ android {
} }
protobuf { protobuf {
protoc { protoc { artifact = 'com.google.protobuf:protoc:3.5.1-1' }
artifact = 'com.google.protobuf:protoc:3.5.1-1'
}
plugins { plugins {
javalite { javalite { artifact = "com.google.protobuf:protoc-gen-javalite:3.0.0" }
artifact = "com.google.protobuf:protoc-gen-javalite:3.0.0" grpc { artifact = 'io.grpc:protoc-gen-grpc-java:1.14.0-SNAPSHOT' // CURRENT_GRPC_VERSION
}
grpc {
artifact = 'io.grpc:protoc-gen-grpc-java:1.14.0-SNAPSHOT' // CURRENT_GRPC_VERSION
} }
} }
generateProtoTasks { generateProtoTasks {
all().each { task -> all().each { task ->
task.plugins { task.plugins {
javalite {} javalite {}
grpc { grpc { // Options added to --grpc_out
// Options added to --grpc_out option 'lite' }
option 'lite'
}
} }
} }
} }

View File

@ -5,16 +5,14 @@ android {
compileSdkVersion 27 compileSdkVersion 27
defaultConfig { defaultConfig {
applicationId "io.grpc.routeguideexample" applicationId "io.grpc.routeguideexample"
minSdkVersion 14 minSdkVersion 14
targetSdkVersion 27 targetSdkVersion 27
versionCode 1 versionCode 1
versionName "1.0" versionName "1.0"
} }
buildTypes { buildTypes {
debug { debug { minifyEnabled false }
minifyEnabled false
}
release { release {
minifyEnabled true minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
@ -28,25 +26,18 @@ android {
} }
protobuf { protobuf {
protoc { protoc { artifact = 'com.google.protobuf:protoc:3.5.1-1' }
artifact = 'com.google.protobuf:protoc:3.5.1-1'
}
plugins { plugins {
javalite { javalite { artifact = "com.google.protobuf:protoc-gen-javalite:3.0.0" }
artifact = "com.google.protobuf:protoc-gen-javalite:3.0.0" grpc { artifact = 'io.grpc:protoc-gen-grpc-java:1.14.0-SNAPSHOT' // CURRENT_GRPC_VERSION
}
grpc {
artifact = 'io.grpc:protoc-gen-grpc-java:1.14.0-SNAPSHOT' // CURRENT_GRPC_VERSION
} }
} }
generateProtoTasks { generateProtoTasks {
all().each { task -> all().each { task ->
task.plugins { task.plugins {
javalite {} javalite {}
grpc { grpc { // Options added to --grpc_out
// Options added to --grpc_out option 'lite' }
option 'lite'
}
} }
} }
} }

View File

@ -22,6 +22,4 @@ allprojects {
} }
} }
task clean(type: Delete) { task clean(type: Delete) { delete rootProject.buildDir }
delete rootProject.buildDir
}

View File

@ -2,25 +2,19 @@ apply plugin: 'java'
apply plugin: 'com.google.protobuf' apply plugin: 'com.google.protobuf'
buildscript { buildscript {
repositories { repositories {
maven { maven { // The google mirror is less flaky than mavenCentral()
// The google mirror is less flaky than mavenCentral() url "https://maven-central.storage-download.googleapis.com/repos/central/data/" }
url "https://maven-central.storage-download.googleapis.com/repos/central/data/"
} }
} dependencies { // ASSUMES GRADLE 2.12 OR HIGHER. Use plugin version 0.7.5 with earlier
dependencies { // gradle versions
// ASSUMES GRADLE 2.12 OR HIGHER. Use plugin version 0.7.5 with earlier classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.3' }
// gradle versions
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.3'
}
} }
repositories { repositories {
maven { maven { // The google mirror is less flaky than mavenCentral()
// The google mirror is less flaky than mavenCentral() url "https://maven-central.storage-download.googleapis.com/repos/central/data/" }
url "https://maven-central.storage-download.googleapis.com/repos/central/data/" mavenLocal()
}
mavenLocal()
} }
// IMPORTANT: You probably want the non-SNAPSHOT version of gRPC. Make sure you // IMPORTANT: You probably want the non-SNAPSHOT version of gRPC. Make sure you
@ -34,37 +28,31 @@ def protobufVersion = '3.5.1'
def protocVersion = '3.5.1-1' def protocVersion = '3.5.1-1'
dependencies { dependencies {
compile "com.google.api.grpc:proto-google-common-protos:1.0.0" compile "com.google.api.grpc:proto-google-common-protos:1.0.0"
compile "io.grpc:grpc-alts:${grpcVersion}" compile "io.grpc:grpc-alts:${grpcVersion}"
compile "io.grpc:grpc-netty:${grpcVersion}" compile "io.grpc:grpc-netty:${grpcVersion}"
compile "io.grpc:grpc-protobuf:${grpcVersion}" compile "io.grpc:grpc-protobuf:${grpcVersion}"
compile "io.grpc:grpc-stub:${grpcVersion}" compile "io.grpc:grpc-stub:${grpcVersion}"
compileOnly "javax.annotation:javax.annotation-api:1.2" compileOnly "javax.annotation:javax.annotation-api:1.2"
// Used for TLS in HelloWorldServerTls // Used for TLS in HelloWorldServerTls
compile "io.netty:netty-tcnative-boringssl-static:${nettyTcNativeVersion}" compile "io.netty:netty-tcnative-boringssl-static:${nettyTcNativeVersion}"
compile "com.google.protobuf:protobuf-java-util:${protobufVersion}" compile "com.google.protobuf:protobuf-java-util:${protobufVersion}"
testCompile "io.grpc:grpc-testing:${grpcVersion}" testCompile "io.grpc:grpc-testing:${grpcVersion}"
testCompile "junit:junit:4.12" testCompile "junit:junit:4.12"
testCompile "org.mockito:mockito-core:1.9.5" testCompile "org.mockito:mockito-core:1.9.5"
} }
protobuf { protobuf {
protoc { protoc { artifact = "com.google.protobuf:protoc:${protocVersion}" }
artifact = "com.google.protobuf:protoc:${protocVersion}" plugins {
} grpc { artifact = "io.grpc:protoc-gen-grpc-java:${grpcVersion}" }
plugins {
grpc {
artifact = "io.grpc:protoc-gen-grpc-java:${grpcVersion}"
} }
} generateProtoTasks {
generateProtoTasks { all()*.plugins { grpc {} }
all()*.plugins {
grpc {}
} }
}
} }
// Inform IDEs like IntelliJ IDEA, Eclipse or NetBeans about the generated code. // Inform IDEs like IntelliJ IDEA, Eclipse or NetBeans about the generated code.
@ -86,77 +74,77 @@ apply plugin: 'application'
startScripts.enabled = false startScripts.enabled = false
task routeGuideServer(type: CreateStartScripts) { task routeGuideServer(type: CreateStartScripts) {
mainClassName = 'io.grpc.examples.routeguide.RouteGuideServer' mainClassName = 'io.grpc.examples.routeguide.RouteGuideServer'
applicationName = 'route-guide-server' applicationName = 'route-guide-server'
outputDir = new File(project.buildDir, 'tmp') outputDir = new File(project.buildDir, 'tmp')
classpath = jar.outputs.files + project.configurations.runtime classpath = jar.outputs.files + project.configurations.runtime
} }
task routeGuideClient(type: CreateStartScripts) { task routeGuideClient(type: CreateStartScripts) {
mainClassName = 'io.grpc.examples.routeguide.RouteGuideClient' mainClassName = 'io.grpc.examples.routeguide.RouteGuideClient'
applicationName = 'route-guide-client' applicationName = 'route-guide-client'
outputDir = new File(project.buildDir, 'tmp') outputDir = new File(project.buildDir, 'tmp')
classpath = jar.outputs.files + project.configurations.runtime classpath = jar.outputs.files + project.configurations.runtime
} }
task helloWorldServer(type: CreateStartScripts) { task helloWorldServer(type: CreateStartScripts) {
mainClassName = 'io.grpc.examples.helloworld.HelloWorldServer' mainClassName = 'io.grpc.examples.helloworld.HelloWorldServer'
applicationName = 'hello-world-server' applicationName = 'hello-world-server'
outputDir = new File(project.buildDir, 'tmp') outputDir = new File(project.buildDir, 'tmp')
classpath = jar.outputs.files + project.configurations.runtime classpath = jar.outputs.files + project.configurations.runtime
} }
task helloWorldClient(type: CreateStartScripts) { task helloWorldClient(type: CreateStartScripts) {
mainClassName = 'io.grpc.examples.helloworld.HelloWorldClient' mainClassName = 'io.grpc.examples.helloworld.HelloWorldClient'
applicationName = 'hello-world-client' applicationName = 'hello-world-client'
outputDir = new File(project.buildDir, 'tmp') outputDir = new File(project.buildDir, 'tmp')
classpath = jar.outputs.files + project.configurations.runtime classpath = jar.outputs.files + project.configurations.runtime
} }
task helloWorldAltsServer(type: CreateStartScripts) { task helloWorldAltsServer(type: CreateStartScripts) {
mainClassName = 'io.grpc.examples.alts.HelloWorldAltsServer' mainClassName = 'io.grpc.examples.alts.HelloWorldAltsServer'
applicationName = 'hello-world-alts-server' applicationName = 'hello-world-alts-server'
outputDir = new File(project.buildDir, 'tmp') outputDir = new File(project.buildDir, 'tmp')
classpath = jar.outputs.files + project.configurations.runtime classpath = jar.outputs.files + project.configurations.runtime
} }
task helloWorldAltsClient(type: CreateStartScripts) { task helloWorldAltsClient(type: CreateStartScripts) {
mainClassName = 'io.grpc.examples.alts.HelloWorldAltsClient' mainClassName = 'io.grpc.examples.alts.HelloWorldAltsClient'
applicationName = 'hello-world-alts-client' applicationName = 'hello-world-alts-client'
outputDir = new File(project.buildDir, 'tmp') outputDir = new File(project.buildDir, 'tmp')
classpath = jar.outputs.files + project.configurations.runtime classpath = jar.outputs.files + project.configurations.runtime
} }
task helloWorldTlsServer(type: CreateStartScripts) { task helloWorldTlsServer(type: CreateStartScripts) {
mainClassName = 'io.grpc.examples.helloworldtls.HelloWorldServerTls' mainClassName = 'io.grpc.examples.helloworldtls.HelloWorldServerTls'
applicationName = 'hello-world-tls-server' applicationName = 'hello-world-tls-server'
outputDir = new File(project.buildDir, 'tmp') outputDir = new File(project.buildDir, 'tmp')
classpath = jar.outputs.files + project.configurations.runtime classpath = jar.outputs.files + project.configurations.runtime
} }
task helloWorldTlsClient(type: CreateStartScripts) { task helloWorldTlsClient(type: CreateStartScripts) {
mainClassName = 'io.grpc.examples.helloworldtls.HelloWorldClientTls' mainClassName = 'io.grpc.examples.helloworldtls.HelloWorldClientTls'
applicationName = 'hello-world-tls-client' applicationName = 'hello-world-tls-client'
outputDir = new File(project.buildDir, 'tmp') outputDir = new File(project.buildDir, 'tmp')
classpath = jar.outputs.files + project.configurations.runtime classpath = jar.outputs.files + project.configurations.runtime
} }
task compressingHelloWorldClient(type: CreateStartScripts) { task compressingHelloWorldClient(type: CreateStartScripts) {
mainClassName = 'io.grpc.examples.experimental.CompressingHelloWorldClient' mainClassName = 'io.grpc.examples.experimental.CompressingHelloWorldClient'
applicationName = 'compressing-hello-world-client' applicationName = 'compressing-hello-world-client'
outputDir = new File(project.buildDir, 'tmp') outputDir = new File(project.buildDir, 'tmp')
classpath = jar.outputs.files + project.configurations.runtime classpath = jar.outputs.files + project.configurations.runtime
} }
applicationDistribution.into('bin') { applicationDistribution.into('bin') {
from(routeGuideServer) from(routeGuideServer)
from(routeGuideClient) from(routeGuideClient)
from(helloWorldServer) from(helloWorldServer)
from(helloWorldClient) from(helloWorldClient)
from(helloWorldAltsServer) from(helloWorldAltsServer)
from(helloWorldAltsClient) from(helloWorldAltsClient)
from(helloWorldTlsServer) from(helloWorldTlsServer)
from(helloWorldTlsClient) from(helloWorldTlsClient)
from(compressingHelloWorldClient) from(compressingHelloWorldClient)
fileMode = 0755 fileMode = 0755
} }

View File

@ -15,9 +15,7 @@ android {
versionName "1.0" versionName "1.0"
} }
buildTypes { buildTypes {
debug { debug { minifyEnabled false }
minifyEnabled false
}
release { release {
minifyEnabled true minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
@ -51,25 +49,18 @@ android {
} }
protobuf { protobuf {
protoc { protoc { artifact = 'com.google.protobuf:protoc:3.5.1-1' }
artifact = 'com.google.protobuf:protoc:3.5.1-1'
}
plugins { plugins {
javalite { javalite { artifact = "com.google.protobuf:protoc-gen-javalite:3.0.0" }
artifact = "com.google.protobuf:protoc-gen-javalite:3.0.0" grpc { artifact = 'io.grpc:protoc-gen-grpc-java:1.14.0-SNAPSHOT' // CURRENT_GRPC_VERSION
}
grpc {
artifact = 'io.grpc:protoc-gen-grpc-java:1.14.0-SNAPSHOT' // CURRENT_GRPC_VERSION
} }
} }
generateProtoTasks { generateProtoTasks {
all().each { task -> all().each { task ->
task.plugins { task.plugins {
javalite {} javalite {}
grpc { grpc { // Options added to --grpc_out
// Options added to --grpc_out option 'lite' }
option 'lite'
}
} }
} }
} }
@ -86,6 +77,4 @@ dependencies {
compile 'io.grpc:grpc-stub:1.14.0-SNAPSHOT' // CURRENT_GRPC_VERSION compile 'io.grpc:grpc-stub:1.14.0-SNAPSHOT' // CURRENT_GRPC_VERSION
} }
repositories { repositories { mavenCentral() }
mavenCentral()
}

View File

@ -13,21 +13,21 @@ apply plugin: 'application'
buildscript { buildscript {
ext.kotlin_version = '1.2.21' ext.kotlin_version = '1.2.21'
repositories { repositories {
mavenCentral() mavenCentral()
mavenLocal() mavenLocal()
} }
dependencies { dependencies {
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.5' classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.5'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
} }
} }
repositories { repositories {
mavenCentral() mavenCentral()
mavenLocal() mavenLocal()
} }
// IMPORTANT: You probably want the non-SNAPSHOT version of gRPC. Make sure you // IMPORTANT: You probably want the non-SNAPSHOT version of gRPC. Make sure you
@ -38,51 +38,45 @@ repositories {
def grpcVersion = '1.14.0-SNAPSHOT' // CURRENT_GRPC_VERSION def grpcVersion = '1.14.0-SNAPSHOT' // CURRENT_GRPC_VERSION
dependencies { dependencies {
compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version" compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
compile "com.google.api.grpc:proto-google-common-protos:1.0.0" compile "com.google.api.grpc:proto-google-common-protos:1.0.0"
compile "io.grpc:grpc-netty:${grpcVersion}" compile "io.grpc:grpc-netty:${grpcVersion}"
compile "io.grpc:grpc-protobuf:${grpcVersion}" compile "io.grpc:grpc-protobuf:${grpcVersion}"
compile "io.grpc:grpc-stub:${grpcVersion}" compile "io.grpc:grpc-stub:${grpcVersion}"
testCompile "io.grpc:grpc-testing:${grpcVersion}" // gRCP testing utilities testCompile "io.grpc:grpc-testing:${grpcVersion}" // gRCP testing utilities
testCompile "junit:junit:4.12" testCompile "junit:junit:4.12"
testCompile "org.mockito:mockito-core:1.9.5" testCompile "org.mockito:mockito-core:1.9.5"
} }
protobuf { protobuf {
protoc { protoc { artifact = 'com.google.protobuf:protoc:3.5.1-1' }
artifact = 'com.google.protobuf:protoc:3.5.1-1' plugins {
} grpc { artifact = "io.grpc:protoc-gen-grpc-java:${grpcVersion}" }
plugins {
grpc {
artifact = "io.grpc:protoc-gen-grpc-java:${grpcVersion}"
} }
} generateProtoTasks {
generateProtoTasks { all()*.plugins { grpc {} }
all()*.plugins {
grpc {}
} }
}
} }
startScripts.enabled = false startScripts.enabled = false
task helloWorldServer(type: CreateStartScripts) { task helloWorldServer(type: CreateStartScripts) {
mainClassName = 'io.grpc.examples.helloworld.HelloWorldServer' mainClassName = 'io.grpc.examples.helloworld.HelloWorldServer'
applicationName = 'hello-world-server' applicationName = 'hello-world-server'
outputDir = new File(project.buildDir, 'tmp') outputDir = new File(project.buildDir, 'tmp')
classpath = jar.outputs.files + project.configurations.runtime classpath = jar.outputs.files + project.configurations.runtime
} }
task helloWorldClient(type: CreateStartScripts) { task helloWorldClient(type: CreateStartScripts) {
mainClassName = 'io.grpc.examples.helloworld.HelloWorldClient' mainClassName = 'io.grpc.examples.helloworld.HelloWorldClient'
applicationName = 'hello-world-client' applicationName = 'hello-world-client'
outputDir = new File(project.buildDir, 'tmp') outputDir = new File(project.buildDir, 'tmp')
classpath = jar.outputs.files + project.configurations.runtime classpath = jar.outputs.files + project.configurations.runtime
} }
applicationDistribution.into('bin') { applicationDistribution.into('bin') {
from(helloWorldServer) from(helloWorldServer)
from(helloWorldClient) from(helloWorldClient)
fileMode = 0755 fileMode = 0755
} }

View File

@ -13,27 +13,25 @@
// limitations under the License. // limitations under the License.
description = 'gRPC: gae interop testing (jdk7)' description = 'gRPC: gae interop testing (jdk7)'
buildscript { // Configuration for building buildscript {
repositories { // Configuration for building
jcenter() // Bintray's repository - a fast Maven Central mirror & more repositories {
maven { jcenter() // Bintray's repository - a fast Maven Central mirror & more
// The google mirror is less flaky than mavenCentral() maven { // The google mirror is less flaky than mavenCentral()
url "https://maven-central.storage-download.googleapis.com/repos/central/data/" url "https://maven-central.storage-download.googleapis.com/repos/central/data/" }
}
dependencies {
classpath 'com.google.cloud.tools:appengine-gradle-plugin:1.3.5'
classpath 'com.squareup.okhttp:okhttp:2.5.0'
} }
}
dependencies {
classpath 'com.google.cloud.tools:appengine-gradle-plugin:1.3.5'
classpath 'com.squareup.okhttp:okhttp:2.5.0'
}
} }
repositories { // repositories for Jar's you access in your code repositories {
mavenLocal() // repositories for Jar's you access in your code
maven { mavenLocal()
// The google mirror is less flaky than mavenCentral() maven { // The google mirror is less flaky than mavenCentral()
url "https://maven-central.storage-download.googleapis.com/repos/central/data/" url "https://maven-central.storage-download.googleapis.com/repos/central/data/" }
} jcenter()
jcenter()
} }
apply plugin: 'java' // standard Java tasks apply plugin: 'java' // standard Java tasks
@ -41,34 +39,36 @@ apply plugin: 'war' // standard Web Archive plugin
apply plugin: 'com.google.cloud.tools.appengine' // App Engine tasks apply plugin: 'com.google.cloud.tools.appengine' // App Engine tasks
dependencies { dependencies {
providedCompile group: 'javax.servlet', name: 'servlet-api', version:'2.5' providedCompile group: 'javax.servlet', name: 'servlet-api', version:'2.5'
compile 'com.google.appengine:appengine-api-1.0-sdk:1.9.59' compile 'com.google.appengine:appengine-api-1.0-sdk:1.9.59'
// Deps needed by all gRPC apps in GAE // Deps needed by all gRPC apps in GAE
compile libraries.google_api_protos compile libraries.google_api_protos
compile project(":grpc-okhttp") compile project(":grpc-okhttp")
compile project(":grpc-protobuf") compile project(":grpc-protobuf")
compile project(":grpc-stub") compile project(":grpc-stub")
compile (project(":grpc-interop-testing")) { compile (project(":grpc-interop-testing")) {
exclude group: 'io.opencensus', module: 'opencensus-impl' exclude group: 'io.opencensus', module: 'opencensus-impl'
} }
// The lite version of opencensus is required for jdk7 GAE // The lite version of opencensus is required for jdk7 GAE
runtime libraries.opencensus_impl_lite runtime libraries.opencensus_impl_lite
} }
// [START model] // [START model]
appengine { // App Engine tasks configuration appengine {
run { // local (dev_appserver) configuration (standard environments only) // App Engine tasks configuration
port = 8080 // default run { // local (dev_appserver) configuration (standard environments only)
} port = 8080 // default
}
deploy { // deploy configuration deploy {
// default - stop the current version // deploy configuration
stopPreviousVersion = System.getProperty('gaeStopPreviousVersion') ?: true // default - stop the current version
// default - make this the current version stopPreviousVersion = System.getProperty('gaeStopPreviousVersion') ?: true
promote = System.getProperty('gaePromote') ?: true // default - make this the current version
// Use -DgaeDeployVersion if set, otherwise the version is null and the plugin will generate it promote = System.getProperty('gaePromote') ?: true
version = System.getProperty('gaeDeployVersion') // Use -DgaeDeployVersion if set, otherwise the version is null and the plugin will generate it
} version = System.getProperty('gaeDeployVersion')
}
} }
// [END model] // [END model]
@ -80,65 +80,69 @@ targetCompatibility = 1.7
/** Returns the service name. */ /** Returns the service name. */
String getGaeProject() { String getGaeProject() {
def stream = new ByteArrayOutputStream() def stream = new ByteArrayOutputStream()
exec { exec {
executable 'gcloud' executable 'gcloud'
args = ['config', 'get-value', 'project'] args = [
standardOutput = stream 'config',
} 'get-value',
return stream.toString().trim() 'project'
]
standardOutput = stream
}
return stream.toString().trim()
} }
String getService(java.nio.file.Path projectPath) { String getService(java.nio.file.Path projectPath) {
Node xml = new XmlParser().parse(projectPath.resolve("src/main/webapp/WEB-INF/appengine-web.xml").toFile()) Node xml = new XmlParser().parse(projectPath.resolve("src/main/webapp/WEB-INF/appengine-web.xml").toFile())
if (xml.service.isEmpty()) { if (xml.service.isEmpty()) {
return null return null
} else { } else {
return xml.service.text() return xml.service.text()
} }
} }
String getAppUrl(String project, String service, String version) { String getAppUrl(String project, String service, String version) {
if (version != null && service != null) { if (version != null && service != null) {
return "http://${version}.${service}.${project}.appspot.com" return "http://${version}.${service}.${project}.appspot.com"
} else { } else {
return "http://${project}.appspot.com" return "http://${project}.appspot.com"
} }
} }
task runInteropTestRemote(dependsOn: 'appengineDeploy') { task runInteropTestRemote(dependsOn: 'appengineDeploy') {
doLast { doLast {
// give remote app some time to settle down // give remote app some time to settle down
sleep(20000) sleep(20000)
def appUrl = getAppUrl( def appUrl = getAppUrl(
getGaeProject(), getGaeProject(),
getService(project.getProjectDir().toPath()), getService(project.getProjectDir().toPath()),
System.getProperty('gaeDeployVersion')) System.getProperty('gaeDeployVersion'))
logger.log(LogLevel.INFO, "the appURL=" + appUrl) logger.log(LogLevel.INFO, "the appURL=" + appUrl)
def client = new com.squareup.okhttp.OkHttpClient() def client = new com.squareup.okhttp.OkHttpClient()
// The test suite can take a while to run // The test suite can take a while to run
client.setReadTimeout(3, java.util.concurrent.TimeUnit.MINUTES) client.setReadTimeout(3, java.util.concurrent.TimeUnit.MINUTES)
// The '?jdk8' argument is ignored by the server, it exists only to tag the request log entry // The '?jdk8' argument is ignored by the server, it exists only to tag the request log entry
def interopRequest = new com.squareup.okhttp.Request.Builder() def interopRequest = new com.squareup.okhttp.Request.Builder()
.url("${appUrl}/?jdk7").build() .url("${appUrl}/?jdk7").build()
// Retry in case GAE is slow and times out // Retry in case GAE is slow and times out
int maxRetries = 5 int maxRetries = 5
String result = null String result = null
Throwable caught = null Throwable caught = null
for (int attempt = 0; attempt < maxRetries; attempt++) { for (int attempt = 0; attempt < maxRetries; attempt++) {
try { try {
def response = client.newCall(interopRequest).execute() def response = client.newCall(interopRequest).execute()
result = response.body().string() result = response.body().string()
if (response.code() == 200) { if (response.code() == 200) {
return return
}
} catch (Throwable t) {
caught = t
logger.log(LogLevel.ERROR, "caught exception. will retry if possible", t)
}
} }
} catch (Throwable t) { throw new GradleException("Interop test failed:\nresponse: ${result}\nthrowable:${caught}")
caught = t
logger.log(LogLevel.ERROR, "caught exception. will retry if possible", t)
}
} }
throw new GradleException("Interop test failed:\nresponse: ${result}\nthrowable:${caught}")
}
} }

View File

@ -13,27 +13,25 @@
// limitations under the License. // limitations under the License.
description = 'gRPC: gae interop testing (jdk8)' description = 'gRPC: gae interop testing (jdk8)'
buildscript { // Configuration for building buildscript {
repositories { // Configuration for building
jcenter() // Bintray's repository - a fast Maven Central mirror & more repositories {
maven { jcenter() // Bintray's repository - a fast Maven Central mirror & more
// The google mirror is less flaky than mavenCentral() maven { // The google mirror is less flaky than mavenCentral()
url "https://maven-central.storage-download.googleapis.com/repos/central/data/" url "https://maven-central.storage-download.googleapis.com/repos/central/data/" }
}
dependencies {
classpath 'com.google.cloud.tools:appengine-gradle-plugin:1.3.5'
classpath 'com.squareup.okhttp:okhttp:2.5.0'
} }
}
dependencies {
classpath 'com.google.cloud.tools:appengine-gradle-plugin:1.3.5'
classpath 'com.squareup.okhttp:okhttp:2.5.0'
}
} }
repositories { // repositories for Jar's you access in your code repositories {
mavenLocal() // repositories for Jar's you access in your code
maven { mavenLocal()
// The google mirror is less flaky than mavenCentral() maven { // The google mirror is less flaky than mavenCentral()
url "https://maven-central.storage-download.googleapis.com/repos/central/data/" url "https://maven-central.storage-download.googleapis.com/repos/central/data/" }
} jcenter()
jcenter()
} }
apply plugin: 'java' // standard Java tasks apply plugin: 'java' // standard Java tasks
@ -41,31 +39,33 @@ apply plugin: 'war' // standard Web Archive plugin
apply plugin: 'com.google.cloud.tools.appengine' // App Engine tasks apply plugin: 'com.google.cloud.tools.appengine' // App Engine tasks
dependencies { dependencies {
providedCompile group: 'javax.servlet', name: 'servlet-api', version:'2.5' providedCompile group: 'javax.servlet', name: 'servlet-api', version:'2.5'
compile 'com.google.appengine:appengine-api-1.0-sdk:1.9.59' compile 'com.google.appengine:appengine-api-1.0-sdk:1.9.59'
// Deps needed by all gRPC apps in GAE // Deps needed by all gRPC apps in GAE
compile libraries.google_api_protos compile libraries.google_api_protos
compile project(":grpc-okhttp") compile project(":grpc-okhttp")
compile project(":grpc-protobuf") compile project(":grpc-protobuf")
compile project(":grpc-stub") compile project(":grpc-stub")
compile project(":grpc-interop-testing") compile project(":grpc-interop-testing")
compile libraries.netty_tcnative compile libraries.netty_tcnative
} }
// [START model] // [START model]
appengine { // App Engine tasks configuration appengine {
run { // local (dev_appserver) configuration (standard environments only) // App Engine tasks configuration
port = 8080 // default run { // local (dev_appserver) configuration (standard environments only)
} port = 8080 // default
}
deploy { // deploy configuration deploy {
// default - stop the current version // deploy configuration
stopPreviousVersion = System.getProperty('gaeStopPreviousVersion') ?: true // default - stop the current version
// default - make this the current version stopPreviousVersion = System.getProperty('gaeStopPreviousVersion') ?: true
promote = System.getProperty('gaePromote') ?: true // default - make this the current version
// Use -DgaeDeployVersion if set, otherwise the version is null and the plugin will generate it promote = System.getProperty('gaePromote') ?: true
version = System.getProperty('gaeDeployVersion') // Use -DgaeDeployVersion if set, otherwise the version is null and the plugin will generate it
} version = System.getProperty('gaeDeployVersion')
}
} }
// [END model] // [END model]
@ -77,75 +77,79 @@ targetCompatibility = 1.8
/** Returns the service name. */ /** Returns the service name. */
String getGaeProject() { String getGaeProject() {
def stream = new ByteArrayOutputStream() def stream = new ByteArrayOutputStream()
exec { exec {
executable 'gcloud' executable 'gcloud'
args = ['config', 'get-value', 'project'] args = [
standardOutput = stream 'config',
} 'get-value',
return stream.toString().trim() 'project'
]
standardOutput = stream
}
return stream.toString().trim()
} }
String getService(java.nio.file.Path projectPath) { String getService(java.nio.file.Path projectPath) {
Node xml = new XmlParser().parse(projectPath.resolve("src/main/webapp/WEB-INF/appengine-web.xml").toFile()) Node xml = new XmlParser().parse(projectPath.resolve("src/main/webapp/WEB-INF/appengine-web.xml").toFile())
if (xml.service.isEmpty()) { if (xml.service.isEmpty()) {
return null return null
} else { } else {
return xml.service.text() return xml.service.text()
} }
} }
String getAppUrl(String project, String service, String version) { String getAppUrl(String project, String service, String version) {
if (version != null && service != null) { if (version != null && service != null) {
return "http://${version}.${service}.${project}.appspot.com" return "http://${version}.${service}.${project}.appspot.com"
} else { } else {
return "http://${project}.appspot.com" return "http://${project}.appspot.com"
} }
} }
task runInteropTestRemote(dependsOn: 'appengineDeploy') { task runInteropTestRemote(dependsOn: 'appengineDeploy') {
doLast { doLast {
// give remote app some time to settle down // give remote app some time to settle down
sleep(20000) sleep(20000)
def appUrl = getAppUrl( def appUrl = getAppUrl(
getGaeProject(), getGaeProject(),
getService(project.getProjectDir().toPath()), getService(project.getProjectDir().toPath()),
System.getProperty('gaeDeployVersion')) System.getProperty('gaeDeployVersion'))
logger.log(LogLevel.INFO, "the appURL=" + appUrl) logger.log(LogLevel.INFO, "the appURL=" + appUrl)
def client = new com.squareup.okhttp.OkHttpClient() def client = new com.squareup.okhttp.OkHttpClient()
// The '?jdk8' argument is ignored by the server, it exists only to tag the request log entry // The '?jdk8' argument is ignored by the server, it exists only to tag the request log entry
client.setReadTimeout(30, java.util.concurrent.TimeUnit.SECONDS) client.setReadTimeout(30, java.util.concurrent.TimeUnit.SECONDS)
def request = new com.squareup.okhttp.Request.Builder() def request = new com.squareup.okhttp.Request.Builder()
.url("${appUrl}/long_lived_channel?jdk8").build() .url("${appUrl}/long_lived_channel?jdk8").build()
def result1 = client.newCall(request).execute() def result1 = client.newCall(request).execute()
def result2 = client.newCall(request).execute() def result2 = client.newCall(request).execute()
if (result1.code() != 200 || result2.code() != 200) { if (result1.code() != 200 || result2.code() != 200) {
throw new GradleException("Unable to reuse same channel across requests") throw new GradleException("Unable to reuse same channel across requests")
}
// The test suite can take a while to run
client.setReadTimeout(3, java.util.concurrent.TimeUnit.MINUTES)
// The '?jdk8' argument is ignored by the server, it exists only to tag the request log entry
def interopRequest = new com.squareup.okhttp.Request.Builder()
.url("${appUrl}/?jdk8").build()
// Retry in case GAE is slow and times out
int maxRetries = 5
String result = null
Throwable caught = null
for (int attempt = 0; attempt < maxRetries; attempt++) {
try {
def response = client.newCall(interopRequest).execute()
result = response.body().string()
if (response.code() == 200) {
return
} }
} catch (Throwable t) {
caught = t // The test suite can take a while to run
logger.log(LogLevel.ERROR, "caught exception. will retry if possible", t) client.setReadTimeout(3, java.util.concurrent.TimeUnit.MINUTES)
} // The '?jdk8' argument is ignored by the server, it exists only to tag the request log entry
def interopRequest = new com.squareup.okhttp.Request.Builder()
.url("${appUrl}/?jdk8").build()
// Retry in case GAE is slow and times out
int maxRetries = 5
String result = null
Throwable caught = null
for (int attempt = 0; attempt < maxRetries; attempt++) {
try {
def response = client.newCall(interopRequest).execute()
result = response.body().string()
if (response.code() == 200) {
return
}
} catch (Throwable t) {
caught = t
logger.log(LogLevel.ERROR, "caught exception. will retry if possible", t)
}
}
throw new GradleException("Interop test failed:\nresponse: ${result}\nthrowable:${caught}")
} }
throw new GradleException("Interop test failed:\nresponse: ${result}\nthrowable:${caught}")
}
} }

View File

@ -2,14 +2,10 @@ description = "gRPC: GRPCLB LoadBalancer plugin"
buildscript { buildscript {
repositories { repositories {
maven { maven { // The google mirror is less flaky than mavenCentral()
// The google mirror is less flaky than mavenCentral() url "https://maven-central.storage-download.googleapis.com/repos/central/data/" }
url "https://maven-central.storage-download.googleapis.com/repos/central/data/"
}
}
dependencies {
classpath libraries.protobuf_plugin
} }
dependencies { classpath libraries.protobuf_plugin }
} }
dependencies { dependencies {
@ -23,7 +19,7 @@ dependencies {
} }
compileOnly libraries.javax_annotation compileOnly libraries.javax_annotation
testCompile libraries.truth, testCompile libraries.truth,
project(':grpc-core').sourceSets.test.output project(':grpc-core').sourceSets.test.output
} }
configureProtoCompilation() configureProtoCompilation()

View File

@ -5,15 +5,11 @@ startScripts.enabled = false
// Add dependency on the protobuf plugin // Add dependency on the protobuf plugin
buildscript { buildscript {
repositories { repositories {
maven { maven { // The google mirror is less flaky than mavenCentral()
// The google mirror is less flaky than mavenCentral() url "https://maven-central.storage-download.googleapis.com/repos/central/data/" }
url "https://maven-central.storage-download.googleapis.com/repos/central/data/" }
} dependencies { classpath libraries.protobuf_plugin }
}
dependencies {
classpath libraries.protobuf_plugin
}
} }
dependencies { dependencies {
@ -53,12 +49,12 @@ test {
task test_client(type: CreateStartScripts) { task test_client(type: CreateStartScripts) {
mainClassName = "io.grpc.testing.integration.TestServiceClient" mainClassName = "io.grpc.testing.integration.TestServiceClient"
applicationName = "test-client" applicationName = "test-client"
defaultJvmOpts = ["-javaagent:JAVAAGENT_APP_HOME" + configurations.alpnagent.singleFile.name] defaultJvmOpts = [
"-javaagent:JAVAAGENT_APP_HOME" + configurations.alpnagent.singleFile.name
]
outputDir = new File(project.buildDir, 'tmp') outputDir = new File(project.buildDir, 'tmp')
classpath = jar.outputs.files + configurations.runtime classpath = jar.outputs.files + configurations.runtime
dependencies { dependencies { runtime configurations.alpnagent }
runtime configurations.alpnagent
}
doLast { doLast {
unixScript.text = unixScript.text.replace('JAVAAGENT_APP_HOME', '\$APP_HOME/lib/') unixScript.text = unixScript.text.replace('JAVAAGENT_APP_HOME', '\$APP_HOME/lib/')
windowsScript.text = windowsScript.text.replace('JAVAAGENT_APP_HOME', '%APP_HOME%\\lib\\') windowsScript.text = windowsScript.text.replace('JAVAAGENT_APP_HOME', '%APP_HOME%\\lib\\')
@ -84,7 +80,10 @@ task stresstest_client(type: CreateStartScripts) {
applicationName = "stresstest-client" applicationName = "stresstest-client"
outputDir = new File(project.buildDir, 'tmp') outputDir = new File(project.buildDir, 'tmp')
classpath = jar.outputs.files + configurations.runtime classpath = jar.outputs.files + configurations.runtime
defaultJvmOpts = ["-verbose:gc", "-XX:+PrintFlagsFinal"] defaultJvmOpts = [
"-verbose:gc",
"-XX:+PrintFlagsFinal"
]
} }
task http2_client(type: CreateStartScripts) { task http2_client(type: CreateStartScripts) {

View File

@ -6,16 +6,18 @@ dependencies {
// Tests depend on base class defined by core module. // Tests depend on base class defined by core module.
testCompile project(':grpc-core').sourceSets.test.output, testCompile project(':grpc-core').sourceSets.test.output,
project(':grpc-testing'), project(':grpc-testing'),
project(':grpc-testing-proto') project(':grpc-testing-proto')
testRuntime libraries.netty_tcnative, testRuntime libraries.netty_tcnative,
libraries.conscrypt libraries.conscrypt
signature "org.codehaus.mojo.signature:java17:1.0@signature" signature "org.codehaus.mojo.signature:java17:1.0@signature"
} }
[compileJava, compileTestJava].each() { [compileJava, compileTestJava].each() {
// Netty retuns a lot of futures that we mostly don't care about. // Netty retuns a lot of futures that we mostly don't care about.
it.options.compilerArgs += ["-Xep:FutureReturnValueIgnored:OFF"] it.options.compilerArgs += [
"-Xep:FutureReturnValueIgnored:OFF"
]
} }
javadoc { javadoc {
@ -24,11 +26,7 @@ javadoc {
} }
project.sourceSets { project.sourceSets {
main { main { java { srcDir "${projectDir}/third_party/netty/java" } }
java {
srcDir "${projectDir}/third_party/netty/java"
}
}
} }
test { test {

View File

@ -1,36 +1,28 @@
buildscript { buildscript {
repositories { repositories { jcenter() }
jcenter() dependencies { classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.2' }
}
dependencies {
classpath 'com.github.jengelman.gradle.plugins:shadow:2.0.2'
}
} }
apply plugin: 'com.github.johnrengelman.shadow' apply plugin: 'com.github.johnrengelman.shadow'
description = "gRPC: Netty Shaded" description = "gRPC: Netty Shaded"
sourceSets { sourceSets { testShadow {} }
testShadow {}
}
dependencies { dependencies {
compile project(':grpc-netty') compile project(':grpc-netty')
runtime libraries.netty_tcnative runtime libraries.netty_tcnative
testShadowCompile files(shadowJar), testShadowCompile files(shadowJar),
configurations.shadow, configurations.shadow,
project(':grpc-testing-proto'), project(':grpc-testing-proto'),
project(':grpc-testing'), project(':grpc-testing'),
libraries.truth libraries.truth
shadow project(':grpc-core') shadow project(':grpc-core')
} }
artifacts { artifacts { // We want uploadArchives to handle the shadowJar; we don't care about
// We want uploadArchives to handle the shadowJar; we don't care about
// uploadShadow // uploadShadow
archives shadowJar archives shadowJar }
}
shadowJar { shadowJar {
classifier = null classifier = null

View File

@ -6,22 +6,14 @@ dependencies {
// Tests depend on base class defined by core module. // Tests depend on base class defined by core module.
testCompile project(':grpc-core').sourceSets.test.output, testCompile project(':grpc-core').sourceSets.test.output,
project(':grpc-testing'), project(':grpc-testing'),
project(':grpc-netty') project(':grpc-netty')
signature "org.codehaus.mojo.signature:java16:1.1@signature" signature "org.codehaus.mojo.signature:java16:1.1@signature"
} }
project.sourceSets { project.sourceSets {
main { main { java { srcDir "${projectDir}/third_party/okhttp/main/java" } }
java { test { java { srcDir "${projectDir}/third_party/okhttp/test/java" } }
srcDir "${projectDir}/third_party/okhttp/main/java"
}
}
test {
java {
srcDir "${projectDir}/third_party/okhttp/test/java"
}
}
} }
checkstyleMain.exclude '**/io/grpc/okhttp/internal/**' checkstyleMain.exclude '**/io/grpc/okhttp/internal/**'

View File

@ -1,14 +1,10 @@
buildscript { buildscript {
repositories { repositories {
maven { maven { // The google mirror is less flaky than mavenCentral()
// The google mirror is less flaky than mavenCentral() url "https://maven-central.storage-download.googleapis.com/repos/central/data/" }
url "https://maven-central.storage-download.googleapis.com/repos/central/data/"
}
mavenLocal() mavenLocal()
} }
dependencies { dependencies { classpath libraries.protobuf_plugin }
classpath libraries.protobuf_plugin
}
} }
apply plugin: 'com.google.protobuf' apply plugin: 'com.google.protobuf'
@ -26,36 +22,36 @@ dependencies {
} }
compileTestJava { compileTestJava {
// Protobuf-generated Lite produces quite a few warnings. // Protobuf-generated Lite produces quite a few warnings.
options.compilerArgs += ["-Xlint:-rawtypes", "-Xlint:-unchecked", "-Xlint:-fallthrough", options.compilerArgs += [
"-XepExcludedPaths:.*/build/generated/source/proto/.*"] "-Xlint:-rawtypes",
"-Xlint:-unchecked",
"-Xlint:-fallthrough",
"-XepExcludedPaths:.*/build/generated/source/proto/.*"
]
} }
protobuf { protobuf {
protoc { protoc {
if (project.hasProperty('protoc')) { if (project.hasProperty('protoc')) {
path = project.protoc path = project.protoc
} else { } else {
artifact = "com.google.protobuf:protoc:${protocVersion}" artifact = "com.google.protobuf:protoc:${protocVersion}"
}
} }
} plugins {
plugins { javalite {
javalite { if (project.hasProperty('protoc-gen-javalite')) {
if (project.hasProperty('protoc-gen-javalite')) { path = project['protoc-gen-javalite']
path = project['protoc-gen-javalite'] } else {
} else { artifact = libraries.protoc_lite
artifact = libraries.protoc_lite }
} }
} }
} generateProtoTasks {
generateProtoTasks { ofSourceSet('test')*.each { task ->
ofSourceSet('test')*.each { task -> task.builtins { remove java }
task.builtins { task.plugins { javalite {} }
remove java }
}
task.plugins {
javalite {}
}
} }
}
} }

View File

@ -1,14 +1,10 @@
// Add dependency on the protobuf plugin // Add dependency on the protobuf plugin
buildscript { buildscript {
repositories { repositories {
maven { maven { // The google mirror is less flaky than mavenCentral()
// The google mirror is less flaky than mavenCentral() url "https://maven-central.storage-download.googleapis.com/repos/central/data/" }
url "https://maven-central.storage-download.googleapis.com/repos/central/data/"
}
}
dependencies {
classpath libraries.protobuf_plugin
} }
dependencies { classpath libraries.protobuf_plugin }
} }
description = 'gRPC: Protobuf Nano' description = 'gRPC: Protobuf Nano'
@ -23,16 +19,14 @@ dependencies {
configureProtoCompilation() configureProtoCompilation()
if (project.hasProperty('protobuf')) { if (project.hasProperty('protobuf')) {
protobuf { protobuf {
generateProtoTasks { generateProtoTasks {
all().each { task -> all().each { task ->
task.builtins { task.builtins {
remove java remove java
javanano { javanano { option 'ignore_services=true' }
option 'ignore_services=true' }
} }
} }
}
} }
}
} }

View File

@ -2,14 +2,10 @@ description = 'gRPC: Protobuf'
buildscript { buildscript {
repositories { repositories {
maven { maven { // The google mirror is less flaky than mavenCentral()
// The google mirror is less flaky than mavenCentral() url "https://maven-central.storage-download.googleapis.com/repos/central/data/" }
url "https://maven-central.storage-download.googleapis.com/repos/central/data/"
}
}
dependencies {
classpath libraries.protobuf_plugin
} }
dependencies { classpath libraries.protobuf_plugin }
} }
dependencies { dependencies {

View File

@ -1,14 +1,10 @@
// Add dependency on the protobuf plugin // Add dependency on the protobuf plugin
buildscript { buildscript {
repositories { repositories {
maven { maven { // The google mirror is less flaky than mavenCentral()
// The google mirror is less flaky than mavenCentral() url "https://maven-central.storage-download.googleapis.com/repos/central/data/" }
url "https://maven-central.storage-download.googleapis.com/repos/central/data/"
}
}
dependencies {
classpath libraries.protobuf_plugin
} }
dependencies { classpath libraries.protobuf_plugin }
} }
description = "gRPC: Services" description = "gRPC: Services"

View File

@ -42,8 +42,8 @@ project(':grpc-benchmarks').projectDir = "$rootDir/benchmarks" as File
project(':grpc-services').projectDir = "$rootDir/services" as File project(':grpc-services').projectDir = "$rootDir/services" as File
if (settings.hasProperty('skipCodegen') && skipCodegen.toBoolean()) { if (settings.hasProperty('skipCodegen') && skipCodegen.toBoolean()) {
println '*** Skipping the build of codegen and compilation of proto files because skipCodegen=true' println '*** Skipping the build of codegen and compilation of proto files because skipCodegen=true'
} else { } else {
include ":grpc-compiler" include ":grpc-compiler"
project(':grpc-compiler').projectDir = "$rootDir/compiler" as File project(':grpc-compiler').projectDir = "$rootDir/compiler" as File
} }

View File

@ -2,7 +2,7 @@ description = "gRPC: Stub"
dependencies { dependencies {
compile project(':grpc-core') compile project(':grpc-core')
testCompile libraries.truth, testCompile libraries.truth,
project(':grpc-testing') project(':grpc-testing')
signature "org.codehaus.mojo.signature:java16:1.1@signature" signature "org.codehaus.mojo.signature:java16:1.1@signature"
} }

View File

@ -3,14 +3,10 @@ description = "gRPC: Testing Protos"
// Add dependency on the protobuf plugin // Add dependency on the protobuf plugin
buildscript { buildscript {
repositories { repositories {
maven { maven { // The google mirror is less flaky than mavenCentral()
// The google mirror is less flaky than mavenCentral() url "https://maven-central.storage-download.googleapis.com/repos/central/data/" }
url "https://maven-central.storage-download.googleapis.com/repos/central/data/"
}
}
dependencies {
classpath libraries.protobuf_plugin
} }
dependencies { classpath libraries.protobuf_plugin }
} }
dependencies { dependencies {

View File

@ -17,9 +17,7 @@ dependencies {
compileOnly libraries.truth compileOnly libraries.truth
testCompile project(':grpc-testing-proto'), testCompile project(':grpc-testing-proto'),
project(':grpc-core').sourceSets.test.output project(':grpc-core').sourceSets.test.output
} }
javadoc { javadoc { exclude 'io/grpc/internal/**' }
exclude 'io/grpc/internal/**'
}