blob: 1efbe83568585c0a7b2d202e28eab122032b2fbd [file] [log] [blame]
zhangkun9de8e4b2015-01-15 10:29:05 -08001apply plugin: "cpp"
Eric Andersonfb28ad22015-01-29 15:00:58 -08002apply plugin: "protobuf"
zhangkun9de8e4b2015-01-15 10:29:05 -08003
Eric Andersonb938ba52015-02-28 09:59:25 -08004import org.apache.tools.ant.taskdefs.condition.Os
5
zhangkun835e607852015-01-22 12:31:56 -08006description = 'The protoc plugin for gRPC Java'
7
Eric Andersonfb28ad22015-01-29 15:00:58 -08008buildscript {
9 repositories {
10 mavenCentral()
11 }
12 dependencies {
13 classpath libraries.protobuf_plugin
14 }
15}
16
zhangkun9de8e4b2015-01-15 10:29:05 -080017executables {
18 java_plugin {}
19}
20
Eric Andersonfb28ad22015-01-29 15:00:58 -080021dependencies {
22 compile project(':grpc-stub'),
23 libraries.protobuf
24}
25
zhangkun9de8e4b2015-01-15 10:29:05 -080026binaries.all {
nmittlerf1299602015-01-30 14:55:38 -080027 if (toolChain in Gcc || toolChain in Clang) {
zhangkun9de8e4b2015-01-15 10:29:05 -080028 cppCompiler.args "-std=c++11"
Eric Anderson2049e0d2015-01-29 12:41:51 -080029 if (System.env.CXXFLAGS) {
30 cppCompiler.args System.env.CXXFLAGS
31 }
32 if (System.env.CPPFLAGS) {
33 cppCompiler.args System.env.CPPFLAGS
34 }
zhangkun9de8e4b2015-01-15 10:29:05 -080035 linker.args "-lprotoc", "-lprotobuf"
Eric Anderson2049e0d2015-01-29 12:41:51 -080036 if (System.env.LDFLAGS) {
37 linker.args System.env.LDFLAGS
38 }
Eric Andersonb938ba52015-02-28 09:59:25 -080039 } else if (toolChain in VisualCpp) {
40 cppCompiler.args "/EHsc", "/MD"
41 if (rootProject.hasProperty('protobuf.include')) {
42 cppCompiler.args "/I" + rootProject.properties['protobuf.include']
43 }
44 linker.args "libprotobuf.lib", "libprotoc.lib"
45 if (rootProject.hasProperty('protobuf.libs')) {
46 linker.args "/LIBPATH:" + rootProject.properties['protobuf.libs']
47 }
zhangkun9de8e4b2015-01-15 10:29:05 -080048 }
49}
50
Eric Andersonb938ba52015-02-28 09:59:25 -080051protobufCodeGenPlugins = ["java_plugin:$javaPluginPath"]
zhangkun9de8e4b2015-01-15 10:29:05 -080052
Eric Andersonfb28ad22015-01-29 15:00:58 -080053generateTestProto.dependsOn 'java_pluginExecutable'
Eric Andersonb938ba52015-02-28 09:59:25 -080054// Ignore test for the moment on Windows. It will be easier to run once the
55// gradle protobuf plugin can support nano.
56if (!Os.isFamily(Os.FAMILY_WINDOWS)) {
57 test.dependsOn('testGolden','testNanoGolden')
58}
Eric Andersonfb28ad22015-01-29 15:00:58 -080059
60task testGolden(type: Exec, dependsOn: 'generateTestProto') {
Eric Andersonb938ba52015-02-28 09:59:25 -080061 if (!Os.isFamily(Os.FAMILY_WINDOWS)) {
62 executable "diff"
63 } else {
64 executable "fc"
65 }
66 // File isn't found on Windows if last slash is forward-slash
67 def slash = System.getProperty("file.separator")
68 args "$buildDir/generated-sources/test/io/grpc/testing/integration" + slash + "TestServiceGrpc.java",
Eric Andersonfb28ad22015-01-29 15:00:58 -080069 "$projectDir/src/test/golden/TestService.java.txt"
zhangkun835e607852015-01-22 12:31:56 -080070}
Xiao Hangdcff3152015-02-20 15:03:06 -080071
zsurocking5902c6a2015-02-25 20:54:53 -080072task testNanoGolden(type: Exec, dependsOn: 'java_pluginExecutable') {
Jakob Buchgraberdf321fe2015-02-25 19:47:05 -080073 doFirst {
74 temporaryDir.createNewFile();
75 }
76
zsurocking5902c6a2015-02-25 20:54:53 -080077 environment 'TEST_TMP_DIR', temporaryDir
78 commandLine './src/test/run_nano_test.sh'
79}
Xiao Hangdcff3152015-02-20 15:03:06 -080080
Eric Anderson192144e2015-03-02 13:31:14 -080081[
82 install.repositories.mavenInstaller,
83 uploadArchives.repositories.mavenDeployer,
84]*.addFilter('none') { artifact, file -> false }