Skip to content

Commit 5ce10f0

Browse files
authored
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.
1 parent 9d26c5c commit 5ce10f0

File tree

32 files changed

+929
-1050
lines changed

32 files changed

+929
-1050
lines changed

all/build.gradle

Lines changed: 19 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -4,27 +4,23 @@ description = "gRPC: All"
44

55
buildscript {
66
repositories {
7-
maven {
8-
// The google mirror is less flaky than mavenCentral()
9-
url "https://maven-central.storage-download.googleapis.com/repos/central/data/"
10-
}
11-
}
12-
dependencies {
13-
classpath 'org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.0.1'
7+
maven { // The google mirror is less flaky than mavenCentral()
8+
url "https://maven-central.storage-download.googleapis.com/repos/central/data/" }
149
}
10+
dependencies { classpath 'org.kt3k.gradle.plugin:coveralls-gradle-plugin:2.0.1' }
1511
}
1612

1713
def subprojects = [
18-
project(':grpc-auth'),
19-
project(':grpc-core'),
20-
project(':grpc-context'),
21-
project(':grpc-netty'),
22-
project(':grpc-okhttp'),
23-
project(':grpc-protobuf'),
24-
project(':grpc-protobuf-lite'),
25-
project(':grpc-protobuf-nano'),
26-
project(':grpc-stub'),
27-
project(':grpc-testing'),
14+
project(':grpc-auth'),
15+
project(':grpc-core'),
16+
project(':grpc-context'),
17+
project(':grpc-netty'),
18+
project(':grpc-okhttp'),
19+
project(':grpc-protobuf'),
20+
project(':grpc-protobuf-lite'),
21+
project(':grpc-protobuf-nano'),
22+
project(':grpc-stub'),
23+
project(':grpc-testing'),
2824
]
2925

