pekko/project/VersionGenerator.scala
Patrik Nordwall 5c96a5f556 replace unicode arrows
* ⇒, →, ←
* because we don't want to show them in documentation snippets and
  then it's complicated to avoid that when snippets are
  located in src/test/scala in individual modules
* dont replace object `→` in FSM.scala and PersistentFSM.scala
2019-03-11 16:58:51 +01:00

34 lines
938 B
Scala

/*
* Copyright (C) 2016-2019 Lightbend Inc. <https://www.lightbend.com>
*/
package akka
import sbt._
import sbt.Keys._
/**
* Generate version.conf and akka/Version.scala files based on the version setting.
*/
object VersionGenerator {
val settings: Seq[Setting[_]] = inConfig(Compile)(Seq(
resourceGenerators += generateVersion(resourceManaged, _ / "version.conf",
"""|akka.version = "%s"
|"""),
sourceGenerators += generateVersion(sourceManaged, _ / "akka" / "Version.scala",
"""|package akka
|
|object Version {
| val current: String = "%s"
|}
|""")))
def generateVersion(dir: SettingKey[File], locate: File => File, template: String) = Def.task[Seq[File]] {
val file = locate(dir.value)
val content = template.stripMargin.format(version.value)
if (!file.exists || IO.read(file) != content) IO.write(file, content)
Seq(file)
}
}