Merge remote-tracking branch 'origin/wip/bintray-publishing' into full-bintray

Conflicts:
	project/build.properties
	project/packaging.scala
This commit is contained in:
Josh Suereth 2014-01-06 09:42:08 -05:00
commit 2f6c444fd5
2 changed files with 37 additions and 14 deletions

View File

@ -1,18 +1,8 @@
sbtPlugin := true
name := "sbt-launcher-package"
organization := "org.scala-sbt"
name := "sbt-launcher-packaging"
version := "0.1.0"
crossTarget <<= target
publishTo in Global := {
val nativeReleaseUrl = "http://scalasbt.artifactoryonline.com/scalasbt/sbt-native-packages"
val nativeReleasePattern = "[organization]/[module]/[revision]/[module].[ext]"
val resolver = Resolver.url("native-releases", new URL(nativeReleaseUrl))(Patterns(nativeReleasePattern))
// Resolver.file("native-releases-local", file("/home/jsuereth/repos/native-packages"))(Patterns(nativeReleasePattern))
Some(resolver)
}

View File

@ -10,7 +10,15 @@ object Packaging {
val sbtLaunchJar = TaskKey[File]("sbt-launch-jar", "Resolves SBT launch jar")
val moduleID = (organization, sbtVersion) apply { (o,v) => ModuleID(o,"sbt",v) }
def localWindowsPattern = "[organisation]/[module]/[revision]/[module].[ext]"
val bintrayLinuxPattern = "[module]/[revision]/[module]-[revision].[ext]"
val bintrayGenericPattern = "[module]/[revision]/[module]/[revision]/[module]-[revision].[ext]"
val bintrayDebianUrl = "https://api.bintray.com/content/sbt/debian/"
val bintrayRpmUrl = "https://api.bintray.com/content/sbt/rpm/"
val bintrayGenericPackagesUrl = "https://api.bintray.com/content/sbt/native-packages/"
// Note: The legacy api.
//val genericNativeReleasesUrl = "http://scalasbt.artifactoryonline.com/scalasbt/sbt-native-packages"
//val genericNativeReleasesPattern = "[organisation]/[module]/[revision]/[module].[ext]"
import util.control.Exception.catching
@ -20,8 +28,33 @@ object Packaging {
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"
}
/** Returns an id, url and pattern for publishing based on the given configuration. */
def getPublishSettings(config: Configuration): (String, String, String) =
config.name match {
case Debian.name => ("bintray-debian", bintrayDebianUrl, bintrayLinuxPattern)
case Rpm.name => ("bintray-rpm", bintrayRpmUrl, bintrayLinuxPattern)
case _ => ("generic-native-packages-" + config.name, bintrayGenericPackagesUrl, bintrayGenericPattern)
}
def makePublishTo(id: String, url: String, pattern: String): Setting[_] = {
publishTo := {
val resolver = Resolver.url(id, new URL(url))(Patterns(pattern))
Some(resolver)
}
}
def makePublishToForConfig(config: Configuration) = {
val (id, url, pattern) = getPublishSettings(config)
// Add the publish to and ensure global resolvers has the resolver we just configured.
inConfig(config)(Seq(makePublishTo(id, url, pattern))) ++
Seq(resolvers <++= (publishTo in config) apply (_.toSeq))
}
val settings: Seq[Setting[_]] = packagerSettings ++ deploymentSettings ++ mapGenericFilesToLinux ++ mapGenericFilesToWindows ++ Seq(
def publishToSettings: Seq[Setting[_]] =
Seq[Configuration](Debian, Universal, Windows, Rpm) flatMap makePublishToForConfig
val settings: Seq[Setting[_]] = packagerSettings ++ deploymentSettings ++ mapGenericFilesToLinux ++ mapGenericFilesToWindows ++ publishToSettings ++ Seq(
sbtLaunchJarUrl <<= sbtVersion apply downloadUrlForVersion,
sbtLaunchJarLocation <<= target apply (_ / "sbt-launch.jar"),
sbtLaunchJar <<= (sbtLaunchJarUrl, sbtLaunchJarLocation) map { (uri, file) =>