| apply plugin: "cpp" |
| apply plugin: "protobuf" |
| |
| import org.apache.tools.ant.taskdefs.condition.Os |
| |
| description = 'The protoc plugin for gRPC Java' |
| |
| buildscript { |
| repositories { |
| mavenCentral() |
| } |
| dependencies { |
| classpath libraries.protobuf_plugin |
| } |
| } |
| |
| executables { |
| java_plugin {} |
| } |
| |
| dependencies { |
| compile project(':grpc-stub'), |
| libraries.protobuf |
| } |
| |
| binaries.all { |
| if (toolChain in Gcc || toolChain in Clang) { |
| cppCompiler.args "-std=c++11" |
| if (System.env.CXXFLAGS) { |
| cppCompiler.args System.env.CXXFLAGS |
| } |
| if (System.env.CPPFLAGS) { |
| cppCompiler.args System.env.CPPFLAGS |
| } |
| linker.args "-lprotoc", "-lprotobuf" |
| if (System.env.LDFLAGS) { |
| linker.args System.env.LDFLAGS |
| } |
| } else if (toolChain in VisualCpp) { |
| cppCompiler.args "/EHsc", "/MD" |
| if (rootProject.hasProperty('protobuf.include')) { |
| cppCompiler.args "/I" + rootProject.properties['protobuf.include'] |
| } |
| linker.args "libprotobuf.lib", "libprotoc.lib" |
| if (rootProject.hasProperty('protobuf.libs')) { |
| linker.args "/LIBPATH:" + rootProject.properties['protobuf.libs'] |
| } |
| } |
| } |
| |
| protobufCodeGenPlugins = ["java_plugin:$javaPluginPath"] |
| |
| generateTestProto.dependsOn 'java_pluginExecutable' |
| // Ignore test for the moment on Windows. It will be easier to run once the |
| // gradle protobuf plugin can support nano. |
| if (!Os.isFamily(Os.FAMILY_WINDOWS)) { |
| test.dependsOn('testGolden','testNanoGolden') |
| } |
| |
| task testGolden(type: Exec, dependsOn: 'generateTestProto') { |
| if (!Os.isFamily(Os.FAMILY_WINDOWS)) { |
| executable "diff" |
| } else { |
| executable "fc" |
| } |
| // File isn't found on Windows if last slash is forward-slash |
| def slash = System.getProperty("file.separator") |
| args "$buildDir/generated-sources/test/io/grpc/testing/integration" + slash + "TestServiceGrpc.java", |
| "$projectDir/src/test/golden/TestService.java.txt" |
| } |
| |
| task testNanoGolden(type: Exec, dependsOn: 'java_pluginExecutable') { |
| doFirst { |
| temporaryDir.createNewFile(); |
| } |
| |
| environment 'TEST_TMP_DIR', temporaryDir |
| commandLine './src/test/run_nano_test.sh' |
| } |
| |
| [ |
| install.repositories.mavenInstaller, |
| uploadArchives.repositories.mavenDeployer, |
| ]*.addFilter('none') { artifact, file -> false } |