Skip to content

Commit 287a27a

Browse files
committed
Upgrade to protobuf-gradle-plugin:0.4.0
Use the plugin to compile nano for golden test and get rid of the shell script.
1 parent 7ecb6fa commit 287a27a

3 files changed

Lines changed: 56 additions & 41 deletions

File tree

build.gradle

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ subprojects {
5050
// Only when the codegen is built along with the project, will we be able to recompile
5151
// the proto files.
5252
project.apply plugin: 'com.google.protobuf'
53-
project.protobufCodeGenPlugins = ["java_plugin:$javaPluginPath"]
53+
project.protobufCodeGenPlugins = ["grpc:$javaPluginPath"]
5454
project.protocDep = "com.google.protobuf:protoc:${protobufVersion}"
5555
project.generatedFileDir = "${projectDir}/src/generated"
5656
project.afterEvaluate {
@@ -68,6 +68,11 @@ subprojects {
6868
java {
6969
srcDir 'src/generated/main'
7070
}
71+
proto {
72+
plugins {
73+
grpc { }
74+
}
75+
}
7176
}
7277
}
7378
}
@@ -85,7 +90,7 @@ subprojects {
8590
okhttp: 'com.squareup.okhttp:okhttp:2.2.0',
8691
protobuf: "com.google.protobuf:protobuf-java:${protobufVersion}",
8792
protobuf_nano: "com.google.protobuf.nano:protobuf-javanano:${protobufVersion}",
88-
protobuf_plugin: 'com.google.protobuf:protobuf-gradle-plugin:0.3.1',
93+
protobuf_plugin: 'com.google.protobuf:protobuf-gradle-plugin:0.4.0',
8994

9095
netty: 'io.netty:netty-codec-http2:4.1.0.Beta5',
9196

compiler/build.gradle

Lines changed: 49 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,45 @@ model {
7373
}
7474
}
7575

76+
configurations {
77+
testNanoCompile
78+
}
79+
7680
dependencies {
7781
testCompile project(':grpc-protobuf'),
7882
project(':grpc-stub')
83+
testNanoCompile project(':grpc-protobuf-nano'),
84+
project(':grpc-stub')
85+
}
86+
87+
sourceSets {
88+
test {
89+
proto {
90+
plugins {
91+
grpc { }
92+
}
93+
}
94+
}
95+
testNano {
96+
proto {
97+
setSrcDirs(['src/test/proto'])
98+
builtins {
99+
remove java
100+
javanano {
101+
option 'ignore_services=true'
102+
}
103+
}
104+
plugins {
105+
grpc {
106+
option 'nano=true'
107+
}
108+
}
109+
}
110+
}
111+
}
112+
113+
checkstyleTestNano {
114+
source = fileTree(dir: "src/testNano", include: "**/*.java")
79115
}
80116

81117
binaries.all {
@@ -152,35 +188,28 @@ artifacts {
152188
}
153189

154190
project.protocDep = "com.google.protobuf:protoc:${protobufVersion}"
155-
protobufCodeGenPlugins = ["java_plugin:$javaPluginPath"]
191+
protobufCodeGenPlugins = ["grpc:$javaPluginPath"]
156192

157193
project.afterEvaluate {
158-
generateTestProto.dependsOn 'java_pluginExecutable'
194+
[generateTestProto, generateTestNanoProto]*.dependsOn 'java_pluginExecutable'
159195
}
160196

161-
// Ignore test for the moment on Windows. It will be easier to run once the
162-
// gradle protobuf plugin can support nano.
163-
if (osdetector.os != 'windows') {
164-
test.dependsOn('testGolden','testNanoGolden')
165-
}
197+
test.dependsOn('testGolden', 'testNanoGolden')
166198

167-
task testGolden(type: Exec, dependsOn: 'generateTestProto') {
199+
def configureTestTask(Task task, String suffix) {
200+
task.dependsOn "generateTest${suffix}Proto"
168201
if (osdetector.os != 'windows') {
169-
executable "diff"
202+
task.executable "diff"
170203
} else {
171-
executable "fc"
204+
task.executable "fc"
172205
}
173206
// File isn't found on Windows if last slash is forward-slash
174207
def slash = System.getProperty("file.separator")
175-
args "$buildDir/generated-sources/test/io/grpc/testing/integration" + slash + "TestServiceGrpc.java",
176-
"$projectDir/src/test/golden/TestService.java.txt"
208+
task.args "$buildDir/generated-sources/test${suffix}/io/grpc/testing/integration" + slash + "TestServiceGrpc.java",
209+
"$projectDir/src/test/golden/TestService${suffix}.java.txt"
177210
}
178211

179-
task testNanoGolden(type: Exec, dependsOn: 'java_pluginExecutable') {
180-
doFirst {
181-
temporaryDir.createNewFile();
182-
}
183-
184-
environment 'TEST_TMP_DIR', temporaryDir
185-
commandLine './src/test/run_nano_test.sh'
186-
}
212+
task testGolden(type: Exec)
213+
task testNanoGolden(type: Exec)
214+
configureTestTask(testGolden, '')
215+
configureTestTask(testNanoGolden, 'Nano')

compiler/src/test/run_nano_test.sh

Lines changed: 0 additions & 19 deletions
This file was deleted.

0 commit comments

Comments
 (0)