我正在尝试使用sbt multi-project配置一个新的Scala版本。我想使用sbt-protoc,尤其是ScalaPB,它需要以下配置设置:
Compile / PB.targets := Seq(
scalapb.gen() -> (Compile / sourceManaged).value
)现在的问题是如何在多项目中正确地应用sbt.librarymanagement.Configurations.Compile配置。我使用的是Scala 2.13和sbt 1.4.7。
我当前的build.sbt
Compile / PB.targets := Seq(
scalapb.gen() -> (Compile / sourceManaged).value
)
lazy val commonSettings = List(
scalaVersion := scala212,
scalacOptions ++= Seq(
"utf8",
"-Ypartial-unification"
)
)
lazy val core = (project in file("core"))
.settings(
commonSettings,
name := "twirp4s-core",
crossScalaVersions := Seq(scala212, scala213),
libraryDependencies ++= Seq(
catsCore,
circeCore,
circeGeneric,
circeParser,
http4sDsl,
http4sCirce
),
addCompilerPlugin(betterMonadicForPlugin),
)
lazy val root = (project in file("."))
.aggregate(core)
.settings(
name := "twirp4s-root",
libraryDependencies += scalaTest % Test,
skip in publish := true
)当我尝试编译我的项目时,编译器说:
[info] Protobufs files found, but PB.targets is empty.发布于 2021-02-08 20:59:05
正如你已经知道的,@Seth在评论中建议,将Compile / PB.targets移动到core.settings中是可行的。这是您应该使用的build.sbt:
lazy val commonSettings = List(
scalaVersion := scala212,
scalacOptions ++= Seq(
"utf8",
"-Ypartial-unification"
)
)
lazy val core = (project in file("core"))
.settings(
commonSettings,
name := "twirp4s-core",
crossScalaVersions := Seq(scala212, scala213),
libraryDependencies ++= Seq(
catsCore,
circeCore,
circeGeneric,
circeParser,
http4sDsl,
http4sCirce
),
addCompilerPlugin(betterMonadicForPlugin),
Compile / PB.targets := Seq(
scalapb.gen() -> (Compile / sourceManaged).value
)
)
lazy val root = (project in file("."))
.aggregate(core)
.settings(
name := "twirp4s-root",
libraryDependencies += scalaTest % Test,
skip in publish := true
)https://stackoverflow.com/questions/66089595
复制相似问题