Add publish settings to sbt build

This commit is contained in:
Peter Vlugter 2011-07-08 18:01:19 +12:00
parent 82b459b224
commit 29106c0df0
2 changed files with 87 additions and 15 deletions

View file

@ -3,14 +3,16 @@ import Keys._
import MultiJvmPlugin.{ MultiJvm, extraOptions, multiJvmMarker } import MultiJvmPlugin.{ MultiJvm, extraOptions, multiJvmMarker }
object AkkaBuild extends Build { object AkkaBuild extends Build {
val Organization = "se.scalablesolutions.akka" lazy val buildSettings = Seq(
val Version = "2.0-SNAPSHOT" organization := "se.scalablesolutions.akka",
val ScalaVersion = "2.9.0-1" version := "2.0-SNAPSHOT",
scalaVersion := "2.9.0-1"
)
lazy val akka = Project( lazy val akka = Project(
id = "akka", id = "akka",
base = file("."), base = file("."),
settings = buildSettings ++ Unidoc.settings ++ rstdocSettings ++ Seq( settings = parentSettings ++ Unidoc.settings ++ rstdocSettings ++ Seq(
Unidoc.unidocExclude := Seq(samples.id, tutorials.id), Unidoc.unidocExclude := Seq(samples.id, tutorials.id),
rstdocDirectory <<= baseDirectory / "akka-docs" rstdocDirectory <<= baseDirectory / "akka-docs"
), ),
@ -22,7 +24,7 @@ object AkkaBuild extends Build {
base = file("akka-actor"), base = file("akka-actor"),
settings = defaultSettings ++ Seq( settings = defaultSettings ++ Seq(
autoCompilerPlugins := true, autoCompilerPlugins := true,
addCompilerPlugin("org.scala-lang.plugins" % "continuations" % ScalaVersion), libraryDependencies <+= scalaVersion { v => compilerPlugin("org.scala-lang.plugins" % "continuations" % v) },
scalacOptions += "-P:continuations:enable" scalacOptions += "-P:continuations:enable"
) )
) )
@ -42,7 +44,7 @@ object AkkaBuild extends Build {
dependencies = Seq(testkit), dependencies = Seq(testkit),
settings = defaultSettings ++ Seq( settings = defaultSettings ++ Seq(
autoCompilerPlugins := true, autoCompilerPlugins := true,
addCompilerPlugin("org.scala-lang.plugins" % "continuations" % ScalaVersion), libraryDependencies <+= scalaVersion { v => compilerPlugin("org.scala-lang.plugins" % "continuations" % v) },
scalacOptions += "-P:continuations:enable", scalacOptions += "-P:continuations:enable",
libraryDependencies ++= Dependencies.actorTests libraryDependencies ++= Dependencies.actorTests
) )
@ -93,7 +95,7 @@ object AkkaBuild extends Build {
lazy val mailboxes = Project( lazy val mailboxes = Project(
id = "akka-durable-mailboxes", id = "akka-durable-mailboxes",
base = file("akka-durable-mailboxes"), base = file("akka-durable-mailboxes"),
settings = buildSettings, settings = parentSettings,
aggregate = Seq(mailboxesCommon, beanstalkMailbox, fileMailbox, redisMailbox, zookeeperMailbox) aggregate = Seq(mailboxesCommon, beanstalkMailbox, fileMailbox, redisMailbox, zookeeperMailbox)
) )
@ -184,7 +186,7 @@ object AkkaBuild extends Build {
lazy val samples = Project( lazy val samples = Project(
id = "akka-samples", id = "akka-samples",
base = file("akka-samples"), base = file("akka-samples"),
settings = buildSettings, settings = parentSettings,
aggregate = Seq(fsmSample) aggregate = Seq(fsmSample)
) )
@ -226,7 +228,7 @@ object AkkaBuild extends Build {
lazy val tutorials = Project( lazy val tutorials = Project(
id = "akka-tutorials", id = "akka-tutorials",
base = file("akka-tutorials"), base = file("akka-tutorials"),
settings = buildSettings, settings = parentSettings,
aggregate = Seq(firstTutorial, secondTutorial) aggregate = Seq(firstTutorial, secondTutorial)
) )
@ -246,14 +248,15 @@ object AkkaBuild extends Build {
// Settings // Settings
lazy val buildSettings = Defaults.defaultSettings ++ Seq( override lazy val settings = super.settings ++ buildSettings ++ Publish.versionSettings
organization := Organization,
version := Version, lazy val baseSettings = Defaults.defaultSettings ++ Publish.settings
scalaVersion := ScalaVersion,
crossPaths := false lazy val parentSettings = baseSettings ++ Seq(
publishArtifact in Compile := false
) )
lazy val defaultSettings = buildSettings ++ Seq( lazy val defaultSettings = baseSettings ++ Seq(
resolvers += "Typesafe Repo" at "http://repo.typesafe.com/typesafe/releases/", resolvers += "Typesafe Repo" at "http://repo.typesafe.com/typesafe/releases/",
// compile options // compile options

69
project/Publish.scala Normal file
View file

@ -0,0 +1,69 @@
import sbt._
import Keys._
import java.io.File
object Publish {
final val Snapshot = "-SNAPSHOT"
lazy val settings = Seq(
crossPaths := false,
pomExtra := akkaPomExtra,
publishTo := akkaPublishTo,
credentials ++= akkaCredentials
)
lazy val versionSettings = Seq(
commands += stampVersion
)
def akkaPomExtra = {
<inceptionYear>2009</inceptionYear>
<url>http://akka.io</url>
<organization>
<name>Scalable Solutions AB</name>
<url>http://scalablesolutions.se</url>
</organization>
<licenses>
<license>
<name>Apache 2</name>
<url>http://www.apache.org/licenses/LICENSE-2.0.txt</url>
<distribution>repo</distribution>
</license>
</licenses>
}
def akkaPublishTo: Option[Resolver] = {
val property = Option(System.getProperty("akka.publish.repository"))
val repo = property map { "Akka Publish Repository" at _ }
val m2repo = Path.userHome / ".m2" /"repository"
repo orElse Some(Resolver.file("Local Maven Repository", m2repo))
}
def akkaCredentials: Seq[Credentials] = {
val property = Option(System.getProperty("akka.publish.credentials"))
property map (f => Credentials(new File(f))) toSeq
}
def stampVersion = Command.command("stamp-version") { state =>
append((version in ThisBuild ~= stamp) :: Nil, state)
}
// TODO: replace with extracted.append when updated to sbt 0.10.1
def append(settings: Seq[Setting[_]], state: State): State = {
val extracted = Project.extract(state)
import extracted._
val append = Load.transformSettings(Load.projectScope(currentRef), currentRef.build, rootProject, settings)
val newStructure = Load.reapply(session.original ++ append, structure)
Project.setProject(session, newStructure, state)
}
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))
}
}