This is an automated email from the ASF dual-hosted git repository.
raboof pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/pekko-grpc.git
The following commit(s) were added to refs/heads/main by this push:
new 800ec108 fix: consistently include proto's in built artifacts (#746)
800ec108 is described below
commit 800ec10882c87fb12eb321a0803dd75310261b21
Author: Arnout Engelen <[email protected]>
AuthorDate: Thu Jun 25 14:27:29 2026 +0200
fix: consistently include proto's in built artifacts (#746)
Earlier it would depend on the task ordering between the download task
and the resource discovery task, this should make it deterministic
---
.../apache/pekko/grpc/sbt/PekkoGrpcPlugin.scala | 48 +++++++++++-----------
.../sbt-test/gen-scala-server/00-interop/build.sbt | 9 ++++
.../src/sbt-test/gen-scala-server/00-interop/test | 1 +
3 files changed, 33 insertions(+), 25 deletions(-)
diff --git
a/sbt-plugin/src/main/scala/org/apache/pekko/grpc/sbt/PekkoGrpcPlugin.scala
b/sbt-plugin/src/main/scala/org/apache/pekko/grpc/sbt/PekkoGrpcPlugin.scala
index 553b78dd..3d615020 100644
--- a/sbt-plugin/src/main/scala/org/apache/pekko/grpc/sbt/PekkoGrpcPlugin.scala
+++ b/sbt-plugin/src/main/scala/org/apache/pekko/grpc/sbt/PekkoGrpcPlugin.scala
@@ -117,7 +117,28 @@ object PekkoGrpcPlugin extends AutoPlugin {
pekkoGrpcCodeGeneratorSettings / target := crossTarget.value /
"pekko-grpc" / Defaults.nameForSrc(
configuration.value.name),
managedSourceDirectories += (pekkoGrpcCodeGeneratorSettings /
target).value,
- unmanagedResourceDirectories ++= (PB.recompile /
resourceDirectories).value,
+ packageBin / mappings := {
+ val existingMappings = (packageBin / mappings).value
+ val unpackedFiles = PB.unpackDependencies.value.files
+ val mappingsToAdd =
+
unpackedFiles.pair(Path.relativeTo(Seq(PB.externalSourcePath.value,
PB.externalIncludePath.value)))
+ @scala.annotation.tailrec
+ def withoutDuplicates(soFar: List[(File, String)], seen:
Set[String], toAdd: Seq[(File, String)])
+ : Seq[(File, String)] = {
+ toAdd.headOption match {
+ case Some((file, string)) =>
+ if (seen.contains(string)) {
+ withoutDuplicates(soFar, seen, toAdd.tail)
+ } else {
+ withoutDuplicates((file, string) :: soFar, seen + string,
toAdd.tail)
+ }
+ case None =>
+ soFar
+ }
+ }
+ withoutDuplicates(existingMappings.toList,
existingMappings.map(_._2).toSet, mappingsToAdd)
+ },
+ unmanagedResourceDirectories ++= (PB.recompile /
unmanagedResourceDirectories).value,
Defaults.ConfigZero / watchSources ++= Def.uncached {
(PB.recompile / sources).value.map(f => WatchSource(f))
},
@@ -135,30 +156,7 @@ object PekkoGrpcPlugin extends AutoPlugin {
(pekkoGrpcCodeGeneratorSettings / target).value,
pekkoGrpcCodeGeneratorSettings.value,
pekkoGrpcGenerators.value),
- PB.protoSources += sourceDirectory.value / "proto")) ++
- inConfig(config)(Seq(
- PB.recompile / includeFilter := GlobFilter("*.proto"),
- PB.recompile / managedSourceDirectories := Nil,
- PB.recompile / unmanagedSourceDirectories := Seq(sourceDirectory.value),
- PB.recompile / sourceDirectories := (PB.recompile /
unmanagedSourceDirectories).value ++
- (PB.recompile / managedSourceDirectories).value,
- PB.recompile / managedSources := Nil,
- PB.recompile / unmanagedSources := {
- Defaults.collectFiles(PB.recompile / unmanagedSourceDirectories,
PB.recompile / includeFilter,
- PB.recompile / excludeFilter).value
- },
- PB.recompile / sources := (PB.recompile / managedSources).value ++
(PB.recompile / unmanagedSources).value,
- PB.recompile / managedResourceDirectories := Nil,
- PB.recompile / unmanagedResourceDirectories := resourceDirectory.value
+: PB.protoSources.value,
- PB.recompile / resourceDirectories := (PB.recompile /
unmanagedResourceDirectories).value ++
- (PB.recompile / managedResourceDirectories).value,
- PB.recompile / managedResources := Nil,
- PB.recompile / unmanagedResources := {
- Defaults.collectFiles(PB.recompile / unmanagedResourceDirectories,
PB.recompile / includeFilter,
- PB.recompile / excludeFilter).value
- },
- PB.recompile / resources := (PB.recompile / managedResources).value ++
- (PB.recompile / unmanagedResources).value))
+ PB.protoSources += sourceDirectory.value / "proto"))
def targetsFor(
targetPath: File,
diff --git a/sbt-plugin/src/sbt-test/gen-scala-server/00-interop/build.sbt
b/sbt-plugin/src/sbt-test/gen-scala-server/00-interop/build.sbt
index 9048218c..69c842ab 100644
--- a/sbt-plugin/src/sbt-test/gen-scala-server/00-interop/build.sbt
+++ b/sbt-plugin/src/sbt-test/gen-scala-server/00-interop/build.sbt
@@ -73,3 +73,12 @@ pekkoGrpcGeneratedSources := Seq(PekkoGrpc.Client,
PekkoGrpc.Server)
pekkoGrpcGeneratedLanguages := Seq(PekkoGrpc.Scala, PekkoGrpc.Java)
pekkoGrpcCodeGeneratorSettings :=
pekkoGrpcCodeGeneratorSettings.value.filterNot(_ == "flat_package")
//#languages-both
+
+// Make sure proto's reliably make it into the artifact:
+TaskKey[Unit]("checkJar") := {
+ val binary = (Compile / packageBin).value
+ IO.withTemporaryDirectory { dir =>
+ val files = IO.unzip(binary, dir, "*.proto")
+ assert(files.contains(dir / "google/protobuf/duration.proto"))
+ }
+}
diff --git a/sbt-plugin/src/sbt-test/gen-scala-server/00-interop/test
b/sbt-plugin/src/sbt-test/gen-scala-server/00-interop/test
index dfffb838..ae69d1b7 100644
--- a/sbt-plugin/src/sbt-test/gen-scala-server/00-interop/test
+++ b/sbt-plugin/src/sbt-test/gen-scala-server/00-interop/test
@@ -1 +1,2 @@
+> checkJar
> test
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]