2011-11-29 00:52:47 +01:00
|
|
|
import sbt._
|
2013-06-27 22:43:31 +02:00
|
|
|
import com.typesafe.sbt.packager.Keys._
|
2011-12-21 17:21:16 +01:00
|
|
|
import sbt.Keys._
|
2013-06-27 22:43:31 +02:00
|
|
|
import com.typesafe.sbt.SbtNativePackager._
|
2011-11-29 00:52:47 +01:00
|
|
|
|
2011-12-21 19:52:26 +01:00
|
|
|
object Packaging {
|
2011-12-21 20:39:57 +01:00
|
|
|
|
|
|
|
|
val sbtLaunchJarUrl = SettingKey[String]("sbt-launch-jar-url")
|
|
|
|
|
val sbtLaunchJarLocation = SettingKey[File]("sbt-launch-jar-location")
|
|
|
|
|
val sbtLaunchJar = TaskKey[File]("sbt-launch-jar", "Resolves SBT launch jar")
|
2012-01-17 15:32:44 +01:00
|
|
|
|
2013-06-17 18:16:10 +02:00
|
|
|
val stagingDirectory = SettingKey[File]("staging-directory")
|
|
|
|
|
val stage = TaskKey[File]("stage")
|
2012-01-17 15:32:44 +01:00
|
|
|
|
|
|
|
|
def localWindowsPattern = "[organisation]/[module]/[revision]/[module].[ext]"
|
2012-07-18 16:40:29 +02:00
|
|
|
|
|
|
|
|
import util.control.Exception.catching
|
|
|
|
|
|
|
|
|
|
def downloadUrlForVersion(v: String) = (v split "[^\\d]" flatMap (i => catching(classOf[Exception]) opt (i.toInt))) match {
|
|
|
|
|
case Array(0, 11, 3, _*) => "http://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/sbt-launch/0.11.3-2/sbt-launch.jar"
|
2012-05-29 14:49:02 +02:00
|
|
|
case Array(0, 11, x, _*) if x >= 3 => "http://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/sbt-launch/"+v+"/sbt-launch.jar"
|
|
|
|
|
case Array(0, y, _*) if y >= 12 => "http://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/sbt-launch/"+v+"/sbt-launch.jar"
|
|
|
|
|
case _ => "http://repo.typesafe.com/typesafe/ivy-releases/org.scala-tools.sbt/sbt-launch/"+v+"/sbt-launch.jar"
|
|
|
|
|
}
|
|
|
|
|
|
2013-06-29 16:09:42 +02:00
|
|
|
val settings: Seq[Setting[_]] = packagerSettings ++ deploymentSettings ++ mapGenericFilesToLinux ++ mapGenericFilesToWinows ++ Seq(
|
2012-05-29 14:49:02 +02:00
|
|
|
sbtLaunchJarUrl <<= sbtVersion apply downloadUrlForVersion,
|
2011-12-21 20:39:57 +01:00
|
|
|
sbtLaunchJarLocation <<= target apply (_ / "sbt-launch.jar"),
|
|
|
|
|
sbtLaunchJar <<= (sbtLaunchJarUrl, sbtLaunchJarLocation) map { (uri, file) =>
|
|
|
|
|
import dispatch._
|
|
|
|
|
if(!file.exists) {
|
2012-03-15 19:51:35 +01:00
|
|
|
// oddly, some places require us to create the file before writing...
|
2012-03-15 19:57:04 +01:00
|
|
|
IO.touch(file)
|
2011-12-21 20:39:57 +01:00
|
|
|
val writer = new java.io.BufferedOutputStream(new java.io.FileOutputStream(file))
|
|
|
|
|
try Http(url(uri) >>> writer)
|
|
|
|
|
finally writer.close()
|
|
|
|
|
}
|
|
|
|
|
// TODO - GPG Trust validation.
|
|
|
|
|
file
|
|
|
|
|
},
|
2011-12-21 04:25:02 +01:00
|
|
|
// GENERAL LINUX PACKAGING STUFFS
|
|
|
|
|
maintainer := "Josh Suereth <joshua.suereth@typesafe.com>",
|
2012-01-11 20:10:10 +01:00
|
|
|
packageSummary := "Simple Build Tool for Scala-driven builds",
|
2012-01-11 19:41:36 +01:00
|
|
|
packageDescription := """This script provides a native way to run the Simple Build Tool,
|
|
|
|
|
a build tool for Scala software, also called SBT.""",
|
2013-06-27 22:43:31 +02:00
|
|
|
// Here we remove the jar file and launch lib from the symlinks:
|
|
|
|
|
linuxPackageSymlinks <<= linuxPackageSymlinks map { links =>
|
|
|
|
|
for {
|
|
|
|
|
link <- links
|
|
|
|
|
if !(link.destination endsWith "sbt-launch-lib.bash")
|
|
|
|
|
if !(link.destination endsWith "sbt-launch.jar")
|
|
|
|
|
} yield link
|
2011-12-21 20:39:57 +01:00
|
|
|
},
|
2011-12-21 04:25:02 +01:00
|
|
|
// DEBIAN SPECIFIC
|
2012-07-18 16:40:29 +02:00
|
|
|
name in Debian <<= (sbtVersion) apply { (sv) => "sbt" /* + "-" + (sv split "[^\\d]" take 3 mkString ".")*/ },
|
2012-05-29 14:49:02 +02:00
|
|
|
version in Debian <<= (version, sbtVersion) apply { (v, sv) =>
|
|
|
|
|
val nums = (v split "[^\\d]")
|
2012-07-18 16:40:29 +02:00
|
|
|
"%s-%s-build-%03d" format (sv, (nums.init mkString "."), nums.last.toInt + 1)
|
2011-11-29 00:52:47 +01:00
|
|
|
},
|
2011-12-20 03:15:10 +01:00
|
|
|
debianPackageDependencies in Debian ++= Seq("curl", "java2-runtime", "bash (>= 2.05a-11)"),
|
|
|
|
|
debianPackageRecommends in Debian += "git",
|
|
|
|
|
linuxPackageMappings in Debian <+= (sourceDirectory) map { bd =>
|
2011-12-21 17:21:16 +01:00
|
|
|
(packageMapping(
|
2011-12-21 04:25:02 +01:00
|
|
|
(bd / "debian/changelog") -> "/usr/share/doc/sbt/changelog.gz"
|
2011-12-21 17:21:16 +01:00
|
|
|
) withUser "root" withGroup "root" withPerms "0644" gzipped) asDocs()
|
2011-12-21 04:25:02 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
|
|
// RPM SPECIFIC
|
|
|
|
|
name in Rpm := "sbt",
|
2012-07-18 16:47:49 +02:00
|
|
|
version in Rpm <<= sbtVersion apply { sv => (sv split "[^\\d]" filterNot (_.isEmpty) mkString ".") },
|
2011-12-21 04:25:02 +01:00
|
|
|
rpmRelease := "1",
|
2011-12-21 15:34:47 +01:00
|
|
|
rpmVendor := "typesafe",
|
|
|
|
|
rpmUrl := Some("http://github.com/paulp/sbt-extras"),
|
2011-12-24 06:46:15 +01:00
|
|
|
rpmLicense := Some("BSD"),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// WINDOWS SPECIFIC
|
|
|
|
|
name in Windows := "sbt",
|
2013-06-29 16:09:42 +02:00
|
|
|
version in Windows <<= (sbtVersion) apply { sv =>
|
|
|
|
|
(sv split "[^\\d]" filterNot (_.isEmpty)) match {
|
|
|
|
|
case Array(major,minor,bugfix, _*) => Seq(major,minor,bugfix, "1") mkString "."
|
|
|
|
|
case Array(major,minor) => Seq(major,minor,"0","1") mkString "."
|
|
|
|
|
case Array(major) => Seq(major,"0","0","1") mkString "."
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
maintainer in Windows := "Typesafe, Inc.",
|
|
|
|
|
packageSummary in Windows := "Simple Build Tool",
|
|
|
|
|
packageDescription in Windows := "THE reactive build tool.",
|
|
|
|
|
wixProductId := "ce07be71-510d-414a-92d4-dff47631848a",
|
|
|
|
|
wixProductUpgradeId := "4552fb0e-e257-4dbd-9ecb-dba9dbacf424",
|
2012-01-17 18:03:26 +01:00
|
|
|
javacOptions := Seq("-source", "1.5", "-target", "1.5"),
|
2012-03-15 19:22:10 +01:00
|
|
|
|
2013-06-29 16:09:42 +02:00
|
|
|
// Universal ZIP download install.
|
2012-03-15 19:31:10 +01:00
|
|
|
name in Universal := "sbt",
|
2012-07-17 22:37:19 +02:00
|
|
|
mappings in Universal <+= sbtLaunchJar map { _ -> "bin/sbt-launch.jar" },
|
2013-06-28 01:56:21 +02:00
|
|
|
|
2012-07-18 16:40:29 +02:00
|
|
|
// Misccelaneous publishing stuff...
|
|
|
|
|
projectID in Debian <<= (organization, sbtVersion) apply { (o,v) => ModuleID(o,"sbt",v) },
|
|
|
|
|
projectID in Windows <<= (organization, sbtVersion) apply { (o,v) => ModuleID(o,"sbt",v) },
|
|
|
|
|
projectID in Rpm <<= (organization, sbtVersion) apply { (o,v) => ModuleID(o,"sbt",v) },
|
2013-06-17 18:16:10 +02:00
|
|
|
projectID in Universal <<= (organization, sbtVersion) apply { (o,v) => ModuleID(o,"sbt",v) },
|
|
|
|
|
stagingDirectory <<= (target) apply { (t) => t / "stage" },
|
|
|
|
|
stage <<= (stagingDirectory, mappings in Universal) map { (dir, m) =>
|
|
|
|
|
val files = for((file, name) <- m)
|
|
|
|
|
yield file -> (dir / name)
|
|
|
|
|
IO copy files
|
|
|
|
|
dir
|
|
|
|
|
}
|
2012-03-15 19:22:10 +01:00
|
|
|
)
|
2011-11-29 00:52:47 +01:00
|
|
|
}
|