This is an automated email from the ASF dual-hosted git repository. nvollmar pushed a commit to branch sbt-support in repository https://gitbox.apache.org/repos/asf/pekko-grpc.git
commit d1825363bb6408e5f2c4a1a68d243723da8388e4 Author: Nicolas Vollmar <[email protected]> AuthorDate: Wed Aug 12 13:52:59 2026 +0200 SBT 2 support for 1.2.0 --- .../org/apache/pekko/grpc/CommonBenchmark.scala | 1 + build.sbt | 44 +++++++++++-- .../scala/org/apache/pekko/grpc/gen/Main.scala | 8 ++- .../pekko/grpc/gen/javadsl/JavaCodeGenerator.scala | 2 +- .../apache/pekko/grpc/gen/javadsl/Service.scala | 2 +- .../grpc/gen/scaladsl/ScalaCodeGenerator.scala | 2 +- .../apache/pekko/grpc/gen/scaladsl/Service.scala | 2 +- project/Common.scala | 74 +++++++++++----------- project/Dependencies.scala | 14 ++-- project/build.properties | 2 +- project/plugins.sbt | 3 +- .../apache/pekko/grpc/sbt/GeneratorBridge.scala | 2 +- .../apache/pekko/grpc/sbt/PekkoGrpcPlugin.scala | 73 +++++++++++---------- .../src/sbt-test/scala3/03-sbt2-basic/build.sbt | 14 ++++ .../scala3/03-sbt2-basic/project/plugins.sbt | 10 +++ .../03-sbt2-basic/src/main/protobuf/echo.proto | 20 ++++++ sbt-plugin/src/sbt-test/scala3/03-sbt2-basic/test | 1 + 17 files changed, 179 insertions(+), 95 deletions(-) diff --git a/benchmarks/src/main/scala/org/apache/pekko/grpc/CommonBenchmark.scala b/benchmarks/src/main/scala/org/apache/pekko/grpc/CommonBenchmark.scala index 4babe8e0..fc829141 100644 --- a/benchmarks/src/main/scala/org/apache/pekko/grpc/CommonBenchmark.scala +++ b/benchmarks/src/main/scala/org/apache/pekko/grpc/CommonBenchmark.scala @@ -38,6 +38,7 @@ import org.openjdk.jmh.annotations.Warmup "-XX:InitialCodeCacheSize=512m", "-XX:ReservedCodeCacheSize=512m", "-XX:+UseParallelGC", + "-XX:+IgnoreUnrecognizedVMOptions", "-XX:-UseBiasedLocking", "-XX:+AlwaysPreTouch")) @BenchmarkMode(Array(Mode.Throughput)) diff --git a/build.sbt b/build.sbt index aca26929..707bf799 100644 --- a/build.sbt +++ b/build.sbt @@ -78,7 +78,7 @@ lazy val codegen = Project(id = "codegen", base = file("codegen")) case _ => MergeStrategy.deduplicate }, crossScalaVersions := Dependencies.Versions.CrossScalaForPlugin, - scalaVersion := scala212, + scalaVersion := Dependencies.Versions.CrossScalaForPlugin.head, Compile / unmanagedSourceDirectories ++= { if (scalaBinaryVersion.value == "2.12") { Seq.empty @@ -114,7 +114,8 @@ lazy val runtime = Project(id = "runtime", base = file("runtime")) AutomaticModuleName.settings("pekko.grpc.runtime"), ReflectiveCodeGen.generatedLanguages := Seq("Scala"), ReflectiveCodeGen.extraGenerators := Seq("ScalaMarshallersCodeGenerator"), - PB.protocVersion := Dependencies.Versions.googleProtoc) + PB.protocVersion := Dependencies.Versions.googleProtoc, + Test / PB.targets += (scalapb.gen() -> (Test / sourceManaged).value)) .enablePlugins(org.apache.pekko.grpc.build.ReflectiveCodeGen) .enablePlugins(ReproducibleBuildsPlugin) @@ -146,8 +147,8 @@ lazy val scalapbProtocPlugin = Project(id = "scalapb-protoc-plugin", base = file case _ => MergeStrategy.deduplicate }) .settings( - crossScalaVersions := Dependencies.Versions.CrossScalaForLib, - scalaVersion := Dependencies.Versions.CrossScalaForLib.head) + crossScalaVersions := Dependencies.Versions.CrossScalaAll, + scalaVersion := Dependencies.Versions.CrossScalaAll.head) .settings(addArtifact(Compile / assembly / artifact, assembly)) .settings(addArtifact(sbt.Artifact(pekkoGrpcProtocPluginId, "bat", "bat", "bat"), mkBatAssemblyTask)) .enablePlugins(ReproducibleBuildsPlugin) @@ -164,6 +165,9 @@ lazy val mavenPlugin = Project(id = "maven-plugin", base = file("maven-plugin")) scalaVersion := Dependencies.Versions.CrossScalaForPlugin.head) .dependsOn(codegen) +val pekkoGrpcVersion = "1.2.0" +val scalaPbVersion = "0.11.20" + lazy val sbtPlugin = Project(id = "sbt-plugin", base = file("sbt-plugin")) .enablePlugins(SbtPlugin) .enablePlugins(ReproducibleBuildsPlugin) @@ -171,7 +175,16 @@ lazy val sbtPlugin = Project(id = "sbt-plugin", base = file("sbt-plugin")) .settings(Dependencies.sbtPlugin) .settings( name := s"$pekkoPrefix-sbt-plugin", + sbtPluginPublishLegacyMavenStyle := true, + addSbtPlugin("com.github.sbt" % "sbt2-compat" % "0.1.0"), + pluginCrossBuild / sbtVersion := { + scalaBinaryVersion.value match { + case "2.12" => "1.12.11" + case _ => "2.0.1" + } + }, /** And for scripted tests: */ + scriptedSbt := (pluginCrossBuild / sbtVersion).value, scriptedLaunchOpts += ("-Dproject.version=" + version.value), scriptedLaunchOpts ++= sys.props.collect { case (k @ "sbt.ivy.home", v) => s"-D$k=$v" }.toSeq, scriptedDependencies := { @@ -180,11 +193,28 @@ lazy val sbtPlugin = Project(id = "sbt-plugin", base = file("sbt-plugin")) val p3 = (runtime / publishLocal).value val p4 = (interopTests / publishLocal).value }, - scriptedSbt := "1.11.7", - scriptedBufferLog := false) + scriptedBufferLog := false, + scalaVersion := "3.8.4", + scalacOptions ++= { + scalaBinaryVersion.value match { + case "2.12" => Seq("-Xsource:3") + case _ => Seq.empty + } + }) .settings( crossScalaVersions := Dependencies.Versions.CrossScalaForPlugin, - scalaVersion := Dependencies.Versions.CrossScalaForPlugin.head) + scalaVersion := Dependencies.Versions.CrossScalaForPlugin.head + ) + .settings( + libraryDependencies := libraryDependencies.value.filterNot(m => m.name == "compilerplugin"), + libraryDependencies ++= Seq( + ("org.apache.pekko" %% "pekko-grpc-codegen" % pekkoGrpcVersion) + .exclude("com.thesamet.scalapb", "compilerplugin_3"), + ("org.apache.pekko" %% "pekko-grpc-scalapb-protoc-plugin" % pekkoGrpcVersion) + .exclude("com.thesamet.scalapb", "compilerplugin_3"), + ("com.thesamet.scalapb" %% "compilerplugin" % scalaPbVersion).exclude("com.thesamet.scalapb", "protoc-bridge_2.13") + ) + ) .dependsOn(codegen) lazy val interopTests = Project(id = "interop-tests", base = file("interop-tests")) diff --git a/codegen/src/main/scala/org/apache/pekko/grpc/gen/Main.scala b/codegen/src/main/scala/org/apache/pekko/grpc/gen/Main.scala index bfe29ea8..0709c9af 100644 --- a/codegen/src/main/scala/org/apache/pekko/grpc/gen/Main.scala +++ b/codegen/src/main/scala/org/apache/pekko/grpc/gen/Main.scala @@ -15,13 +15,15 @@ package org.apache.pekko.grpc.gen import java.io.ByteArrayOutputStream import java.net.URLDecoder - import com.google.protobuf.compiler.PluginProtos.CodeGeneratorRequest import org.apache.pekko -import pekko.grpc.gen.javadsl.{ JavaClientCodeGenerator, JavaInterfaceCodeGenerator, JavaServerCodeGenerator } -import pekko.grpc.gen.scaladsl.{ ScalaClientCodeGenerator, ScalaServerCodeGenerator, ScalaTraitCodeGenerator } +import pekko.grpc.gen.javadsl.{JavaClientCodeGenerator, JavaInterfaceCodeGenerator, JavaServerCodeGenerator} +import pekko.grpc.gen.scaladsl.{ScalaClientCodeGenerator, ScalaServerCodeGenerator, ScalaTraitCodeGenerator} + +import scala.annotation.nowarn // This is the protoc plugin that the gradle plugin uses +@nowarn object Main extends App { val inBytes: Array[Byte] = { val baos = new ByteArrayOutputStream(math.max(64, System.in.available())) diff --git a/codegen/src/main/scala/org/apache/pekko/grpc/gen/javadsl/JavaCodeGenerator.scala b/codegen/src/main/scala/org/apache/pekko/grpc/gen/javadsl/JavaCodeGenerator.scala index 02f10f9a..4f695302 100644 --- a/codegen/src/main/scala/org/apache/pekko/grpc/gen/javadsl/JavaCodeGenerator.scala +++ b/codegen/src/main/scala/org/apache/pekko/grpc/gen/javadsl/JavaCodeGenerator.scala @@ -19,7 +19,7 @@ import protocbridge.Artifact import templates.JavaCommon.txt.ApiInterface import scala.annotation.nowarn -import scala.collection.JavaConverters._ +import scala.jdk.CollectionConverters.* import scala.collection.immutable import protocgen.CodeGenRequest diff --git a/codegen/src/main/scala/org/apache/pekko/grpc/gen/javadsl/Service.scala b/codegen/src/main/scala/org/apache/pekko/grpc/gen/javadsl/Service.scala index b3603f31..d7599442 100644 --- a/codegen/src/main/scala/org/apache/pekko/grpc/gen/javadsl/Service.scala +++ b/codegen/src/main/scala/org/apache/pekko/grpc/gen/javadsl/Service.scala @@ -18,7 +18,7 @@ import protocgen.CodeGenRequest import scalapb.compiler.{ DescriptorImplicits, GeneratorParams } import scala.annotation.tailrec -import scala.collection.JavaConverters._ +import scala.jdk.CollectionConverters.* import scala.collection.immutable final case class Service( diff --git a/codegen/src/main/scala/org/apache/pekko/grpc/gen/scaladsl/ScalaCodeGenerator.scala b/codegen/src/main/scala/org/apache/pekko/grpc/gen/scaladsl/ScalaCodeGenerator.scala index 3aa7ea16..cfa9a72d 100644 --- a/codegen/src/main/scala/org/apache/pekko/grpc/gen/scaladsl/ScalaCodeGenerator.scala +++ b/codegen/src/main/scala/org/apache/pekko/grpc/gen/scaladsl/ScalaCodeGenerator.scala @@ -14,7 +14,7 @@ package org.apache.pekko.grpc.gen.scaladsl import scala.annotation.nowarn -import scala.collection.JavaConverters._ +import scala.jdk.CollectionConverters.* import scala.collection.immutable import org.apache.pekko.grpc.gen.{ BuildInfo, CodeGenerator, Logger } import com.google.protobuf.compiler.PluginProtos.{ CodeGeneratorRequest, CodeGeneratorResponse } diff --git a/codegen/src/main/scala/org/apache/pekko/grpc/gen/scaladsl/Service.scala b/codegen/src/main/scala/org/apache/pekko/grpc/gen/scaladsl/Service.scala index 00fe6f6e..cc05adb0 100644 --- a/codegen/src/main/scala/org/apache/pekko/grpc/gen/scaladsl/Service.scala +++ b/codegen/src/main/scala/org/apache/pekko/grpc/gen/scaladsl/Service.scala @@ -14,7 +14,7 @@ package org.apache.pekko.grpc.gen.scaladsl import scala.collection.immutable -import scala.collection.JavaConverters._ +import scala.jdk.CollectionConverters.* import com.google.protobuf.Descriptors._ import protocgen.CodeGenRequest import scalapb.compiler.{ DescriptorImplicits, GeneratorParams } diff --git a/project/Common.scala b/project/Common.scala index ba528431..3b1f7218 100644 --- a/project/Common.scala +++ b/project/Common.scala @@ -38,49 +38,47 @@ object Common extends AutoPlugin { "Contributors", "[email protected]", url("https://github.com/apache/pekko-grpc/graphs/contributors")), - description := "Apache Pekko gRPC - Support for building streaming gRPC servers and clients on top of Pekko Streams.") + description := + "Apache Pekko gRPC - Support for building streaming gRPC servers and clients on top of Pekko Streams.") override lazy val projectSettings = Seq( projectInfoVersion := (if (isSnapshot.value) "snapshot" else version.value), - scalacOptions ++= (if (!isScala3.value) - Seq( - "-unchecked", - "-deprecation", - "-language:_", - "-Xfatal-warnings", - "-Ywarn-unused", - "-encoding", - "UTF-8") - else - Seq( - "-unchecked", - "-deprecation", - "-language:_", - "-Xfatal-warnings", - "-Wunused:imports", - "-encoding", - "UTF-8")), - Compile / scalacOptions ++= (if (!isScala3.value) - Seq( - // Generated code for methods/fields marked 'deprecated' - "-Wconf:msg=Marked as deprecated in proto file:silent", - // deprecated in 2.13, but used as long as we support 2.12 - "-Wconf:msg=Use `scala.jdk.CollectionConverters` instead:silent", - "-Wconf:msg=Use LazyList instead of Stream:silent", - // ignore imports in templates (FIXME why is that trailing .* needed?) - "-Wconf:src=.*.txt.*:silent", - "-Wconf:cat=unused-nowarn:silent") - else - Seq( - // Generated code for methods/fields marked 'deprecated' - "-Wconf:msg=Marked as deprecated in proto file:silent", - // deprecated in 2.13, but used as long as we support 2.12 - "-Wconf:msg=Use `scala.jdk.CollectionConverters` instead:silent", - "-Wconf:msg=instead of Stream:silent", - "-Wconf:msg=unused import:silent", - "-Wconf:cat=feature:silent")), + scalacOptions ++= + (if (!isScala3.value) + Seq( + "-unchecked", + "-deprecation", + "-language:_", + "-Xfatal-warnings", + "-Ywarn-unused", + "-encoding", + "UTF-8") + else + Seq( + "-unchecked", + "-deprecation", + "-Werror", + "-Wunused:imports", + "-encoding", + "UTF-8")), + Compile / scalacOptions ++= + (if (!isScala3.value) + Seq( + // Generated code for methods/fields marked 'deprecated' + "-Wconf:msg=Marked as deprecated in proto file:silent", + // ignore imports in templates (FIXME why is that trailing .* needed?) + "-Wconf:src=.*.txt.*:silent", + "-Wconf:cat=unused-nowarn:silent") + else + Seq( + // Generated code for methods/fields marked 'deprecated' + "-Wconf:msg=Marked as deprecated in proto file:silent", + "-Wconf:msg=unused import:silent", + "-Wconf:cat=feature:silent")), Compile / console / scalacOptions ~= (_.filterNot(consoleDisabledOptions.contains)), javacOptions ++= List("-Xlint:unchecked", "-Xlint:deprecation"), + Compile / compile / javacOptions ++= Seq("--release", "17"), + Compile / compile / scalacOptions ++= Seq("-release", "17"), Compile / doc / scalacOptions := scalacOptions.value ++ Seq( "-doc-title", "Apache Pekko gRPC", diff --git a/project/Dependencies.scala b/project/Dependencies.scala index 8904952b..1cf08100 100644 --- a/project/Dependencies.scala +++ b/project/Dependencies.scala @@ -16,13 +16,15 @@ import buildinfo.BuildInfo object Dependencies { object Versions { // Update the .github workflows when these scala versions change - val scala212 = "2.12.20" - val scala213 = "2.13.16" - val scala3 = "3.3.6" + val scala212 = "2.12.21" + val scala213 = "2.13.18" + val scala3 = "3.3.7" + val scala3_8 = "3.8.3" // the order in the list is important because the head will be considered the default. - val CrossScalaForLib = Seq(scala212, scala213, scala3) - val CrossScalaForPlugin = Seq(scala212) + val CrossScalaForLib = Seq(scala213, scala3) + val CrossScalaForPlugin = Seq(scala212, scala3_8) + val CrossScalaAll = Seq(scala212, scala213, scala3) // We don't force Pekko updates because downstream projects can upgrade // themselves. For more information see @@ -63,7 +65,7 @@ object Dependencies { val slf4jApi = "org.slf4j" % "slf4j-api" % "2.0.17" val mavenPluginApi = "org.apache.maven" % "maven-plugin-api" % Versions.maven val mavenCore = "org.apache.maven" % "maven-core" % Versions.maven - val protocJar = "com.github.os72" % "protoc-jar" % "3.11.4" + val protocJar = "io.github.blackrock" % "protoc-jar" % "3.0.0" val plexusBuildApi = "org.sonatype.plexus" % "plexus-build-api" % "0.0.7" % "optional" } diff --git a/project/build.properties b/project/build.properties index 01a16ed1..dabdb159 100644 --- a/project/build.properties +++ b/project/build.properties @@ -1 +1 @@ -sbt.version=1.11.7 +sbt.version=1.12.11 diff --git a/project/plugins.sbt b/project/plugins.sbt index 4a3bd6c0..2cd19855 100644 --- a/project/plugins.sbt +++ b/project/plugins.sbt @@ -9,7 +9,7 @@ enablePlugins(BuildInfoPlugin) -val sbtProtocV = "1.0.8" +val sbtProtocV = "1.1.0-RC1" buildInfoKeys := Seq[BuildInfoKey]("sbtProtocVersion" -> sbtProtocV) @@ -42,3 +42,4 @@ libraryDependencies += "org.eclipse.jgit" % "org.eclipse.jgit" % "5.13.3.2024011 libraryDependencies += "org.scala-sbt" %% "scripted-plugin" % sbtVersion.value libraryDependencies += "com.thesamet.scalapb" %% "compilerplugin" % "0.11.20" +//libraryDependencies += "com.thesamet.scalapb" %% "compilerplugin" % "1.0.0-alpha.5" diff --git a/sbt-plugin/src/main/scala/org/apache/pekko/grpc/sbt/GeneratorBridge.scala b/sbt-plugin/src/main/scala/org/apache/pekko/grpc/sbt/GeneratorBridge.scala index 13da7e15..7334a285 100644 --- a/sbt-plugin/src/main/scala/org/apache/pekko/grpc/sbt/GeneratorBridge.scala +++ b/sbt-plugin/src/main/scala/org/apache/pekko/grpc/sbt/GeneratorBridge.scala @@ -26,7 +26,7 @@ object GeneratorBridge { logger: Logger): protocbridge.Generator = { // This matches the sbt binary version (2.12) val codegenScalaBinaryVersion = CrossVersion.binaryScalaVersion(BuildInfo.scalaVersion) - protocbridge.SandboxedJvmGenerator( + protocbridge.SandboxedJvmGenerator.forResolver( codeGenerator.name, protocbridge.Artifact(BuildInfo.organization, s"${BuildInfo.name}_$codegenScalaBinaryVersion", BuildInfo.version), codeGenerator.suggestedDependencies(scalaBinaryVersion), 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 cbb06e77..3979138d 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 @@ -21,11 +21,10 @@ import pekko.grpc.gen.{ BuildInfo, Logger => GenLogger, ProtocSettings } import protocbridge.Generator import sbt.Keys._ import sbt._ +import sbtcompat.PluginCompat._ import sbtprotoc.ProtocPlugin import scalapb.ScalaPbCodeGenerator -import language.implicitConversions - object PekkoGrpcPlugin extends AutoPlugin { import sbtprotoc.ProtocPlugin.autoImport._ @@ -35,25 +34,22 @@ object PekkoGrpcPlugin extends AutoPlugin { // hack because we cannot access sbt logger from streams unless inside taskKeys and // we need it in settingsKeys - private val generatorLogger = new GenLogger { + private class MutableLogger extends GenLogger { @volatile var logger: Logger = ConsoleLogger() def debug(text: String): Unit = logger.debug(text) def info(text: String): Unit = logger.info(text) def warn(text: String): Unit = logger.warn(text) def error(text: String): Unit = logger.error(text) } + private val generatorLogger = new MutableLogger - object GeneratorOption extends Enumeration { - protected case class Val(setting: String) extends super.Val - implicit def valueToGeneratorOptionVal(x: Value): Val = x.asInstanceOf[Val] - - val ServerPowerApis = Val("server_power_apis") - val UsePlayActions = Val("use_play_actions") - - val settings: Set[String] = values.map(_.setting) + object GeneratorOption { + val ServerPowerApis = "server_power_apis" + val UsePlayActions = "use_play_actions" + val settings: Set[String] = Set(ServerPowerApis, UsePlayActions) } - trait Keys { _: autoImport.type => + trait Keys { self: autoImport.type => object PekkoGrpc { sealed trait GeneratedSource @@ -86,7 +82,7 @@ object PekkoGrpcPlugin extends AutoPlugin { object autoImport extends Keys import autoImport._ - override def projectSettings: Seq[sbt.Setting[_]] = defaultSettings ++ configSettings(Compile) ++ configSettings(Test) + override def projectSettings: Seq[sbt.Setting[?]] = defaultSettings ++ configSettings(Compile) ++ configSettings(Test) private def defaultSettings = Seq( @@ -101,19 +97,19 @@ object PekkoGrpcPlugin extends AutoPlugin { "com.thesamet.scalapb" %% "scalapb-runtime" % scalapb.compiler.Version.scalapbVersion % "protobuf") else Seq() }, - Compile / PB.recompile := { + Compile / PB.recompile := Def.uncached { // hack to get our (dirty) hands on a proper sbt logger before running the generators generatorLogger.logger = streams.value.log (Compile / PB.recompile).value }, - Test / PB.recompile := { + Test / PB.recompile := Def.uncached { // hack to get our (dirty) hands on a proper sbt logger before running the generators generatorLogger.logger = streams.value.log (Test / PB.recompile).value }, PB.protocVersion := BuildInfo.googleProtocVersion) - def configSettings(config: Configuration): Seq[Setting[_]] = + def configSettings(config: Configuration): Seq[Setting[?]] = inConfig(config)( (if (config == Compile || config == Test) Seq() // already supported by sbt-protoc by default else sbtprotoc.ProtocPlugin.protobufConfigSettings) ++ @@ -122,7 +118,9 @@ object PekkoGrpcPlugin extends AutoPlugin { configuration.value.name), managedSourceDirectories += (pekkoGrpcCodeGeneratorSettings / target).value, unmanagedResourceDirectories ++= (PB.recompile / resourceDirectories).value, - Defaults.ConfigGlobal / watchSources ++= (PB.recompile / sources).value, + Defaults.ConfigZero / watchSources ++= Def.uncached { + (PB.recompile / sources).value.map(f => WatchSource(f)) + }, pekkoGrpcGenerators := { generatorsFor( pekkoGrpcGeneratedSources.value, @@ -137,23 +135,30 @@ object PekkoGrpcPlugin extends AutoPlugin { (pekkoGrpcCodeGeneratorSettings / target).value, pekkoGrpcCodeGeneratorSettings.value, pekkoGrpcGenerators.value), - PB.protoSources += sourceDirectory.value / "proto") ++ - inTask(PB.recompile)(Seq( - includeFilter := GlobFilter("*.proto"), - managedSourceDirectories := Nil, - unmanagedSourceDirectories := Seq(sourceDirectory.value), - sourceDirectories := unmanagedSourceDirectories.value ++ managedSourceDirectories.value, - managedSources := Nil, - unmanagedSources := { Defaults.collectFiles(unmanagedSourceDirectories, includeFilter, excludeFilter).value }, - sources := managedSources.value ++ unmanagedSources.value, - managedResourceDirectories := Nil, - unmanagedResourceDirectories := resourceDirectory.value +: PB.protoSources.value, - resourceDirectories := unmanagedResourceDirectories.value ++ managedResourceDirectories.value, - managedResources := Nil, - unmanagedResources := { - Defaults.collectFiles(unmanagedResourceDirectories, includeFilter, excludeFilter).value - }, - resources := managedResources.value ++ unmanagedResources.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)) def targetsFor( targetPath: File, diff --git a/sbt-plugin/src/sbt-test/scala3/03-sbt2-basic/build.sbt b/sbt-plugin/src/sbt-test/scala3/03-sbt2-basic/build.sbt new file mode 100644 index 00000000..8509801e --- /dev/null +++ b/sbt-plugin/src/sbt-test/scala3/03-sbt2-basic/build.sbt @@ -0,0 +1,14 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * license agreements; and to You under the Apache License, version 2.0: + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * This file is part of the Apache Pekko project, which was derived from Akka. + */ + +// Verify that the pekko-grpc sbt plugin cross-builds correctly for sbt 1.x and sbt 2.x. +// When run in the Scala 3 build pass (+scripted), scriptedSbt is set to 2.x.y. +scalaVersion := "3.3.7" + +enablePlugins(PekkoGrpcPlugin) diff --git a/sbt-plugin/src/sbt-test/scala3/03-sbt2-basic/project/plugins.sbt b/sbt-plugin/src/sbt-test/scala3/03-sbt2-basic/project/plugins.sbt new file mode 100644 index 00000000..5eb2b655 --- /dev/null +++ b/sbt-plugin/src/sbt-test/scala3/03-sbt2-basic/project/plugins.sbt @@ -0,0 +1,10 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * license agreements; and to You under the Apache License, version 2.0: + * + * https://www.apache.org/licenses/LICENSE-2.0 + * + * This file is part of the Apache Pekko project, which was derived from Akka. + */ + +addSbtPlugin("org.apache.pekko" % "pekko-grpc-sbt-plugin" % sys.props("project.version")) diff --git a/sbt-plugin/src/sbt-test/scala3/03-sbt2-basic/src/main/protobuf/echo.proto b/sbt-plugin/src/sbt-test/scala3/03-sbt2-basic/src/main/protobuf/echo.proto new file mode 100644 index 00000000..1e4a2075 --- /dev/null +++ b/sbt-plugin/src/sbt-test/scala3/03-sbt2-basic/src/main/protobuf/echo.proto @@ -0,0 +1,20 @@ +syntax = "proto3"; + +option java_multiple_files = true; +option java_package = "example.myapp.echo.grpc"; +option java_outer_classname = "EchoProto"; + +package echo; + +// Simple echo service used to verify sbt-plugin code generation under sbt 2. +service EchoService { + rpc Echo (EchoRequest) returns (EchoReply) {} +} + +message EchoRequest { + string message = 1; +} + +message EchoReply { + string message = 1; +} diff --git a/sbt-plugin/src/sbt-test/scala3/03-sbt2-basic/test b/sbt-plugin/src/sbt-test/scala3/03-sbt2-basic/test new file mode 100644 index 00000000..5df2af1f --- /dev/null +++ b/sbt-plugin/src/sbt-test/scala3/03-sbt2-basic/test @@ -0,0 +1 @@ +> compile --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
