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

#1625 fix transformer not picked up #1626

Merged
merged 2 commits into from
Dec 17, 2021
Merged
Changes from 1 commit
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
26 changes: 16 additions & 10 deletions contrib/scalapblib/src/ScalaPBWorker.scala
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,18 @@ class ScalaPBWorker {

val instance = new ScalaPBWorkerApi {
override def compileScalaPB(
source: File,
root: File,
sources: Seq[File],
scalaPBOptions: String,
generatedDirectory: File,
otherArgs: Seq[String]
): Unit = {
val opts = if (scalaPBOptions.isEmpty) "" else scalaPBOptions + ":"
val args = otherArgs ++ Seq(
s"--scala_out=${opts}${generatedDirectory.getCanonicalPath}",
s"--proto_path=${source.getParentFile.getCanonicalPath}",
source.getCanonicalPath
)
s"--proto_path=${root.getCanonicalPath}"
) ++ sources.map(_.getCanonicalPath)
ctx.log.debug(args.mkString(" "))
borissmidt marked this conversation as resolved.
Show resolved Hide resolved
mainMethod.invoke(null, args.toArray)
}
}
Expand Down Expand Up @@ -80,16 +81,20 @@ class ScalaPBWorker {
scalaPBOptions: String,
dest: os.Path,
scalaPBCExtraArgs: Seq[String]
)(implicit ctx: mill.api.Ctx): mill.api.Result[PathRef] = {
)(
implicit ctx: mill.api.Ctx
): mill.api.Result[PathRef] = {
val compiler = scalaPB(scalaPBClasspath)

def compileScalaPBDir(inputDir: os.Path): Unit = {
// ls throws if the path doesn't exist
if (inputDir.toIO.exists) {
os.walk(inputDir).filter(_.last.matches(".*.proto"))
.foreach { proto =>
compiler.compileScalaPB(proto.toIO, scalaPBOptions, dest.toIO, scalaPBCExtraArgs)
}
val files = os
.walk(inputDir)
.filter(_.last.matches(".*.proto"))
.map(_.toIO)
.toIndexedSeq
compiler.compileScalaPB(inputDir.toIO, files, scalaPBOptions, dest.toIO, scalaPBCExtraArgs)
}
}

Expand All @@ -101,7 +106,8 @@ class ScalaPBWorker {

trait ScalaPBWorkerApi {
def compileScalaPB(
source: File,
root: File,
source: Seq[File],
scalaPBOptions: String,
generatedDirectory: File,
otherArgs: Seq[String]
Expand Down