Skip to content

Commit

Permalink
workaround. set custom routesGenerator
Browse files Browse the repository at this point in the history
  • Loading branch information
xuwei-k committed Oct 20, 2020
1 parent 0cc2569 commit 0341fb7
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,31 @@ remoteCacheId := "fixed-id"
remoteCacheIdCandidates := Seq(remoteCacheId.value)

pushRemoteCacheConfiguration := pushRemoteCacheConfiguration.value.withOverwrite(true)

routesGenerator := {
import play.routes.compiler.{RoutesCompiler, RoutesGenerator, Rule}
val base = InjectedRoutesGenerator
new RoutesGenerator {
override def generate(
task: RoutesCompiler.RoutesCompilerTask,
namespace: Option[String],
rules: List[Rule]
): Seq[(String, String)] = {
val baseDir = (ThisBuild / baseDirectory).value.getCanonicalPath + "/"
val sourceCommentPrefix = s"// @SOURCE:${baseDir}"
base.generate(task = task, namespace = namespace, rules = rules).map {
case (fileName, src) =>
fileName -> src.linesIterator
.filterNot(_ contains "@DATE")
.map {
case line if line.startsWith(sourceCommentPrefix) =>
line.replace(baseDir, "")
case line =>
line
}
.mkString("\n")
}
}
override def id = base.id
}
}

0 comments on commit 0341fb7

Please sign in to comment.