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

use string interpolation instead of format method #207

Merged
merged 1 commit into from
Oct 13, 2024
Merged
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
14 changes: 7 additions & 7 deletions src/main/scala/sbtprotobuf/ProtobufPlugin.scala
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class ScopedProtobufPlugin(configuration: Configuration, private[sbtprotobuf] va

protobufProtocOptions ++= { // if a java target is provided, add java generation option
(ProtobufConfig / protobufGeneratedTargets).value.find(_._2.endsWith(".java")) match {
case Some(targetForJava) => Seq("--java_out=%s".format(targetForJava._1.getCanonicalPath))
case Some(targetForJava) => Seq(s"--java_out=${targetForJava._1.getCanonicalPath}")
case None => Nil
}
},
Expand All @@ -127,7 +127,7 @@ class ScopedProtobufPlugin(configuration: Configuration, private[sbtprotobuf] va
extractFile(ur, protocGenGrpcJavaArtifactName)
}
((ProtobufConfig / protobufGeneratedTargets).value.find(_._2.endsWith(".java")) match {
case Some(targetForJava) => Seq("--java_rpc_out=%s".format(targetForJava._1.getCanonicalPath))
case Some(targetForJava) => Seq(s"--java_rpc_out=${targetForJava._1.getCanonicalPath}")
case None => Nil
}) ++ Seq(
s"--plugin=protoc-gen-java_rpc=${grpcCli}"
Expand Down Expand Up @@ -170,7 +170,7 @@ class ScopedProtobufPlugin(configuration: Configuration, private[sbtprotobuf] va
val incPath = includePaths.map("-I" + _.getCanonicalPath)
protocCommand(incPath ++ protocOptions ++ schemas.map(_.getCanonicalPath))
} catch { case e: Exception =>
throw new RuntimeException("error occurred while compiling protobuf files: %s" format(e.getMessage), e)
throw new RuntimeException(s"error occurred while compiling protobuf files: ${e.getMessage}", e)
}

private[this] def compile(
Expand All @@ -188,18 +188,18 @@ class ScopedProtobufPlugin(configuration: Configuration, private[sbtprotobuf] va
}

if(!schemas.isEmpty){
log.info("compiling %d protobuf files to %s".format(schemas.size, generatedTargetDirs.mkString(",")))
log.info(s"compiling ${schemas.size} protobuf files to ${generatedTargetDirs.mkString(",")}")
log.debug("protoc options:")
protocOptions.map("\t"+_).foreach(log.debug(_))
schemas.foreach(schema => log.info("Compiling schema %s" format schema))
schemas.foreach(schema => log.info(s"Compiling schema ${schema}"))

val exitCode = executeProtoc(protocCommand, schemas, includePaths, protocOptions, log)
if (exitCode != 0)
sys.error("protoc returned exit code: %d" format exitCode)
sys.error(s"protoc returned exit code: ${exitCode}")

log.info("Compiling protobuf")
generatedTargetDirs.foreach{ dir =>
log.info("Protoc target directory: %s".format(dir.absolutePath))
log.info(s"Protoc target directory: ${dir.absolutePath}")
}

(generatedTargets.flatMap{ot => (ot._1 ** ot._2).get}).toSet
Expand Down