blob: 151728f6b7b0f09871d3133943eade7300f49722 [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) {
Eric Andersona0acb9b2015-03-20 10:26:00 -070028 // Support Gcc 4.6 by using c++0x instead of c++11
Louis Ryanc42c8c42015-03-18 16:31:38 -070029 cppCompiler.args "--std=c++0x"
Eric Anderson2049e0d2015-01-29 12:41:51 -080030 if (System.env.CXXFLAGS) {
31 cppCompiler.args System.env.CXXFLAGS
32 }
33 if (System.env.CPPFLAGS) {
34 cppCompiler.args System.env.CPPFLAGS
35 }
zhangkun9de8e4b2015-01-15 10:29:05 -080036 linker.args "-lprotoc", "-lprotobuf"
Eric Anderson2049e0d2015-01-29 12:41:51 -080037 if (System.env.LDFLAGS) {
38 linker.args System.env.LDFLAGS
39 }
Eric Andersonb938ba52015-02-28 09:59:25 -080040 } else if (toolChain in VisualCpp) {
41 cppCompiler.args "/EHsc", "/MD"
42 if (rootProject.hasProperty('protobuf.include')) {
43 cppCompiler.args "/I" + rootProject.properties['protobuf.include']
44 }
45 linker.args "libprotobuf.lib", "libprotoc.lib"
46 if (rootProject.hasProperty('protobuf.libs')) {
47 linker.args "/LIBPATH:" + rootProject.properties['protobuf.libs']
48 }
zhangkun9de8e4b2015-01-15 10:29:05 -080049 }
50}
51
Eric Andersonb938ba52015-02-28 09:59:25 -080052protobufCodeGenPlugins = ["java_plugin:$javaPluginPath"]
zhangkun9de8e4b2015-01-15 10:29:05 -080053
Eric Andersonfb28ad22015-01-29 15:00:58 -080054generateTestProto.dependsOn 'java_pluginExecutable'
Eric Andersonb938ba52015-02-28 09:59:25 -080055// Ignore test for the moment on Windows. It will be easier to run once the
56// gradle protobuf plugin can support nano.
57if (!Os.isFamily(Os.FAMILY_WINDOWS)) {
58 test.dependsOn('testGolden','testNanoGolden')
59}
Eric Andersonfb28ad22015-01-29 15:00:58 -080060
61task testGolden(type: Exec, dependsOn: 'generateTestProto') {
Eric Andersonb938ba52015-02-28 09:59:25 -080062 if (!Os.isFamily(Os.FAMILY_WINDOWS)) {
63 executable "diff"
64 } else {
65 executable "fc"
66 }
67 // File isn't found on Windows if last slash is forward-slash
68 def slash = System.getProperty("file.separator")
69 args "$buildDir/generated-sources/test/io/grpc/testing/integration" + slash + "TestServiceGrpc.java",
Eric Andersonfb28ad22015-01-29 15:00:58 -080070 "$projectDir/src/test/golden/TestService.java.txt"
zhangkun835e607852015-01-22 12:31:56 -080071}
Xiao Hangdcff3152015-02-20 15:03:06 -080072
zsurocking5902c6a2015-02-25 20:54:53 -080073task testNanoGolden(type: Exec, dependsOn: 'java_pluginExecutable') {
Jakob Buchgraberdf321fe2015-02-25 19:47:05 -080074 doFirst {
75 temporaryDir.createNewFile();
76 }
77
zsurocking5902c6a2015-02-25 20:54:53 -080078 environment 'TEST_TMP_DIR', temporaryDir
79 commandLine './src/test/run_nano_test.sh'
80}
Xiao Hangdcff3152015-02-20 15:03:06 -080081
Eric Anderson192144e2015-03-02 13:31:14 -080082[
83 install.repositories.mavenInstaller,
84 uploadArchives.repositories.mavenDeployer,
85]*.addFilter('none') { artifact, file -> false }