blob: 6c7710d647c39bf6f1ceb4eee0076ecca3d29522 [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 {
Kun Zhang90706dc2015-04-09 13:11:31 -070018 java_plugin {
19 baseName "$protocPluginBaseName"
20 }
zhangkun9de8e4b2015-01-15 10:29:05 -080021}
22
Eric Andersonfb28ad22015-01-29 15:00:58 -080023dependencies {
24 compile project(':grpc-stub'),
25 libraries.protobuf
26}
27
zhangkun9de8e4b2015-01-15 10:29:05 -080028binaries.all {
nmittlerf1299602015-01-30 14:55:38 -080029 if (toolChain in Gcc || toolChain in Clang) {
Eric Andersona0acb9b2015-03-20 10:26:00 -070030 // Support Gcc 4.6 by using c++0x instead of c++11
Louis Ryanc42c8c42015-03-18 16:31:38 -070031 cppCompiler.args "--std=c++0x"
Eric Anderson2049e0d2015-01-29 12:41:51 -080032 if (System.env.CXXFLAGS) {
33 cppCompiler.args System.env.CXXFLAGS
34 }
35 if (System.env.CPPFLAGS) {
36 cppCompiler.args System.env.CPPFLAGS
37 }
zhangkun9de8e4b2015-01-15 10:29:05 -080038 linker.args "-lprotoc", "-lprotobuf"
Eric Anderson2049e0d2015-01-29 12:41:51 -080039 if (System.env.LDFLAGS) {
40 linker.args System.env.LDFLAGS
41 }
Eric Andersonb938ba52015-02-28 09:59:25 -080042 } else if (toolChain in VisualCpp) {
43 cppCompiler.args "/EHsc", "/MD"
44 if (rootProject.hasProperty('protobuf.include')) {
45 cppCompiler.args "/I" + rootProject.properties['protobuf.include']
46 }
47 linker.args "libprotobuf.lib", "libprotoc.lib"
48 if (rootProject.hasProperty('protobuf.libs')) {
49 linker.args "/LIBPATH:" + rootProject.properties['protobuf.libs']
50 }
zhangkun9de8e4b2015-01-15 10:29:05 -080051 }
52}
53
Eric Andersonb938ba52015-02-28 09:59:25 -080054protobufCodeGenPlugins = ["java_plugin:$javaPluginPath"]
zhangkun9de8e4b2015-01-15 10:29:05 -080055
Eric Andersonfb28ad22015-01-29 15:00:58 -080056generateTestProto.dependsOn 'java_pluginExecutable'
Eric Andersonb938ba52015-02-28 09:59:25 -080057// Ignore test for the moment on Windows. It will be easier to run once the
58// gradle protobuf plugin can support nano.
59if (!Os.isFamily(Os.FAMILY_WINDOWS)) {
60 test.dependsOn('testGolden','testNanoGolden')
61}
Eric Andersonfb28ad22015-01-29 15:00:58 -080062
63task testGolden(type: Exec, dependsOn: 'generateTestProto') {
Eric Andersonb938ba52015-02-28 09:59:25 -080064 if (!Os.isFamily(Os.FAMILY_WINDOWS)) {
65 executable "diff"
66 } else {
67 executable "fc"
68 }
69 // File isn't found on Windows if last slash is forward-slash
70 def slash = System.getProperty("file.separator")
71 args "$buildDir/generated-sources/test/io/grpc/testing/integration" + slash + "TestServiceGrpc.java",
Eric Andersonfb28ad22015-01-29 15:00:58 -080072 "$projectDir/src/test/golden/TestService.java.txt"
zhangkun835e607852015-01-22 12:31:56 -080073}
Xiao Hangdcff3152015-02-20 15:03:06 -080074
zsurocking5902c6a2015-02-25 20:54:53 -080075task testNanoGolden(type: Exec, dependsOn: 'java_pluginExecutable') {
Jakob Buchgraberdf321fe2015-02-25 19:47:05 -080076 doFirst {
77 temporaryDir.createNewFile();
78 }
79
zsurocking5902c6a2015-02-25 20:54:53 -080080 environment 'TEST_TMP_DIR', temporaryDir
81 commandLine './src/test/run_nano_test.sh'
82}
Xiao Hangdcff3152015-02-20 15:03:06 -080083
Eric Anderson192144e2015-03-02 13:31:14 -080084[
85 install.repositories.mavenInstaller,
86 uploadArchives.repositories.mavenDeployer,
87]*.addFilter('none') { artifact, file -> false }