3026
for (subproject in rootProject.subprojects) {
@@ -56,8 +52,8 @@ task jacocoMerge(type: JacocoMerge) {
5652
mustRunAfter(subprojects.jacocoTestReport.mustRunAfter)
5753
destinationFile = file("${buildDir}/jacoco/test.exec")
5854
executionData = files(subprojects.jacocoTestReport.executionData)
59-
.plus(project(':grpc-interop-testing').jacocoTestReport.executionData)
60-
.filter { f -> f.exists() }
55+
.plus(project(':grpc-interop-testing').jacocoTestReport.executionData)
56+
.filter { f -> f.exists() }
6157
}
6258

6359
jacocoTestReport {
@@ -72,14 +68,14 @@ jacocoTestReport {
7268
classDirectories = files(subprojects.sourceSets.main.output)
7369
classDirectories = files(classDirectories.files.collect {
7470
fileTree(dir: it,
75-
exclude: ['**/io/grpc/okhttp/internal/**'])
71+
exclude: [
72+
'**/io/grpc/okhttp/internal/**'
73+
])
7674
})
7775
}
7876

7977
coveralls {
8078
sourceDirs = subprojects.sourceSets.main.allSource.srcDirs.flatten()
8179
}
8280

83-
tasks.coveralls {
84-
dependsOn(jacocoTestReport)
85-
}
81+
tasks.coveralls { dependsOn(jacocoTestReport) }

alts/build.gradle

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,10 @@ targetCompatibility = 1.7
55

66
buildscript {
77
repositories {
8-
maven {
9-
// The google mirror is less flaky than mavenCentral()
10-
url "https://maven-central.storage-download.googleapis.com/repos/central/data/"
11-
}
12-
}
13-
dependencies {
14-
classpath libraries.protobuf_plugin
8+
maven { // The google mirror is less flaky than mavenCentral()
9+
url "https://maven-central.storage-download.googleapis.com/repos/central/data/" }
1510
}
11+
dependencies { classpath libraries.protobuf_plugin }
1612
}
1713

1814
dependencies {
@@ -24,10 +20,10 @@ dependencies {
2420
libraries.protobuf
2521
runtime project(':grpc-grpclb')
2622
testCompile libraries.guava,
27-
libraries.guava_testlib,
28-
libraries.junit,
29-
libraries.mockito,
30-
libraries.truth
23+
libraries.guava_testlib,
24+
libraries.junit,
25+
libraries.mockito,
26+
libraries.truth
3127
signature 'org.codehaus.mojo.signature:java17:1.0@signature'
3228
}
3329

@@ -36,9 +32,10 @@ configureProtoCompilation()
3632
[compileJava, compileTestJava].each() {
3733
// ALTS retuns a lot of futures that we mostly don't care about.
3834
// protobuf calls valueof. Will be fixed in next release (google/protobuf#4046)
39-
it.options.compilerArgs += ["-Xlint:-deprecation", "-Xep:FutureReturnValueIgnored:OFF"]
35+
it.options.compilerArgs += [
36+
"-Xlint:-deprecation",
37+
"-Xep:FutureReturnValueIgnored:OFF"
38+
]
4039
}
4140

42-
javadoc {
43-
exclude 'io/grpc/alts/internal/**'
44-
}
41+
javadoc { exclude 'io/grpc/alts/internal/**' }

android-interop-testing/app/build.gradle

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -14,26 +14,19 @@ android {
1414
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
1515
}
1616
buildTypes {
17-
debug {
18-
minifyEnabled false
19-
}
17+
debug { minifyEnabled false }
2018
release {
2119
minifyEnabled true
2220
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
2321
}
2422
}
25-
lintOptions {
26-
disable 'InvalidPackage', 'HardcodedText'
27-
}
23+
lintOptions { disable 'InvalidPackage', 'HardcodedText' }
2824
}
2925

3026
protobuf {
31-
protoc {
32-
artifact = 'com.google.protobuf:protoc:3.5.1-1'
33-
}
27+
protoc { artifact = 'com.google.protobuf:protoc:3.5.1-1' }
3428
plugins {
35-
grpc {
36-
artifact = 'io.grpc:protoc-gen-grpc-java:1.14.0-SNAPSHOT' // CURRENT_GRPC_VERSION
29+
grpc { artifact = 'io.grpc:protoc-gen-grpc-java:1.14.0-SNAPSHOT' // CURRENT_GRPC_VERSION
3730
}
3831
}
3932
generateProtoTasks {
@@ -47,10 +40,8 @@ protobuf {
4740
}
4841

4942
task.plugins {
50-
grpc {
51-
// Options added to --grpc_out
52-
option 'nano'
53-
}
43+
grpc { // Options added to --grpc_out
44+
option 'nano' }
5445
}
5546
}
5647
}
@@ -73,7 +64,5 @@ dependencies {
7364
}
7465

7566
gradle.projectsEvaluated {
76-
tasks.withType(JavaCompile) {
77-
options.compilerArgs << "-Xlint:deprecation"
78-
}
67+
tasks.withType(JavaCompile) { options.compilerArgs << "-Xlint:deprecation" }
7968
}

android/build.gradle

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,7 @@ buildscript {
99
google()
1010
jcenter()
1111
mavenCentral()
12-
maven {
13-
url "https://plugins.gradle.org/m2/"
14-
}
12+
maven { url "https://plugins.gradle.org/m2/" }
1513
}
1614
dependencies {
1715
classpath 'com.android.tools.build:gradle:3.0.1'
@@ -33,9 +31,7 @@ android {
3331
versionName "1.0"
3432
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
3533
}
36-
lintOptions {
37-
abortOnError false
38-
}
34+
lintOptions { abortOnError false }
3935
}
4036

4137
repositories {

auth/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ dependencies {
33
compile project(':grpc-core'),
44
libraries.google_auth_credentials
55
testCompile project(':grpc-testing'),
6-
libraries.oauth_client
6+
libraries.oauth_client
77
signature "org.codehaus.mojo.signature:java16:1.1@signature"
88
}

benchmarks/build.gradle

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
buildscript {
22
repositories {
3-
maven {
4-
// The google mirror is less flaky than mavenCentral()
5-
url "https://maven-central.storage-download.googleapis.com/repos/central/data/"
6-
}
7-
}
8-
dependencies {
9-
classpath libraries.protobuf_plugin
3+
maven { // The google mirror is less flaky than mavenCentral()
4+
url "https://maven-central.storage-download.googleapis.com/repos/central/data/" }
105
}
6+
dependencies { classpath libraries.protobuf_plugin }
117
}
128

139
apply plugin: 'application'
@@ -41,31 +37,35 @@ dependencies {
4137
}
4238

4339
compileJava {
44-
// The Control.Void protobuf clashes
45-
options.compilerArgs += ["-Xep:JavaLangClash:OFF"]
40+
// The Control.Void protobuf clashes
41+
options.compilerArgs += ["-Xep:JavaLangClash:OFF"]
4642
}
4743

4844
configureProtoCompilation()
4945

5046
def vmArgs = [
51-
"-server",
52-
"-Xms2g",
53-
"-Xmx2g",
54-
"-XX:+PrintGCDetails"
47+
"-server",
48+
"-Xms2g",
49+
"-Xmx2g",
50+
"-XX:+PrintGCDetails"
5551
]
5652

5753
task qps_client(type: CreateStartScripts) {
5854
mainClassName = "io.grpc.benchmarks.qps.AsyncClient"
5955
applicationName = "qps_client"
60-
defaultJvmOpts = ["-javaagent:" + configurations.alpnagent.asPath] + vmArgs
56+
defaultJvmOpts = [
57+
"-javaagent:" + configurations.alpnagent.asPath
58+
].plus(vmArgs)
6159
outputDir = new File(project.buildDir, 'tmp')
6260
classpath = jar.outputs.files + project.configurations.runtime
6361
}
6462

6563
task openloop_client(type: CreateStartScripts) {
6664
mainClassName = "io.grpc.benchmarks.qps.OpenLoopClient"
6765
applicationName = "openloop_client"
68-
defaultJvmOpts = ["-javaagent:" + configurations.alpnagent.asPath] + vmArgs
66+
defaultJvmOpts = [
67+
"-javaagent:" + configurations.alpnagent.asPath
68+
].plus(vmArgs)
6969
outputDir = new File(project.buildDir, 'tmp')
7070
classpath = jar.outputs.files + project.configurations.runtime
7171
}
@@ -80,7 +80,9 @@ task qps_server(type: CreateStartScripts) {
8080
task benchmark_worker(type: CreateStartScripts) {
8181
mainClassName = "io.grpc.benchmarks.driver.LoadWorker"
8282
applicationName = "benchmark_worker"
83-
defaultJvmOpts = ["-javaagent:" + configurations.alpnagent.asPath] + vmArgs
83+
defaultJvmOpts = [
84+
"-javaagent:" + configurations.alpnagent.asPath
85+
].plus(vmArgs)
8486
outputDir = new File(project.buildDir, 'tmp')
8587
classpath = jar.outputs.files + project.configurations.runtime
8688
}

0 commit comments

Comments
 (0)