Skip to content

Commit

Permalink
Merge pull request #1983 from sbt/wip/nightly-bintray
Browse files Browse the repository at this point in the history
publish nightlies to bintray
  • Loading branch information
eed3si9n committed Apr 22, 2015
2 parents 2f7e9c6 + 2da38b9 commit d6a77b3
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 13 deletions.
2 changes: 1 addition & 1 deletion build.sbt
Expand Up @@ -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"
)

Expand Down
30 changes: 18 additions & 12 deletions 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 =>
Expand All @@ -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)
}

0 comments on commit d6a77b3

Please sign in to comment.