zhangkun | 9de8e4b | 2015-01-15 10:29:05 -0800 | [diff] [blame] | 1 | apply plugin: "cpp" |
Eric Anderson | fb28ad2 | 2015-01-29 15:00:58 -0800 | [diff] [blame] | 2 | apply plugin: "protobuf" |
zhangkun | 9de8e4b | 2015-01-15 10:29:05 -0800 | [diff] [blame] | 3 | |
Eric Anderson | b938ba5 | 2015-02-28 09:59:25 -0800 | [diff] [blame] | 4 | import org.apache.tools.ant.taskdefs.condition.Os |
| 5 | |
zhangkun83 | 5e60785 | 2015-01-22 12:31:56 -0800 | [diff] [blame] | 6 | description = 'The protoc plugin for gRPC Java' |
| 7 | |
Eric Anderson | fb28ad2 | 2015-01-29 15:00:58 -0800 | [diff] [blame] | 8 | buildscript { |
| 9 | repositories { |
| 10 | mavenCentral() |
| 11 | } |
| 12 | dependencies { |
| 13 | classpath libraries.protobuf_plugin |
| 14 | } |
| 15 | } |
| 16 | |
zhangkun | 9de8e4b | 2015-01-15 10:29:05 -0800 | [diff] [blame] | 17 | executables { |
| 18 | java_plugin {} |
| 19 | } |
| 20 | |
Eric Anderson | fb28ad2 | 2015-01-29 15:00:58 -0800 | [diff] [blame] | 21 | dependencies { |
| 22 | compile project(':grpc-stub'), |
| 23 | libraries.protobuf |
| 24 | } |
| 25 | |
zhangkun | 9de8e4b | 2015-01-15 10:29:05 -0800 | [diff] [blame] | 26 | binaries.all { |
nmittler | f129960 | 2015-01-30 14:55:38 -0800 | [diff] [blame] | 27 | if (toolChain in Gcc || toolChain in Clang) { |
Louis Ryan | c42c8c4 | 2015-03-18 16:31:38 -0700 | [diff] [blame^] | 28 | cppCompiler.args "--std=c++0x" |
Eric Anderson | 2049e0d | 2015-01-29 12:41:51 -0800 | [diff] [blame] | 29 | if (System.env.CXXFLAGS) { |
| 30 | cppCompiler.args System.env.CXXFLAGS |
| 31 | } |
| 32 | if (System.env.CPPFLAGS) { |
| 33 | cppCompiler.args System.env.CPPFLAGS |
| 34 | } |
zhangkun | 9de8e4b | 2015-01-15 10:29:05 -0800 | [diff] [blame] | 35 | linker.args "-lprotoc", "-lprotobuf" |
Eric Anderson | 2049e0d | 2015-01-29 12:41:51 -0800 | [diff] [blame] | 36 | if (System.env.LDFLAGS) { |
| 37 | linker.args System.env.LDFLAGS |
| 38 | } |
Eric Anderson | b938ba5 | 2015-02-28 09:59:25 -0800 | [diff] [blame] | 39 | } 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 | } |
zhangkun | 9de8e4b | 2015-01-15 10:29:05 -0800 | [diff] [blame] | 48 | } |
| 49 | } |
| 50 | |
Eric Anderson | b938ba5 | 2015-02-28 09:59:25 -0800 | [diff] [blame] | 51 | protobufCodeGenPlugins = ["java_plugin:$javaPluginPath"] |
zhangkun | 9de8e4b | 2015-01-15 10:29:05 -0800 | [diff] [blame] | 52 | |
Eric Anderson | fb28ad2 | 2015-01-29 15:00:58 -0800 | [diff] [blame] | 53 | generateTestProto.dependsOn 'java_pluginExecutable' |
Eric Anderson | b938ba5 | 2015-02-28 09:59:25 -0800 | [diff] [blame] | 54 | // Ignore test for the moment on Windows. It will be easier to run once the |
| 55 | // gradle protobuf plugin can support nano. |
| 56 | if (!Os.isFamily(Os.FAMILY_WINDOWS)) { |
| 57 | test.dependsOn('testGolden','testNanoGolden') |
| 58 | } |
Eric Anderson | fb28ad2 | 2015-01-29 15:00:58 -0800 | [diff] [blame] | 59 | |
| 60 | task testGolden(type: Exec, dependsOn: 'generateTestProto') { |
Eric Anderson | b938ba5 | 2015-02-28 09:59:25 -0800 | [diff] [blame] | 61 | 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 Anderson | fb28ad2 | 2015-01-29 15:00:58 -0800 | [diff] [blame] | 69 | "$projectDir/src/test/golden/TestService.java.txt" |
zhangkun83 | 5e60785 | 2015-01-22 12:31:56 -0800 | [diff] [blame] | 70 | } |
Xiao Hang | dcff315 | 2015-02-20 15:03:06 -0800 | [diff] [blame] | 71 | |
zsurocking | 5902c6a | 2015-02-25 20:54:53 -0800 | [diff] [blame] | 72 | task testNanoGolden(type: Exec, dependsOn: 'java_pluginExecutable') { |
Jakob Buchgraber | df321fe | 2015-02-25 19:47:05 -0800 | [diff] [blame] | 73 | doFirst { |
| 74 | temporaryDir.createNewFile(); |
| 75 | } |
| 76 | |
zsurocking | 5902c6a | 2015-02-25 20:54:53 -0800 | [diff] [blame] | 77 | environment 'TEST_TMP_DIR', temporaryDir |
| 78 | commandLine './src/test/run_nano_test.sh' |
| 79 | } |
Xiao Hang | dcff315 | 2015-02-20 15:03:06 -0800 | [diff] [blame] | 80 | |
Eric Anderson | 192144e | 2015-03-02 13:31:14 -0800 | [diff] [blame] | 81 | [ |
| 82 | install.repositories.mavenInstaller, |
| 83 | uploadArchives.repositories.mavenDeployer, |
| 84 | ]*.addFilter('none') { artifact, file -> false } |