diff --git a/rules/scala_proto/private/ScalaProtoWorker.scala b/rules/scala_proto/private/ScalaProtoWorker.scala index 195e0f9a2..ff96007d9 100644 --- a/rules/scala_proto/private/ScalaProtoWorker.scala +++ b/rules/scala_proto/private/ScalaProtoWorker.scala @@ -16,6 +16,13 @@ object ScalaProtoWorker extends WorkerMain[Unit] { private[this] val argParser: ArgumentParser = { val parser = ArgumentParsers.newFor("proto").addHelp(true).fromFilePrefix("@").build + parser + .addArgument("--proto_path") + .help("Proto path") + .metavar("proto_path") + .nargs("*") + .`type`(Arguments.fileType.verifyIsDirectory) + .setDefault_(Collections.emptyList) parser .addArgument("--output_dir") .help("Output dir") @@ -36,11 +43,12 @@ object ScalaProtoWorker extends WorkerMain[Unit] { protected[this] def work(ctx: Unit, args: Array[String]): Unit = { val namespace = argParser.parseArgs(args) val sources = namespace.getList[File]("sources").asScala.toList + val path = namespace.getList[File]("proto_path").asScala.toList val scalaOut = namespace.get[File]("output_dir").toPath Files.createDirectories(scalaOut) - val params = s"--scala_out=$scalaOut" :: sources.map(_.getPath) + val params = s"--scala_out=$scalaOut" :: path.map("--proto_path " ++ _.getPath) ++ sources.map(_.getPath) ProtocBridge.runWithGenerators( protoc = a => com.github.os72.protocjar.Protoc.runProtoc(a.toArray), diff --git a/rules/scala_proto/private/core.bzl b/rules/scala_proto/private/core.bzl index 36044ea05..1c03f6070 100644 --- a/rules/scala_proto/private/core.bzl +++ b/rules/scala_proto/private/core.bzl @@ -32,6 +32,7 @@ def scala_proto_library_implementation(ctx): args = ctx.actions.args() args.add("--output_dir", gendir.path) + args.add_all("--proto_path", transitive_proto_path) args.add_all("--", transitive_sources) args.set_param_file_format("multiline") args.use_param_file("@%s", use_always = True)