From c3b432d6dc04425df1092c412615220ed2c7900c Mon Sep 17 00:00:00 2001 From: Nadav Samet Date: Sat, 30 Jan 2021 19:06:57 -0800 Subject: [PATCH] Add scripted for PGV protos when project has flat_package=true For scalapb/scalapb-validate#70 --- src/sbt-test/integration/common-protos/build.sbt | 10 ++++++++++ .../integration/common-protos/project/plugins.sbt | 11 +++++++++++ .../common-protos/src/main/protobuf/test.proto | 7 +++++++ src/sbt-test/integration/common-protos/test | 1 + 4 files changed, 29 insertions(+) create mode 100644 src/sbt-test/integration/common-protos/build.sbt create mode 100644 src/sbt-test/integration/common-protos/project/plugins.sbt create mode 100644 src/sbt-test/integration/common-protos/src/main/protobuf/test.proto create mode 100644 src/sbt-test/integration/common-protos/test diff --git a/src/sbt-test/integration/common-protos/build.sbt b/src/sbt-test/integration/common-protos/build.sbt new file mode 100644 index 00000000..80fe98f4 --- /dev/null +++ b/src/sbt-test/integration/common-protos/build.sbt @@ -0,0 +1,10 @@ +import scalapb.compiler.Version.protobufVersion + +scalaVersion := "2.13.4" + +Compile / PB.targets := Seq(scalapb.gen(flatPackage=true) -> (Compile / sourceManaged).value) + +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" +) diff --git a/src/sbt-test/integration/common-protos/project/plugins.sbt b/src/sbt-test/integration/common-protos/project/plugins.sbt new file mode 100644 index 00000000..013577d8 --- /dev/null +++ b/src/sbt-test/integration/common-protos/project/plugins.sbt @@ -0,0 +1,11 @@ +{ + val pluginVersion = System.getProperty("plugin.version") + if(pluginVersion == null) + throw new RuntimeException("""|The system property 'plugin.version' is not defined. + |Specify this property using the scriptedLaunchOpts -D.""".stripMargin) + else addSbtPlugin("com.thesamet" % "sbt-protoc" % pluginVersion) +} + +libraryDependencies ++= Seq( + "com.thesamet.scalapb" %% "compilerplugin" % "0.10.11" +) diff --git a/src/sbt-test/integration/common-protos/src/main/protobuf/test.proto b/src/sbt-test/integration/common-protos/src/main/protobuf/test.proto new file mode 100644 index 00000000..a76c4183 --- /dev/null +++ b/src/sbt-test/integration/common-protos/src/main/protobuf/test.proto @@ -0,0 +1,7 @@ +syntax = "proto3"; + +import "validate/validate.proto"; + +message Foo { + validate.Int32Rules rules = 1; +} diff --git a/src/sbt-test/integration/common-protos/test b/src/sbt-test/integration/common-protos/test new file mode 100644 index 00000000..5df2af1f --- /dev/null +++ b/src/sbt-test/integration/common-protos/test @@ -0,0 +1 @@ +> compile