2023-01-08 17:13:31 +08:00
|
|
|
/*
|
|
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
|
* license agreements; and to You under the Apache License, version 2.0:
|
|
|
|
|
*
|
|
|
|
|
* https://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
*
|
2023-06-22 14:19:26 +01:00
|
|
|
* This file is part of the Apache Pekko project, which was derived from Akka.
|
2023-01-08 17:13:31 +08:00
|
|
|
*/
|
|
|
|
|
|
2019-01-02 18:55:26 +08:00
|
|
|
/*
|
2022-02-04 12:36:44 +01:00
|
|
|
* Copyright (C) 2016-2022 Lightbend Inc. <https://www.lightbend.com>
|
2016-02-23 12:58:39 +01:00
|
|
|
*/
|
2018-03-13 23:45:55 +09:00
|
|
|
|
2016-02-12 17:57:27 +13:00
|
|
|
import sbt._
|
|
|
|
|
import sbt.Keys._
|
|
|
|
|
|
|
|
|
|
/**
|
2022-12-02 04:53:48 -08:00
|
|
|
* Generate version.conf and org/apache/pekko/Version.scala files based on the version setting.
|
2016-02-12 17:57:27 +13:00
|
|
|
*/
|
2017-10-30 03:13:14 +02:00
|
|
|
object VersionGenerator {
|
2016-02-12 17:57:27 +13:00
|
|
|
|
2021-02-01 15:38:29 +00:00
|
|
|
val settings: Seq[Setting[_]] = inConfig(Compile)(
|
|
|
|
|
Seq(
|
2022-12-02 04:53:48 -08:00
|
|
|
resourceGenerators += generateVersion(
|
|
|
|
|
resourceManaged, _ / "version.conf",
|
|
|
|
|
"""|pekko.version = "%s"
|
|
|
|
|
|"""),
|
|
|
|
|
sourceGenerators += generateVersion(
|
|
|
|
|
sourceManaged, _ / "org" / "apache" / "pekko" / "Version.scala",
|
|
|
|
|
"""|package org.apache.pekko
|
|
|
|
|
|
|
|
|
|
|
|object Version {
|
|
|
|
|
| val current: String = "%s"
|
|
|
|
|
|}
|
|
|
|
|
|""")))
|
2016-02-12 17:57:27 +13:00
|
|
|
|
2019-02-09 15:25:39 +01:00
|
|
|
def generateVersion(dir: SettingKey[File], locate: File => File, template: String) = Def.task[Seq[File]] {
|
2016-02-12 17:57:27 +13:00
|
|
|
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)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|