* akka.build.version property, #26958 * and use timestamped snapshot version if "timestamp" is passed in * to support publishing snapshots with same version for Scala 2.12 and 2.13 with +publish * remove stampVersion plugin, since it's no longer needed * store currentDateTime in system property * to survive reloads
This commit is contained in:
parent
d9b6f633a0
commit
a9f4f2dd96
3 changed files with 22 additions and 42 deletions
|
|
@ -2,7 +2,6 @@ import akka.{ AutomaticModuleName, CopyrightHeaderForBuild, ParadoxSupport, Scal
|
|||
|
||||
enablePlugins(
|
||||
UnidocRoot,
|
||||
TimeStampede,
|
||||
UnidocWithPrValidation,
|
||||
NoPublish,
|
||||
CopyrightHeader,
|
||||
|
|
|
|||
|
|
@ -6,6 +6,9 @@ package akka
|
|||
|
||||
import java.io.{FileInputStream, InputStreamReader}
|
||||
import java.util.Properties
|
||||
import java.time.format.DateTimeFormatter
|
||||
import java.time.ZonedDateTime
|
||||
import java.time.ZoneOffset
|
||||
|
||||
import sbt.Keys._
|
||||
import sbt._
|
||||
|
|
@ -21,14 +24,31 @@ object AkkaBuild {
|
|||
|
||||
lazy val buildSettings = Dependencies.Versions ++ Seq(
|
||||
organization := "com.typesafe.akka",
|
||||
// use the same value as in the build scope, so it can be overriden by stampVersion
|
||||
// use the same value as in the build scope
|
||||
version := (version in ThisBuild).value)
|
||||
|
||||
lazy val currentDateTime = {
|
||||
// storing the first accessed timestamp in system property so that it will be the
|
||||
// same when build is reloaded or when using `+`.
|
||||
// `+` actually doesn't re-initialize this part of the build but that may change in the future.
|
||||
sys.props.getOrElseUpdate("akka.build.timestamp",
|
||||
DateTimeFormatter
|
||||
.ofPattern("yyyyMMdd-HHmmss")
|
||||
.format(ZonedDateTime.now(ZoneOffset.UTC)))
|
||||
}
|
||||
|
||||
def akkaVersion: String = {
|
||||
sys.props.getOrElse("akka.build.version", "2.6-SNAPSHOT") match {
|
||||
case "timestamp" => s"2.6-$currentDateTime" // used when publishing timestamped snapshots
|
||||
case v => v
|
||||
}
|
||||
}
|
||||
|
||||
lazy val rootSettings = Release.settings ++
|
||||
UnidocRoot.akkaSettings ++
|
||||
Protobuf.settings ++ Seq(
|
||||
parallelExecution in GlobalScope := System.getProperty("akka.parallelExecution", parallelExecutionByDefault.toString).toBoolean,
|
||||
version in ThisBuild := "2.6-SNAPSHOT"
|
||||
version in ThisBuild := akkaVersion
|
||||
)
|
||||
|
||||
lazy val mayChangeSettings = Seq(
|
||||
|
|
|
|||
|
|
@ -1,39 +0,0 @@
|
|||
/*
|
||||
* Copyright (C) 2009-2019 Lightbend Inc. <https://www.lightbend.com>
|
||||
*/
|
||||
|
||||
package akka
|
||||
|
||||
import java.time.Instant
|
||||
import java.time.LocalDateTime
|
||||
import java.time.ZoneId
|
||||
import java.time.format.DateTimeFormatter
|
||||
|
||||
import sbt._
|
||||
import sbt.Keys._
|
||||
|
||||
object TimeStampede extends AutoPlugin {
|
||||
|
||||
override def trigger = noTrigger
|
||||
|
||||
override lazy val projectSettings = Seq(
|
||||
commands += stampVersion)
|
||||
|
||||
final val Snapshot = "-SNAPSHOT"
|
||||
|
||||
def stampVersion = Command.command("stampVersion") { state =>
|
||||
val extracted = Project.extract(state)
|
||||
extracted.appendWithSession(List(version in ThisBuild ~= stamp), state)
|
||||
}
|
||||
|
||||
def stamp(version: String): String = {
|
||||
if (version endsWith Snapshot) (version stripSuffix Snapshot) + "-" + timestamp(System.currentTimeMillis)
|
||||
else version
|
||||
}
|
||||
|
||||
val formatter = DateTimeFormatter.ofPattern("yyyyMMdd-HHmmss")
|
||||
|
||||
def timestamp(time: Long): String = {
|
||||
formatter.format(LocalDateTime.ofInstant(Instant.ofEpochMilli(time), ZoneId.systemDefault()))
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue