File tree Expand file tree Collapse file tree
dev/mvn-build-helper/proto
native-engine/blaze-serde Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1616 <dependency >
1717 <groupId >com.google.protobuf</groupId >
1818 <artifactId >protobuf-java</artifactId >
19- <version >3.21.9 </version >
19+ <version >${protobufVersion} </version >
2020 </dependency >
2121 </dependencies >
2222
Original file line number Diff line number Diff line change 1212// See the License for the specific language governing permissions and
1313// limitations under the License.
1414
15+ use std:: { fs, path:: PathBuf } ;
16+
1517fn main ( ) -> Result < ( ) , String > {
1618 // for use in docker build where file changes can be wonky
1719 println ! ( "cargo:rerun-if-env-changed=FORCE_REBUILD" ) ;
1820
1921 println ! ( "cargo:rerun-if-changed=proto/blaze.proto" ) ;
20- tonic_build:: compile_protos ( "proto/blaze.proto" )
22+
23+ let mut prost_build = tonic_build:: Config :: new ( ) ;
24+
25+ // protobuf-maven-plugin download the protoc executable in the target directory
26+ let protoc_dir_path = "../../dev/mvn-build-helper/proto/target/protoc-plugins" ;
27+ let mut protoc_file: Option < PathBuf > = None ;
28+ if let Ok ( entries) = fs:: read_dir ( protoc_dir_path) {
29+ for entry in entries. filter_map ( Result :: ok) {
30+ let path = entry. path ( ) ;
31+ if path. is_file ( )
32+ && path
33+ . file_name ( )
34+ . map ( |f| f. to_string_lossy ( ) . starts_with ( "protoc" ) )
35+ . unwrap_or ( false )
36+ {
37+ protoc_file = Some ( path) ;
38+ break ;
39+ }
40+ }
41+ }
42+ if let Some ( path) = protoc_file {
43+ eprintln ! ( "Using protoc executable: {:?}" , path) ;
44+ prost_build. protoc_executable ( path) ;
45+ }
46+ prost_build
47+ . compile_protos ( & [ "proto/blaze.proto" ] , & [ "proto" ] )
2148 . map_err ( |e| format ! ( "protobuf compilation failed: {}" , e) )
2249}
You can’t perform that action at this time.
0 commit comments