Skip to content

Commit

Permalink
handle duplicated protos in include paths with ScalaPB-Options-Proto
Browse files Browse the repository at this point in the history
> .../bottom/target/protobuf_external/validate/scalapb-options.proto":
> Input is shadowed in the --proto_path by
> ".../top/target/protobuf_external/validate/scalapb-options.proto".
> Either use the latter file as your input or reorder the --proto_path
> so that the former file's location comes first.
  • Loading branch information
github-brice-jaglin authored and thesamet committed Feb 8, 2021
1 parent 700bbb8 commit 8cfee50
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/main/scala/sbtprotoc/ProtocPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -305,8 +305,8 @@ object ProtocPlugin extends AutoPlugin {
PB.includePaths := (
PB.includePaths.?.value.getOrElse(Nil) ++
PB.protoSources.value ++
protocIncludeDependencies.value ++
Seq(PB.externalIncludePath.value, PB.externalSourcePath.value),
Seq(PB.externalIncludePath.value, PB.externalSourcePath.value) ++
protocIncludeDependencies.value,
).distinct,
PB.generate := sourceGeneratorTask(PB.generate)
.dependsOn(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
syntax = "proto3";

import "validate/validate.proto";

message Bar {
validate.Int32Rules rules = 1;
}
19 changes: 13 additions & 6 deletions src/sbt-test/integration/common-protos/build.sbt
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
import scalapb.compiler.Version.protobufVersion
ThisBuild / scalaVersion := "2.13.4"

scalaVersion := "2.13.4"
lazy val top = (project in file("top"))
.settings(commonSettings)

Compile / PB.targets := Seq(scalapb.gen(flatPackage=true) -> (Compile / sourceManaged).value)
lazy val bottom = (project in file("bottom"))
.dependsOn(top)
.settings(commonSettings)

libraryDependencies ++= Seq(
"com.thesamet.scalapb.common-protos" %% "pgv-proto-scalapb_0.10" % "0.4.1-1" % "protobuf",
"com.thesamet.scalapb.common-protos" %% "pgv-proto-scalapb_0.10" % "0.4.1-1"
lazy val commonSettings = Seq(
Compile / PB.targets := Seq(scalapb.gen(flatPackage = true) -> (Compile / sourceManaged).value),
libraryDependencies ++= Seq(
// Announcing compilation with flatPackage=false in `ScalaPB-Options-Proto`
"com.thesamet.scalapb.common-protos" %% "pgv-proto-scalapb_0.10" % "0.4.1-1" % "protobuf",
"com.thesamet.scalapb.common-protos" %% "pgv-proto-scalapb_0.10" % "0.4.1-1"
)
)
5 changes: 4 additions & 1 deletion src/sbt-test/integration/common-protos/test
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
> compile
> bottom/compile

$ exists ./top/target/scala-2.13/classes/Foo.class
$ exists ./bottom/target/scala-2.13/classes/Bar.class

0 comments on commit 8cfee50

Please sign in to comment.