Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ScalaPB Plugin: Add option scala3_sources #3258

Merged
merged 6 commits into from
Jan 21, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions contrib/scalapblib/readme.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ example/

* scalaPBSearchDeps - A `Boolean` option which determines whether to search for `.proto` files in dependencies and add them to `scalaPBIncludePath`. Defaults to `false`.

* scalaPBScala3Sources - Generate the sources with scala 3 syntax (i. e. use `?` instead of `_` in types)

* scalaPBIncludePath - Additional paths to include `.proto` files when compiling.

If you'd like to configure the https://scalapb.github.io/docs/scalapbc#passing-generator-parameters[options] that are passed to the ScalaPB compiler directly, you can override the `scalaPBOptions` task, for example:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ trait ScalaPBModule extends ScalaModule {
/** ScalaPB enables lenses by default, this option allows you to disable it. */
def scalaPBLenses: T[Boolean] = Task { true }

def scalaPBScala3Sources: T[Boolean] = T { false }

def scalaPBSearchDeps: Boolean = false

/**
Expand Down Expand Up @@ -68,7 +70,8 @@ trait ScalaPBModule extends ScalaModule {
else
Seq("single_line_to_string")
}
)
) ++
(if (scalaPBScala3Sources()) Seq("scala3_sources") else Seq.empty)
).mkString(",")
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,12 @@ object TutorialTests extends TestSuite {
}
}

object TutorialWithScala3Soures extends TutorialBase {
object core extends TutorialModule {
override def scalaPBScala3Sources = { true }
}
}

val resourcePath: os.Path = os.Path(sys.env("MILL_TEST_RESOURCE_DIR"))

def protobufOutPath(eval: UnitTester): os.Path =
Expand Down Expand Up @@ -177,6 +183,12 @@ object TutorialTests extends TestSuite {
}
}

test("calledWithScala3Sources") - UnitTester(TutorialWithScala3Soures, resourcePath).scoped {
eval =>
val result = eval.apply(Tutorial.core.compileScalaPB)
assert(result.isRight)
}

test("compilationArgs") {
test("calledWithAdditionalArgs") - UnitTester(
TutorialWithAdditionalArgs,
Expand Down
Loading