diff --git a/build.sbt b/build.sbt index cb9b46a49f..eae15fa78d 100644 --- a/build.sbt +++ b/build.sbt @@ -15,7 +15,7 @@ def buildLevelSettings: Seq[Setting[_]] = Seq( // bintrayOrganization in ThisBuild := None, // bintrayRepository in ThisBuild := "test-test-test", bintrayOrganization in ThisBuild := Some("sbt"), - bintrayRepository in ThisBuild := "ivy-releases", + bintrayRepository in ThisBuild := s"ivy-${(publishStatus in ThisBuild).value}", bintrayPackage in ThisBuild := "sbt" ) diff --git a/project/StatusPlugin.scala b/project/StatusPlugin.scala index b9ea37f29d..6c33b3ebf5 100644 --- a/project/StatusPlugin.scala +++ b/project/StatusPlugin.scala @@ -1,20 +1,29 @@ import sbt._ import Keys._ -import java.util.regex.Pattern object StatusPlugin extends AutoPlugin { override def requires = plugins.JvmPlugin override def trigger = allRequirements object autoImport { - lazy val publishStatus = SettingKey[String]("publish-status") + lazy val publishStatus = settingKey[String]("possible values are snapshots or releases.") } import autoImport._ override def buildSettings: Seq[Setting[_]] = Seq( - isSnapshot <<= version(v => v.contains("-") && snapshotQualifier(v)), - publishStatus <<= isSnapshot { snap => if (snap) "snapshots" else "releases" }, + isSnapshot := { + val SnapshotQualifier = """(.+)(-.*SNAPSHOT)(.*)""".r + val v = version.value + v match { + case SnapshotQualifier(_, _, _) => true + case _ => false + } + }, + publishStatus := { + if (isSnapshot.value) "snapshots" + else "releases" + }, commands += stampVersion ) def stampVersion = Command.command("stamp-version") { state => @@ -29,17 +38,14 @@ object StatusPlugin extends AutoPlugin { state) } def stamp(v: String): String = - if (v endsWith Snapshot) - (v stripSuffix Snapshot) + "-" + timestampString(System.currentTimeMillis) - else - error("Release version '" + v + "' cannot be stamped") + { + val Snapshot = "-SNAPSHOT" + if (v endsWith Snapshot) (v stripSuffix Snapshot) + "-" + timestampString(System.currentTimeMillis) + else sys.error("Release version '" + v + "' cannot be stamped") + } def timestampString(time: Long): String = { val format = new java.text.SimpleDateFormat("yyyyMMdd-HHmmss") format.format(new java.util.Date(time)) } - final val Snapshot = "-SNAPSHOT" - // NOte: This moved into sbt itself... But we need to add semantic knowledge of how - // we stamp our nightlies. - def snapshotQualifier(v: String) = Pattern.matches(""".+-.*SNAPSHOT.*""", v) }