Skip to content

Commit

Permalink
sbt-plugin: make code gen output path configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
ahjohannessen committed Sep 16, 2020
1 parent ff77ff7 commit ff51b8d
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
5 changes: 3 additions & 2 deletions .gitignore
Expand Up @@ -7,5 +7,6 @@ target/
# Metals
.metals/*
.bloop/*
project/.bloop/*
project/metals.sbt
.vscode/*
**/.bloop/*
**/metals.sbt
9 changes: 8 additions & 1 deletion sbt-java-gen/src/main/scala/Fs2GrpcPlugin.scala
Expand Up @@ -47,14 +47,20 @@ object Fs2GrpcPlugin extends AutoPlugin {

val scalapbCodeGeneratorOptions =
settingKey[Seq[CodeGeneratorOption]]("Settings for scalapb/fs2-grpc code generation")

val scalapbProtobufDirectory =
settingKey[File]("Directory containing protobuf files for scalapb")

val scalapbCodeGenerators =
settingKey[Seq[Target]]("Code generators for scalapb")

val fs2GrpcServiceSuffix =
settingKey[String](
"Suffix used for generated service, e.g. service `Foo` with suffix `Fs2Grpc` results in `FooFs2Grpc`"
)

val fs2GrpcOutputPath =
settingKey[File]("Directory for sources generated by fs2-grpc")
}
import autoImport._

Expand All @@ -76,6 +82,7 @@ object Fs2GrpcPlugin extends AutoPlugin {
override def projectSettings: Seq[Def.Setting[_]] =
List(
fs2GrpcServiceSuffix := "Fs2Grpc",
fs2GrpcOutputPath := (sourceManaged in Compile).value / "fs2-grpc",
scalapbProtobufDirectory := (sourceManaged in Compile).value / "scalapb",
scalapbCodeGenerators := {
Target(
Expand All @@ -98,7 +105,7 @@ object Fs2GrpcPlugin extends AutoPlugin {
scalapbCodeGeneratorOptions.value.filterNot(_ == CodeGeneratorOption.Fs2Grpc).map(_.toString) :+
s"serviceSuffix=${fs2GrpcServiceSuffix.value}"
),
(sourceManaged in Compile).value / "fs2-grpc"
fs2GrpcOutputPath.value
)
).filter(_ => scalapbCodeGeneratorOptions.value.contains(CodeGeneratorOption.Fs2Grpc)).toList
},
Expand Down

0 comments on commit ff51b8d

Please sign in to comment.