leiningen.protoc
Leiningen plugin for compiling Google Protocol Buffers
build-cmd
(build-cmd {:keys [protoc-exe protoc-grpc-exe]} {:keys [proto-source-paths builtin-proto-path]} {:keys [proto-target-path grpc-target-path]})
compile-proto!
(compile-proto! compiler-details source-paths target-paths timeout)
Compiles the sources using the provided configurations
protoc
(protoc {:keys [protoc-timeout], :as project} & _)
Compiles Google Protocol Buffer proto files to Java Sources.
The following options are available and should be configured in the project.clj:
:protoc-version :: the Protocol Buffers Compiler version to use. Defaults to :latest
:proto-source-paths :: vector of absolute paths or paths relative to the project root that contain the .proto files to be compiled. Defaults to ["src/proto"]
:proto-target-path :: the absolute path or path relative to the project root where the sources should be generated. Defaults to ${target-path}/generated-sources/protobuf
:protoc-grpc :: true (or empty map) to generate interfaces for gRPC service definitions with default settings. Can optionally provide a map with the following configs: :version - version number for gRPC codegen. Defaults to :latest. :target-path - absolute path or path relative to the project root where the sources should be generated. Defaults to the :proto-target-path
Defaults to false
.
:protoc-timeout :: timeout value in seconds for the compilation process Defaults to 60
resolve!
(resolve! artifact protoc-version)
Resolves the Google Protocol Buffers code generation artifact+version in the local maven repository if it exists or downloads from Maven Central
resolve-builtin-proto!
(resolve-builtin-proto! project)
If the project.clj includes the com.google.protobuf/protobuf-java
dependency, then we unpack it to a temporary location to use during compilation in order to make the builtin proto files available.
resolve-protoc!
(resolve-protoc! protoc-version)
Given a string com.google.protobuf/protoc version or :latest
, will ensure the required protoc executable is available in the local Maven repository either from a previous download, or will download from Maven Central.
resolve-protoc-grpc!
(resolve-protoc-grpc! protoc-version)
Given a string io.grpc/protoc-gen-grpc-java version or :latest
, will ensure the required protoc executable is available in the local Maven repository either from a previous download, or will download from Maven Central.
validate
(validate {:keys [protoc-version protoc-grpc proto-source-paths proto-target-path protoc-timeout]})
Validates the input arguments and returns a vector of error messages