aboutsummaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
authorZHANG Dapeng <zdapeng@google.com>2018-06-11 18:35:18 -0700
committerGitHub <noreply@github.com>2018-06-11 18:35:18 -0700
commit5ce10f0146ddce96bc1e6884fe55d8623880b528 (patch)
tree74dd7fcfff4f3dcc5e9de108d7cfa385bce564ec /examples
parent9d26c5c40596693bb643d267ab2f3d25b15ed36b (diff)
downloadgrpc-grpc-java-5ce10f0146ddce96bc1e6884fe55d8623880b528.tar.gz
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.
Diffstat (limited to 'examples')
-rw-r--r--examples/android/clientcache/app/build.gradle21
-rw-r--r--examples/android/helloworld/app/build.gradle21
-rw-r--r--examples/android/routeguide/app/build.gradle23
-rw-r--r--examples/android/routeguide/build.gradle4
-rw-r--r--examples/build.gradle156
-rw-r--r--examples/example-kotlin/android/helloworld/app/build.gradle25
-rw-r--r--examples/example-kotlin/build.gradle76
7 files changed, 134 insertions, 192 deletions
diff --git a/examples/android/clientcache/app/build.gradle b/examples/android/clientcache/app/build.gradle
index d0d84bd35..bec1a6a5e 100644
--- a/examples/android/clientcache/app/build.gradle
+++ b/examples/android/clientcache/app/build.gradle
@@ -14,9 +14,7 @@ android {
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
- debug {
- minifyEnabled false
- }
+ debug { minifyEnabled false }
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
@@ -30,25 +28,18 @@ android {
}
protobuf {
- protoc {
- artifact = 'com.google.protobuf:protoc:3.4.0'
- }
+ protoc { artifact = 'com.google.protobuf:protoc:3.4.0' }
plugins {
- javalite {
- 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
+ javalite { 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
}
}
generateProtoTasks {
all().each { task ->
task.plugins {
javalite {}
- grpc {
- // Options added to --grpc_out
- option 'lite'
- }
+ grpc { // Options added to --grpc_out
+ option 'lite' }
}
}
}
diff --git a/examples/android/helloworld/app/build.gradle b/examples/android/helloworld/app/build.gradle
index 8f980c87b..f46a397ab 100644
--- a/examples/android/helloworld/app/build.gradle
+++ b/examples/android/helloworld/app/build.gradle
@@ -13,9 +13,7 @@ android {
versionName "1.0"
}
buildTypes {
- debug {
- minifyEnabled false
- }
+ debug { minifyEnabled false }
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
@@ -29,25 +27,18 @@ android {
}
protobuf {
- protoc {
- artifact = 'com.google.protobuf:protoc:3.5.1-1'
- }
+ protoc { artifact = 'com.google.protobuf:protoc:3.5.1-1' }
plugins {
- javalite {
- 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
+ javalite { 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
}
}
generateProtoTasks {
all().each { task ->
task.plugins {
javalite {}
- grpc {
- // Options added to --grpc_out
- option 'lite'
- }
+ grpc { // Options added to --grpc_out
+ option 'lite' }
}
}
}
diff --git a/examples/android/routeguide/app/build.gradle b/examples/android/routeguide/app/build.gradle
index b69c3b99e..2e2465bdc 100644
--- a/examples/android/routeguide/app/build.gradle
+++ b/examples/android/routeguide/app/build.gradle
@@ -5,16 +5,14 @@ android {
compileSdkVersion 27
defaultConfig {
- applicationId "io.grpc.routeguideexample"
+ applicationId "io.grpc.routeguideexample"
minSdkVersion 14
targetSdkVersion 27
versionCode 1
versionName "1.0"
}
buildTypes {
- debug {
- minifyEnabled false
- }
+ debug { minifyEnabled false }
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
@@ -28,25 +26,18 @@ android {
}
protobuf {
- protoc {
- artifact = 'com.google.protobuf:protoc:3.5.1-1'
- }
+ protoc { artifact = 'com.google.protobuf:protoc:3.5.1-1' }
plugins {
- javalite {
- 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
+ javalite { 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
}
}
generateProtoTasks {
all().each { task ->
task.plugins {
javalite {}
- grpc {
- // Options added to --grpc_out
- option 'lite'
- }
+ grpc { // Options added to --grpc_out
+ option 'lite' }
}
}
}
diff --git a/examples/android/routeguide/build.gradle b/examples/android/routeguide/build.gradle
index 7b299d637..b0692f9d1 100644
--- a/examples/android/routeguide/build.gradle
+++ b/examples/android/routeguide/build.gradle
@@ -22,6 +22,4 @@ allprojects {
}
}
-task clean(type: Delete) {
- delete rootProject.buildDir
-}
+task clean(type: Delete) { delete rootProject.buildDir }
diff --git a/examples/build.gradle b/examples/build.gradle
index 32d83dc02..1e0f81a78 100644
--- a/examples/build.gradle
+++ b/examples/build.gradle
@@ -2,25 +2,19 @@ apply plugin: 'java'
apply plugin: 'com.google.protobuf'
buildscript {
- repositories {
- maven {
- // The google mirror is less flaky than mavenCentral()
- url "https://maven-central.storage-download.googleapis.com/repos/central/data/"
+ repositories {
+ maven { // The google mirror is less flaky than mavenCentral()
+ 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
- // gradle versions
- classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.3'
- }
+ dependencies { // ASSUMES GRADLE 2.12 OR HIGHER. Use plugin version 0.7.5 with earlier
+ // gradle versions
+ classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.3' }
}
repositories {
- maven {
- // The google mirror is less flaky than mavenCentral()
- url "https://maven-central.storage-download.googleapis.com/repos/central/data/"
- }
- mavenLocal()
+ maven { // The google mirror is less flaky than mavenCentral()
+ url "https://maven-central.storage-download.googleapis.com/repos/central/data/" }
+ mavenLocal()
}
// 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'
dependencies {
- compile "com.google.api.grpc:proto-google-common-protos:1.0.0"
- compile "io.grpc:grpc-alts:${grpcVersion}"
- compile "io.grpc:grpc-netty:${grpcVersion}"
- compile "io.grpc:grpc-protobuf:${grpcVersion}"
- compile "io.grpc:grpc-stub:${grpcVersion}"
- compileOnly "javax.annotation:javax.annotation-api:1.2"
+ compile "com.google.api.grpc:proto-google-common-protos:1.0.0"
+ compile "io.grpc:grpc-alts:${grpcVersion}"
+ compile "io.grpc:grpc-netty:${grpcVersion}"
+ compile "io.grpc:grpc-protobuf:${grpcVersion}"
+ compile "io.grpc:grpc-stub:${grpcVersion}"
+ compileOnly "javax.annotation:javax.annotation-api:1.2"
- // Used for TLS in HelloWorldServerTls
- compile "io.netty:netty-tcnative-boringssl-static:${nettyTcNativeVersion}"
+ // Used for TLS in HelloWorldServerTls
+ 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 "junit:junit:4.12"
- testCompile "org.mockito:mockito-core:1.9.5"
+ testCompile "io.grpc:grpc-testing:${grpcVersion}"
+ testCompile "junit:junit:4.12"
+ testCompile "org.mockito:mockito-core:1.9.5"
}
protobuf {
- protoc {
- artifact = "com.google.protobuf:protoc:${protocVersion}"
- }
- plugins {
- grpc {
- artifact = "io.grpc:protoc-gen-grpc-java:${grpcVersion}"
+ protoc { artifact = "com.google.protobuf:protoc:${protocVersion}" }
+ plugins {
+ grpc { artifact = "io.grpc:protoc-gen-grpc-java:${grpcVersion}" }
}
- }
- generateProtoTasks {
- all()*.plugins {
- grpc {}
+ generateProtoTasks {
+ all()*.plugins { grpc {} }
}
- }
}
// Inform IDEs like IntelliJ IDEA, Eclipse or NetBeans about the generated code.
@@ -86,77 +74,77 @@ apply plugin: 'application'
startScripts.enabled = false
task routeGuideServer(type: CreateStartScripts) {
- mainClassName = 'io.grpc.examples.routeguide.RouteGuideServer'
- applicationName = 'route-guide-server'
- outputDir = new File(project.buildDir, 'tmp')
- classpath = jar.outputs.files + project.configurations.runtime
+ mainClassName = 'io.grpc.examples.routeguide.RouteGuideServer'
+ applicationName = 'route-guide-server'
+ outputDir = new File(project.buildDir, 'tmp')
+ classpath = jar.outputs.files + project.configurations.runtime
}
task routeGuideClient(type: CreateStartScripts) {
- mainClassName = 'io.grpc.examples.routeguide.RouteGuideClient'
- applicationName = 'route-guide-client'
- outputDir = new File(project.buildDir, 'tmp')
- classpath = jar.outputs.files + project.configurations.runtime
+ mainClassName = 'io.grpc.examples.routeguide.RouteGuideClient'
+ applicationName = 'route-guide-client'
+ outputDir = new File(project.buildDir, 'tmp')
+ classpath = jar.outputs.files + project.configurations.runtime
}
task helloWorldServer(type: CreateStartScripts) {
- mainClassName = 'io.grpc.examples.helloworld.HelloWorldServer'
- applicationName = 'hello-world-server'
- outputDir = new File(project.buildDir, 'tmp')
- classpath = jar.outputs.files + project.configurations.runtime
+ mainClassName = 'io.grpc.examples.helloworld.HelloWorldServer'
+ applicationName = 'hello-world-server'
+ outputDir = new File(project.buildDir, 'tmp')
+ classpath = jar.outputs.files + project.configurations.runtime
}
task helloWorldClient(type: CreateStartScripts) {
- mainClassName = 'io.grpc.examples.helloworld.HelloWorldClient'
- applicationName = 'hello-world-client'
- outputDir = new File(project.buildDir, 'tmp')
- classpath = jar.outputs.files + project.configurations.runtime
+ mainClassName = 'io.grpc.examples.helloworld.HelloWorldClient'
+ applicationName = 'hello-world-client'
+ outputDir = new File(project.buildDir, 'tmp')
+ classpath = jar.outputs.files + project.configurations.runtime
}
task helloWorldAltsServer(type: CreateStartScripts) {
- mainClassName = 'io.grpc.examples.alts.HelloWorldAltsServer'
- applicationName = 'hello-world-alts-server'
- outputDir = new File(project.buildDir, 'tmp')
- classpath = jar.outputs.files + project.configurations.runtime
+ mainClassName = 'io.grpc.examples.alts.HelloWorldAltsServer'
+ applicationName = 'hello-world-alts-server'
+ outputDir = new File(project.buildDir, 'tmp')
+ classpath = jar.outputs.files + project.configurations.runtime
}
task helloWorldAltsClient(type: CreateStartScripts) {
- mainClassName = 'io.grpc.examples.alts.HelloWorldAltsClient'
- applicationName = 'hello-world-alts-client'
- outputDir = new File(project.buildDir, 'tmp')
- classpath = jar.outputs.files + project.configurations.runtime
+ mainClassName = 'io.grpc.examples.alts.HelloWorldAltsClient'
+ applicationName = 'hello-world-alts-client'
+ outputDir = new File(project.buildDir, 'tmp')
+ classpath = jar.outputs.files + project.configurations.runtime
}
task helloWorldTlsServer(type: CreateStartScripts) {
- mainClassName = 'io.grpc.examples.helloworldtls.HelloWorldServerTls'
- applicationName = 'hello-world-tls-server'
- outputDir = new File(project.buildDir, 'tmp')
- classpath = jar.outputs.files + project.configurations.runtime
+ mainClassName = 'io.grpc.examples.helloworldtls.HelloWorldServerTls'
+ applicationName = 'hello-world-tls-server'
+ outputDir = new File(project.buildDir, 'tmp')
+ classpath = jar.outputs.files + project.configurations.runtime
}
task helloWorldTlsClient(type: CreateStartScripts) {
- mainClassName = 'io.grpc.examples.helloworldtls.HelloWorldClientTls'
- applicationName = 'hello-world-tls-client'
- outputDir = new File(project.buildDir, 'tmp')
- classpath = jar.outputs.files + project.configurations.runtime
+ mainClassName = 'io.grpc.examples.helloworldtls.HelloWorldClientTls'
+ applicationName = 'hello-world-tls-client'
+ outputDir = new File(project.buildDir, 'tmp')
+ classpath = jar.outputs.files + project.configurations.runtime
}
task compressingHelloWorldClient(type: CreateStartScripts) {
- mainClassName = 'io.grpc.examples.experimental.CompressingHelloWorldClient'
- applicationName = 'compressing-hello-world-client'
- outputDir = new File(project.buildDir, 'tmp')
- classpath = jar.outputs.files + project.configurations.runtime
+ mainClassName = 'io.grpc.examples.experimental.CompressingHelloWorldClient'
+ applicationName = 'compressing-hello-world-client'
+ outputDir = new File(project.buildDir, 'tmp')
+ classpath = jar.outputs.files + project.configurations.runtime
}
applicationDistribution.into('bin') {
- from(routeGuideServer)
- from(routeGuideClient)
- from(helloWorldServer)
- from(helloWorldClient)
- from(helloWorldAltsServer)
- from(helloWorldAltsClient)
- from(helloWorldTlsServer)
- from(helloWorldTlsClient)
- from(compressingHelloWorldClient)
- fileMode = 0755
+ from(routeGuideServer)
+ from(routeGuideClient)
+ from(helloWorldServer)
+ from(helloWorldClient)
+ from(helloWorldAltsServer)
+ from(helloWorldAltsClient)
+ from(helloWorldTlsServer)
+ from(helloWorldTlsClient)
+ from(compressingHelloWorldClient)
+ fileMode = 0755
}
diff --git a/examples/example-kotlin/android/helloworld/app/build.gradle b/examples/example-kotlin/android/helloworld/app/build.gradle
index 5e8a2e257..486ce3638 100644
--- a/examples/example-kotlin/android/helloworld/app/build.gradle
+++ b/examples/example-kotlin/android/helloworld/app/build.gradle
@@ -15,9 +15,7 @@ android {
versionName "1.0"
}
buildTypes {
- debug {
- minifyEnabled false
- }
+ debug { minifyEnabled false }
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
@@ -51,25 +49,18 @@ android {
}
protobuf {
- protoc {
- artifact = 'com.google.protobuf:protoc:3.5.1-1'
- }
+ protoc { artifact = 'com.google.protobuf:protoc:3.5.1-1' }
plugins {
- javalite {
- 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
+ javalite { 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
}
}
generateProtoTasks {
all().each { task ->
task.plugins {
javalite {}
- grpc {
- // Options added to --grpc_out
- option 'lite'
- }
+ grpc { // Options added to --grpc_out
+ option 'lite' }
}
}
}
@@ -86,6 +77,4 @@ dependencies {
compile 'io.grpc:grpc-stub:1.14.0-SNAPSHOT' // CURRENT_GRPC_VERSION
}
-repositories {
- mavenCentral()
-}
+repositories { mavenCentral() }
diff --git a/examples/example-kotlin/build.gradle b/examples/example-kotlin/build.gradle
index d2b7cdfea..17ceddf8b 100644
--- a/examples/example-kotlin/build.gradle
+++ b/examples/example-kotlin/build.gradle
@@ -13,21 +13,21 @@ apply plugin: 'application'
buildscript {
- ext.kotlin_version = '1.2.21'
+ ext.kotlin_version = '1.2.21'
- repositories {
- mavenCentral()
- mavenLocal()
- }
- dependencies {
- classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.5'
- classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
- }
+ repositories {
+ mavenCentral()
+ mavenLocal()
+ }
+ dependencies {
+ classpath 'com.google.protobuf:protobuf-gradle-plugin:0.8.5'
+ classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
+ }
}
repositories {
- mavenCentral()
- mavenLocal()
+ mavenCentral()
+ mavenLocal()
}
// 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
dependencies {
- compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
- compile "com.google.api.grpc:proto-google-common-protos:1.0.0"
- compile "io.grpc:grpc-netty:${grpcVersion}"
- compile "io.grpc:grpc-protobuf:${grpcVersion}"
- compile "io.grpc:grpc-stub:${grpcVersion}"
+ compile "org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlin_version"
+ compile "com.google.api.grpc:proto-google-common-protos:1.0.0"
+ compile "io.grpc:grpc-netty:${grpcVersion}"
+ compile "io.grpc:grpc-protobuf:${grpcVersion}"
+ compile "io.grpc:grpc-stub:${grpcVersion}"
- testCompile "io.grpc:grpc-testing:${grpcVersion}" // gRCP testing utilities
- testCompile "junit:junit:4.12"
- testCompile "org.mockito:mockito-core:1.9.5"
+ testCompile "io.grpc:grpc-testing:${grpcVersion}" // gRCP testing utilities
+ testCompile "junit:junit:4.12"
+ testCompile "org.mockito:mockito-core:1.9.5"
}
protobuf {
- protoc {
- artifact = 'com.google.protobuf:protoc:3.5.1-1'
- }
- plugins {
- grpc {
- artifact = "io.grpc:protoc-gen-grpc-java:${grpcVersion}"
+ protoc { artifact = 'com.google.protobuf:protoc:3.5.1-1' }
+ plugins {
+ grpc { artifact = "io.grpc:protoc-gen-grpc-java:${grpcVersion}" }
}
- }
- generateProtoTasks {
- all()*.plugins {
- grpc {}
+ generateProtoTasks {
+ all()*.plugins { grpc {} }
}
- }
}
startScripts.enabled = false
task helloWorldServer(type: CreateStartScripts) {
- mainClassName = 'io.grpc.examples.helloworld.HelloWorldServer'
- applicationName = 'hello-world-server'
- outputDir = new File(project.buildDir, 'tmp')
- classpath = jar.outputs.files + project.configurations.runtime
+ mainClassName = 'io.grpc.examples.helloworld.HelloWorldServer'
+ applicationName = 'hello-world-server'
+ outputDir = new File(project.buildDir, 'tmp')
+ classpath = jar.outputs.files + project.configurations.runtime
}
task helloWorldClient(type: CreateStartScripts) {
- mainClassName = 'io.grpc.examples.helloworld.HelloWorldClient'
- applicationName = 'hello-world-client'
- outputDir = new File(project.buildDir, 'tmp')
- classpath = jar.outputs.files + project.configurations.runtime
+ mainClassName = 'io.grpc.examples.helloworld.HelloWorldClient'
+ applicationName = 'hello-world-client'
+ outputDir = new File(project.buildDir, 'tmp')
+ classpath = jar.outputs.files + project.configurations.runtime
}
applicationDistribution.into('bin') {
- from(helloWorldServer)
- from(helloWorldClient)
- fileMode = 0755
+ from(helloWorldServer)
+ from(helloWorldClient)
+ fileMode = 0755
}