diff --git a/connector/protobuf/README.md b/connector/protobuf/README.md new file mode 100644 index 000000000000..4fc28950495b --- /dev/null +++ b/connector/protobuf/README.md @@ -0,0 +1,37 @@ +# Spark Protobuf - Developer Documentation + +## Getting Started + +### Build + +```bash +./build/mvn clean package +``` + +or + +```bash +./build/sbt clean package +``` + +### Build with user-defined `protoc` + +When the user cannot use the official `protoc` binary files to build the `protobuf` module in the compilation environment, +for example, compiling `protobuf` module on CentOS 6 or CentOS 7 which the default `glibc` version is less than 2.14, we can try to compile and test by +specifying the user-defined `protoc` binary files as follows: + +```bash +export PROTOBUF_PROTOC_EXEC_PATH=/path-to-protoc-exe +./build/mvn -Phive -Puser-defined-protoc clean package +``` + +or + +```bash +export PROTOBUF_PROTOC_EXEC_PATH=/path-to-protoc-exe +export CONNECT_PLUGIN_EXEC_PATH=/path-to-protoc-gen-grpc-java-exe +./build/sbt -Puser-defined-protoc clean package +``` + +The user-defined `protoc` binary files can be produced in the user's compilation environment by source code compilation, +for compilation steps, please refer to [protobuf](https://github.com/protocolbuffers/protobuf). diff --git a/connector/protobuf/pom.xml b/connector/protobuf/pom.xml index 9f884b07a12a..ab491ad38a88 100644 --- a/connector/protobuf/pom.xml +++ b/connector/protobuf/pom.xml @@ -110,28 +110,73 @@ - - com.github.os72 - protoc-jar-maven-plugin - 3.11.4 - - - - generate-test-sources - - run - - - com.google.protobuf:protoc:${protobuf.version} - ${protobuf.version} - - src/test/resources/protobuf - - test - - - - + + + default-protoc + + true + + + + + com.github.os72 + protoc-jar-maven-plugin + 3.11.4 + + + + generate-test-sources + + run + + + com.google.protobuf:protoc:${protobuf.version} + ${protobuf.version} + + src/test/resources/protobuf + + test + + + + + + + + + user-defined-protoc + + ${env.PROTOBUF_PROTOC_EXEC_PATH} + + + + + com.github.os72 + protoc-jar-maven-plugin + 3.11.4 + + + + generate-test-sources + + run + + + com.google.protobuf:protoc:${protobuf.version} + ${protobuf.version} + ${protobuf.protoc.executable.path} + + src/test/resources/protobuf + + test + + + + + + + + diff --git a/project/SparkBuild.scala b/project/SparkBuild.scala index 9e5fe62e0102..b82c53a06350 100644 --- a/project/SparkBuild.scala +++ b/project/SparkBuild.scala @@ -112,10 +112,14 @@ object SparkBuild extends PomBuild { if (profiles.contains("user-defined-protoc")) { val connectProtocExecPath = Properties.envOrNone("CONNECT_PROTOC_EXEC_PATH") val connectPluginExecPath = Properties.envOrNone("CONNECT_PLUGIN_EXEC_PATH") + val protobufProtocExecPath = Properties.envOrNone("PROTOBUF_PROTOC_EXEC_PATH") if (connectProtocExecPath.isDefined && connectPluginExecPath.isDefined) { sys.props.put("connect.protoc.executable.path", connectProtocExecPath.get) sys.props.put("connect.plugin.executable.path", connectPluginExecPath.get) } + if (protobufProtocExecPath.isDefined) { + sys.props.put("protobuf.protoc.executable.path", protobufProtocExecPath.get) + } } profiles } @@ -779,7 +783,16 @@ object SparkProtobuf { case m if m.toLowerCase(Locale.ROOT).endsWith(".proto") => MergeStrategy.discard case _ => MergeStrategy.first }, - ) + ) ++ { + val protobufProtocExecPath = sys.props.get("protobuf.protoc.executable.path") + if (protobufProtocExecPath.isDefined) { + Seq( + PB.protocExecutable := file(protobufProtocExecPath.get) + ) + } else { + Seq.empty + } + } } object Unsafe {