2011-09-23 10:21:03 +02:00
|
|
|
package akka
|
|
|
|
|
|
2011-07-08 18:01:19 +12:00
|
|
|
import sbt._
|
2011-12-09 21:55:49 +13:00
|
|
|
import sbt.Keys._
|
|
|
|
|
import sbt.Project.Initialize
|
2011-07-08 18:01:19 +12:00
|
|
|
import java.io.File
|
|
|
|
|
|
|
|
|
|
object Publish {
|
|
|
|
|
final val Snapshot = "-SNAPSHOT"
|
|
|
|
|
|
2011-12-09 21:55:49 +13:00
|
|
|
val defaultPublishTo = SettingKey[File]("default-publish-to")
|
|
|
|
|
|
2011-07-08 18:01:19 +12:00
|
|
|
lazy val settings = Seq(
|
2011-10-06 15:44:15 +02:00
|
|
|
crossPaths := false,
|
|
|
|
|
pomExtra := akkaPomExtra,
|
2012-05-13 21:14:23 +12:00
|
|
|
publishTo <<= akkaPublishTo,
|
2011-10-06 15:44:15 +02:00
|
|
|
credentials ++= akkaCredentials,
|
|
|
|
|
organizationName := "Typesafe Inc.",
|
2012-03-30 09:59:33 -04:00
|
|
|
organizationHomepage := Some(url("http://www.typesafe.com")),
|
|
|
|
|
publishMavenStyle := true,
|
|
|
|
|
// Maven central cannot allow other repos.
|
|
|
|
|
// TODO - Make sure all artifacts are on central.
|
|
|
|
|
pomIncludeRepository := { x => false }
|
2011-07-08 18:01:19 +12:00
|
|
|
)
|
|
|
|
|
|
|
|
|
|
lazy val versionSettings = Seq(
|
|
|
|
|
commands += stampVersion
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
|
def akkaPomExtra = {
|
2012-03-30 09:59:33 -04:00
|
|
|
(<inceptionYear>2009</inceptionYear>
|
|
|
|
|
<scm>
|
|
|
|
|
<url>git://github.com/akka/akka.git</url>
|
|
|
|
|
<connection>scm:git:git@github.com:akka/akka.git</connection>
|
|
|
|
|
</scm>) ++ makeDevelopersXml(Map(
|
|
|
|
|
"jboner" -> "Jonas Boner",
|
2012-05-11 16:19:46 +02:00
|
|
|
"viktorklang" -> "Viktor Klang",
|
2012-03-30 09:59:33 -04:00
|
|
|
"rkuhn" -> "Roland Kuhn",
|
|
|
|
|
"pvlugter" -> "Peter Vlugter"
|
|
|
|
|
// TODO - More than the names in the last 10 commits
|
|
|
|
|
))
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private[this] def makeDevelopersXml(users: Map[String,String]) =
|
|
|
|
|
<developers>
|
|
|
|
|
{
|
|
|
|
|
for((id, user) <- users)
|
|
|
|
|
yield <developer><id>{id}</id><name>{user}</name></developer>
|
|
|
|
|
}
|
|
|
|
|
</developers>
|
|
|
|
|
|
|
|
|
|
def sonatypePublishTo: Initialize[Option[Resolver]] = {
|
|
|
|
|
version { v: String =>
|
|
|
|
|
val nexus = "https://oss.sonatype.org/"
|
|
|
|
|
if (v.trim.endsWith("SNAPSHOT")) Some("snapshots" at nexus + "content/repositories/snapshots")
|
|
|
|
|
else Some("releases" at nexus + "service/local/staging/deploy/maven2")
|
|
|
|
|
}
|
2011-07-08 18:01:19 +12:00
|
|
|
}
|
|
|
|
|
|
2011-12-09 21:55:49 +13:00
|
|
|
def akkaPublishTo: Initialize[Option[Resolver]] = {
|
2013-10-18 14:13:23 +02:00
|
|
|
(defaultPublishTo, version) { (defaultPT, v) =>
|
2012-08-22 12:54:25 -04:00
|
|
|
akkaPublishRepository orElse
|
|
|
|
|
sonatypeRepo(v) orElse
|
2013-10-18 14:13:23 +02:00
|
|
|
Some(Resolver.file("Default Local Repository", defaultPT))
|
2012-08-22 12:54:25 -04:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
def sonatypeRepo(version: String): Option[Resolver] = {
|
|
|
|
|
Option(sys.props("publish.maven.central")) filter (_.toLowerCase == "true") map { _ =>
|
|
|
|
|
val nexus = "https://oss.sonatype.org/"
|
|
|
|
|
if(version endsWith "-SNAPSHOT") ("snapshots" at nexus + "content/repositories/snapshots")
|
|
|
|
|
else ("releases" at nexus + "service/local/staging/deploy/maven2")
|
2011-12-09 21:55:49 +13:00
|
|
|
}
|
2011-07-08 18:01:19 +12:00
|
|
|
}
|
|
|
|
|
|
2012-09-18 15:49:02 +02:00
|
|
|
def akkaPublishRepository: Option[Resolver] =
|
|
|
|
|
Option(System.getProperty("akka.publish.repository", null)) map { "Akka Publish Repository" at _ }
|
2012-08-22 12:54:25 -04:00
|
|
|
|
2012-09-18 15:49:02 +02:00
|
|
|
def akkaCredentials: Seq[Credentials] =
|
|
|
|
|
Option(System.getProperty("akka.publish.credentials", null)) map (f => Credentials(new File(f))) toSeq
|
2011-07-08 18:01:19 +12:00
|
|
|
|
2011-12-09 21:55:49 +13:00
|
|
|
// timestamped versions
|
2011-07-08 18:01:19 +12:00
|
|
|
|
2011-12-09 21:55:49 +13:00
|
|
|
def stampVersion = Command.command("stamp-version") { state =>
|
2011-07-08 18:01:19 +12:00
|
|
|
val extracted = Project.extract(state)
|
2011-12-09 21:55:49 +13:00
|
|
|
extracted.append(List(version in ThisBuild ~= stamp), state)
|
2011-07-08 18:01:19 +12:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
def stamp(version: String): String = {
|
|
|
|
|
if (version endsWith Snapshot) (version stripSuffix Snapshot) + "-" + timestamp(System.currentTimeMillis)
|
|
|
|
|
else version
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
def timestamp(time: Long): String = {
|
|
|
|
|
val format = new java.text.SimpleDateFormat("yyyyMMdd-HHmmss")
|
|
|
|
|
format.format(new java.util.Date(time))
|
|
|
|
|
}
|
|
|
|
|
}
|