2016-08-22 12:33:23 +02:00
|
|
|
import scala.util.control.Exception.catching
|
2015-08-11 07:30:16 +02:00
|
|
|
import _root_.bintray.InternalBintrayKeys._
|
|
|
|
|
import _root_.bintray.{BintrayRepo, Bintray}
|
2017-03-07 04:34:59 +01:00
|
|
|
import NativePackagerHelper._
|
2017-04-13 05:41:18 +02:00
|
|
|
import com.typesafe.sbt.packager.SettingsHelper._
|
2017-05-10 20:07:04 +02:00
|
|
|
import DebianConstants._
|
2011-09-14 19:01:48 +02:00
|
|
|
|
2017-04-07 06:56:55 +02:00
|
|
|
lazy val sbtOfflineInstall =
|
2017-04-07 10:13:13 +02:00
|
|
|
sys.props.getOrElse("sbt.build.offline", sys.env.getOrElse("sbt.build.offline", "true")) match {
|
2017-05-11 06:11:11 +02:00
|
|
|
case "true" | "1" => true
|
|
|
|
|
case "false" | "0" => false
|
|
|
|
|
case _ => false
|
2017-04-07 06:56:55 +02:00
|
|
|
}
|
2016-05-09 06:25:16 +02:00
|
|
|
lazy val sbtVersionToRelease = sys.props.getOrElse("sbt.build.version", sys.env.getOrElse("sbt.build.version", {
|
|
|
|
|
sys.error("-Dsbt.build.version must be set")
|
|
|
|
|
}))
|
2019-05-10 05:17:22 +02:00
|
|
|
|
|
|
|
|
lazy val scala210 = "2.10.7"
|
2019-10-14 08:59:34 +02:00
|
|
|
lazy val scala212 = "2.12.10"
|
2019-05-10 05:17:22 +02:00
|
|
|
lazy val scala210Jline = "org.scala-lang" % "jline" % scala210
|
|
|
|
|
lazy val jansi = {
|
2019-10-14 08:59:34 +02:00
|
|
|
if (sbtVersionToRelease startsWith "1.") "org.fusesource.jansi" % "jansi" % "1.12"
|
2019-05-10 05:17:22 +02:00
|
|
|
else "org.fusesource.jansi" % "jansi" % "1.4"
|
|
|
|
|
}
|
|
|
|
|
lazy val scala212Jline = "jline" % "jline" % "2.14.6"
|
2019-10-14 08:59:34 +02:00
|
|
|
lazy val scala212Xml = "org.scala-lang.modules" % "scala-xml_2.12" % "1.2.0"
|
2019-05-10 05:17:22 +02:00
|
|
|
lazy val scala212Compiler = "org.scala-lang" % "scala-compiler" % scala212
|
|
|
|
|
lazy val sbtActual = "org.scala-sbt" % "sbt" % sbtVersionToRelease
|
|
|
|
|
|
|
|
|
|
lazy val sbt013ExtraDeps = {
|
|
|
|
|
if (sbtVersionToRelease startsWith "0.13.") Seq(scala210Jline)
|
|
|
|
|
else Seq()
|
|
|
|
|
}
|
|
|
|
|
|
2019-05-15 16:52:39 +02:00
|
|
|
lazy val isWindows: Boolean = sys.props("os.name").toLowerCase(java.util.Locale.ENGLISH).contains("windows")
|
2016-05-09 06:25:16 +02:00
|
|
|
lazy val isExperimental = (sbtVersionToRelease contains "RC") || (sbtVersionToRelease contains "M")
|
2015-08-11 06:39:34 +02:00
|
|
|
val sbtLaunchJarUrl = SettingKey[String]("sbt-launch-jar-url")
|
2016-10-31 21:30:39 +01:00
|
|
|
val sbtLaunchJarLocation = SettingKey[File]("sbt-launch-jar-location")
|
2015-08-11 06:39:34 +02:00
|
|
|
val sbtLaunchJar = TaskKey[File]("sbt-launch-jar", "Resolves SBT launch jar")
|
2016-05-09 06:25:16 +02:00
|
|
|
val moduleID = (organization) apply { (o) => ModuleID(o, "sbt", sbtVersionToRelease) }
|
2013-09-04 17:50:58 +02:00
|
|
|
|
2017-04-07 07:40:05 +02:00
|
|
|
lazy val bintrayDebianUrl = settingKey[String]("API point for Debian packages")
|
|
|
|
|
lazy val bintrayDebianExperimentalUrl = settingKey[String]("API point for Debian experimental packages")
|
|
|
|
|
lazy val bintrayRpmUrl = settingKey[String]("API point for RPM packages")
|
|
|
|
|
lazy val bintrayRpmExperimentalUrl = settingKey[String]("API point for RPM experimental packages")
|
|
|
|
|
lazy val bintrayGenericPackagesUrl = settingKey[String]("API point for generic packages")
|
|
|
|
|
lazy val bintrayTripple = settingKey[(String, String, String)]("id, url, and pattern")
|
|
|
|
|
|
2015-08-11 06:39:34 +02:00
|
|
|
val bintrayLinuxPattern = "[module]/[revision]/[module]-[revision].[ext]"
|
|
|
|
|
val bintrayGenericPattern = "[module]/[revision]/[module]/[revision]/[module]-[revision].[ext]"
|
2015-08-11 07:30:16 +02:00
|
|
|
val bintrayReleaseAllStaged = TaskKey[Unit]("bintray-release-all-staged", "Release all staged artifacts on bintray.")
|
2015-12-18 06:01:35 +01:00
|
|
|
val windowsBuildId = settingKey[Int]("build id for Windows installer")
|
2017-04-27 02:08:26 +02:00
|
|
|
val debianBuildId = settingKey[Int]("build id for Debian")
|
2011-09-14 19:01:48 +02:00
|
|
|
|
2019-05-15 16:52:39 +02:00
|
|
|
val exportRepoUsingCoursier = taskKey[File]("export Maven style repository")
|
|
|
|
|
val exportRepoCsrDirectory = settingKey[File]("")
|
|
|
|
|
|
2015-08-11 06:39:34 +02:00
|
|
|
// This build creates a SBT plugin with handy features *and* bundles the SBT script for distribution.
|
|
|
|
|
val root = (project in file(".")).
|
2017-01-21 12:36:33 +01:00
|
|
|
enablePlugins(UniversalPlugin, LinuxPlugin, DebianPlugin, RpmPlugin, WindowsPlugin,
|
|
|
|
|
UniversalDeployPlugin, DebianDeployPlugin, RpmDeployPlugin, WindowsDeployPlugin).
|
2015-08-11 06:39:34 +02:00
|
|
|
settings(
|
|
|
|
|
organization := "org.scala-sbt",
|
|
|
|
|
name := "sbt-launcher-packaging",
|
2016-10-31 21:30:39 +01:00
|
|
|
packageName := "sbt",
|
2015-08-11 06:39:34 +02:00
|
|
|
version := "0.1.0",
|
2017-01-21 12:36:33 +01:00
|
|
|
crossTarget := target.value,
|
2017-03-11 22:34:18 +01:00
|
|
|
clean := {
|
|
|
|
|
val _ = (clean in dist).value
|
|
|
|
|
clean.value
|
|
|
|
|
},
|
2017-05-11 06:11:11 +02:00
|
|
|
useGpg := true,
|
|
|
|
|
usePgpKeyHex("642AC823"),
|
2017-05-10 19:33:07 +02:00
|
|
|
pgpSecretRing := file(s"""${sys.props("user.home")}""") / ".ssh" / "scalasbt.key",
|
|
|
|
|
pgpPublicRing := file(s"""${sys.props("user.home")}""") / ".ssh" / "scalasbt.pub",
|
2015-08-11 06:39:34 +02:00
|
|
|
publishToSettings,
|
2016-05-09 06:25:16 +02:00
|
|
|
sbtLaunchJarUrl := downloadUrlForVersion(sbtVersionToRelease),
|
2017-01-21 12:36:33 +01:00
|
|
|
sbtLaunchJarLocation := { target.value / "sbt-launch.jar" },
|
|
|
|
|
sbtLaunchJar := {
|
|
|
|
|
val uri = sbtLaunchJarUrl.value
|
|
|
|
|
val file = sbtLaunchJarLocation.value
|
2015-08-11 06:39:34 +02:00
|
|
|
import dispatch.classic._
|
|
|
|
|
if(!file.exists) {
|
|
|
|
|
// oddly, some places require us to create the file before writing...
|
|
|
|
|
IO.touch(file)
|
|
|
|
|
val writer = new java.io.BufferedOutputStream(new java.io.FileOutputStream(file))
|
|
|
|
|
try Http(url(uri) >>> writer)
|
|
|
|
|
finally writer.close()
|
|
|
|
|
}
|
|
|
|
|
// TODO - GPG Trust validation.
|
|
|
|
|
file
|
|
|
|
|
},
|
2019-02-22 23:48:37 +01:00
|
|
|
|
2015-08-11 06:39:34 +02:00
|
|
|
// GENERAL LINUX PACKAGING STUFFS
|
2016-08-22 12:25:30 +02:00
|
|
|
maintainer := "Eugene Yokota <eugene.yokota@lightbend.com>",
|
2015-08-11 07:34:13 +02:00
|
|
|
packageSummary := "sbt, the interactive build tool",
|
|
|
|
|
packageDescription := """This script provides a native way to run sbt,
|
|
|
|
|
a build tool for Scala and more.""",
|
2015-08-11 06:39:34 +02:00
|
|
|
// Here we remove the jar file and launch lib from the symlinks:
|
2017-01-21 12:36:33 +01:00
|
|
|
linuxPackageSymlinks := {
|
|
|
|
|
val links = linuxPackageSymlinks.value
|
2016-05-09 06:25:16 +02:00
|
|
|
for {
|
2015-08-11 06:39:34 +02:00
|
|
|
link <- links
|
|
|
|
|
if !(link.destination endsWith "sbt-launch.jar")
|
|
|
|
|
} yield link
|
|
|
|
|
},
|
2019-02-22 21:25:28 +01:00
|
|
|
|
2015-08-11 07:34:13 +02:00
|
|
|
// DEBIAN SPECIFIC
|
2017-08-29 23:34:24 +02:00
|
|
|
debianBuildId := 0,
|
2017-04-27 02:08:26 +02:00
|
|
|
version in Debian := {
|
|
|
|
|
if (debianBuildId.value == 0) sbtVersionToRelease
|
|
|
|
|
else sbtVersionToRelease + "." + debianBuildId.value
|
|
|
|
|
},
|
2017-04-27 01:25:16 +02:00
|
|
|
// Used to have "openjdk-8-jdk" but that doesn't work on Ubuntu 14.04 https://github.com/sbt/sbt/issues/3105
|
|
|
|
|
// before that we had java6-runtime-headless" and that was pulling in JDK9 on Ubuntu 16.04 https://github.com/sbt/sbt/issues/2931
|
2017-11-16 16:11:19 +01:00
|
|
|
debianPackageDependencies in Debian ++= Seq("bash (>= 3.2)"),
|
2015-08-11 06:39:34 +02:00
|
|
|
debianPackageRecommends in Debian += "git",
|
2017-01-21 12:36:33 +01:00
|
|
|
linuxPackageMappings in Debian += {
|
|
|
|
|
val bd = sourceDirectory.value
|
2015-08-11 06:39:34 +02:00
|
|
|
(packageMapping(
|
2017-01-21 12:36:33 +01:00
|
|
|
(bd / "debian" / "changelog") -> "/usr/share/doc/sbt/changelog.gz"
|
2015-08-11 06:39:34 +02:00
|
|
|
) withUser "root" withGroup "root" withPerms "0644" gzipped) asDocs()
|
|
|
|
|
},
|
2017-01-21 12:36:33 +01:00
|
|
|
debianChangelog in Debian := { Some(sourceDirectory.value / "debian" / "changelog") },
|
2017-04-13 05:41:18 +02:00
|
|
|
addPackage(Debian, packageBin in Debian, "deb"),
|
2019-01-08 01:09:05 +01:00
|
|
|
debianNativeBuildOptions in Debian := Seq("-Zgzip", "-z3"),
|
|
|
|
|
|
2015-08-11 06:39:34 +02:00
|
|
|
// RPM SPECIFIC
|
2017-08-29 23:34:24 +02:00
|
|
|
rpmRelease := "0",
|
2016-05-09 06:25:16 +02:00
|
|
|
version in Rpm := {
|
2017-04-27 02:08:26 +02:00
|
|
|
val stable0 = (sbtVersionToRelease split "[^\\d]" filterNot (_.isEmpty) mkString ".")
|
|
|
|
|
val stable = if (rpmRelease.value == "0") stable0
|
|
|
|
|
else stable0 + "." + rpmRelease.value
|
2016-05-09 06:25:16 +02:00
|
|
|
if (isExperimental) ((sbtVersionToRelease split "[^\\d]" filterNot (_.isEmpty)).toList match {
|
|
|
|
|
case List(a, b, c, d) => List(0, 99, c, d).mkString(".")
|
|
|
|
|
})
|
|
|
|
|
else stable
|
|
|
|
|
},
|
2017-01-21 13:19:57 +01:00
|
|
|
rpmVendor := "lightbend",
|
2015-08-11 07:34:13 +02:00
|
|
|
rpmUrl := Some("http://github.com/sbt/sbt-launcher-package"),
|
2015-08-11 06:39:34 +02:00
|
|
|
rpmLicense := Some("BSD"),
|
2017-04-12 11:20:00 +02:00
|
|
|
// This is intentionally empty. java-devel could bring in JDK 9-ea on Fedora,
|
|
|
|
|
// and java-1.8.0-devel doesn't work on CentOS 6 and 7.
|
|
|
|
|
// https://github.com/sbt/sbt-launcher-package/issues/151
|
|
|
|
|
// https://github.com/elastic/logstash/issues/6275#issuecomment-261359933
|
|
|
|
|
rpmRequirements := Seq(),
|
2015-08-11 06:39:34 +02:00
|
|
|
rpmProvides := Seq("sbt"),
|
2016-05-09 06:25:16 +02:00
|
|
|
|
2015-08-11 06:39:34 +02:00
|
|
|
// WINDOWS SPECIFIC
|
2017-04-08 07:13:12 +02:00
|
|
|
windowsBuildId := 0,
|
2017-01-21 12:36:33 +01:00
|
|
|
version in Windows := {
|
|
|
|
|
val bid = windowsBuildId.value
|
2016-05-09 06:25:16 +02:00
|
|
|
val sv = sbtVersionToRelease
|
2015-08-11 06:39:34 +02:00
|
|
|
(sv split "[^\\d]" filterNot (_.isEmpty)) match {
|
2017-04-08 07:13:12 +02:00
|
|
|
case Array(major,minor,bugfix, _*) if bid == 0 => Seq(major, minor, bugfix) mkString "."
|
2015-12-18 06:01:35 +01:00
|
|
|
case Array(major,minor,bugfix, _*) => Seq(major, minor, bugfix, bid.toString) mkString "."
|
|
|
|
|
case Array(major,minor) => Seq(major, minor, "0", bid.toString) mkString "."
|
|
|
|
|
case Array(major) => Seq(major, "0", "0", bid.toString) mkString "."
|
2015-08-11 06:39:34 +02:00
|
|
|
}
|
|
|
|
|
},
|
2016-05-09 06:25:16 +02:00
|
|
|
maintainer in Windows := "Lightbend, Inc.",
|
2015-12-18 06:01:35 +01:00
|
|
|
packageSummary in Windows := "sbt " + (version in Windows).value,
|
2015-08-11 07:34:13 +02:00
|
|
|
packageDescription in Windows := "The interactive build tool.",
|
2015-08-11 06:39:34 +02:00
|
|
|
wixProductId := "ce07be71-510d-414a-92d4-dff47631848a",
|
2015-12-18 06:01:35 +01:00
|
|
|
wixProductUpgradeId := Hash.toHex(Hash((version in Windows).value)).take(32),
|
2019-10-19 21:13:08 +02:00
|
|
|
javacOptions := Seq("-source", "1.8", "-target", "1.8"),
|
2015-08-11 06:39:34 +02:00
|
|
|
|
|
|
|
|
// Universal ZIP download install.
|
2016-10-31 21:30:39 +01:00
|
|
|
packageName in Universal := packageName.value, // needs to be set explicitly due to a bug in native-packager
|
2016-05-09 06:25:16 +02:00
|
|
|
version in Universal := sbtVersionToRelease,
|
2017-08-10 10:42:57 +02:00
|
|
|
|
|
|
|
|
mappings in Universal := {
|
|
|
|
|
val t = (target in Universal).value
|
|
|
|
|
val prev = (mappings in Universal).value
|
2019-09-24 00:08:29 +02:00
|
|
|
val BinSbt = "bin" + java.io.File.separator + "sbt"
|
|
|
|
|
val BinBat = BinSbt + ".bat"
|
2017-08-10 10:42:57 +02:00
|
|
|
prev.toList map {
|
2019-09-24 00:08:29 +02:00
|
|
|
case (k, BinSbt) =>
|
2019-09-24 18:31:18 +02:00
|
|
|
import java.nio.file.{Files, FileSystems}
|
|
|
|
|
|
2019-09-24 00:08:29 +02:00
|
|
|
val x = IO.read(k)
|
|
|
|
|
IO.write(t / "sbt", x.replaceAllLiterally(
|
|
|
|
|
"declare init_sbt_version=_to_be_replaced",
|
2019-09-23 07:25:35 +02:00
|
|
|
s"declare init_sbt_version=$sbtVersionToRelease"))
|
2019-09-24 18:31:18 +02:00
|
|
|
|
|
|
|
|
if (FileSystems.getDefault.supportedFileAttributeViews.contains("posix")) {
|
|
|
|
|
val perms = Files.getPosixFilePermissions(k.toPath)
|
|
|
|
|
Files.setPosixFilePermissions(t / "sbt" toPath, perms)
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-24 00:08:29 +02:00
|
|
|
(t / "sbt", BinSbt)
|
2017-08-10 11:26:03 +02:00
|
|
|
case (k, BinBat) =>
|
2017-08-10 10:42:57 +02:00
|
|
|
val x = IO.read(k)
|
|
|
|
|
IO.write(t / "sbt.bat", x.replaceAllLiterally(
|
2019-09-23 07:25:35 +02:00
|
|
|
"set init_sbt_version=_to_be_replaced",
|
|
|
|
|
s"set init_sbt_version=$sbtVersionToRelease"))
|
2017-08-10 11:26:03 +02:00
|
|
|
(t / "sbt.bat", BinBat)
|
2017-08-10 10:42:57 +02:00
|
|
|
case (k, v) => (k, v)
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
|
2017-02-15 10:57:47 +01:00
|
|
|
mappings in Universal ++= {
|
|
|
|
|
val launchJar = sbtLaunchJar.value
|
|
|
|
|
val rtExportJar = (packageBin in Compile in java9rtexport).value
|
|
|
|
|
Seq(launchJar -> "bin/sbt-launch.jar", rtExportJar -> "bin/java9-rt-export.jar")
|
|
|
|
|
},
|
2017-04-07 06:56:55 +02:00
|
|
|
mappings in Universal ++= (Def.taskDyn {
|
2019-05-15 16:52:39 +02:00
|
|
|
if (sbtOfflineInstall && sbtVersionToRelease.startsWith("1."))
|
|
|
|
|
Def.task {
|
|
|
|
|
val _ = (exportRepoUsingCoursier in dist).value
|
|
|
|
|
directory((target in dist).value / "lib")
|
|
|
|
|
}
|
|
|
|
|
else if (sbtOfflineInstall)
|
2017-04-07 06:56:55 +02:00
|
|
|
Def.task {
|
|
|
|
|
val _ = (exportRepo in dist).value
|
|
|
|
|
directory((target in dist).value / "lib")
|
|
|
|
|
}
|
|
|
|
|
else Def.task { Seq[(File, String)]() }
|
|
|
|
|
}).value,
|
2019-04-05 15:11:01 +02:00
|
|
|
mappings in Universal ++= {
|
|
|
|
|
val base = baseDirectory.value
|
|
|
|
|
if (sbtVersionToRelease startsWith "0.13.") Nil
|
|
|
|
|
else Seq[(File, String)](base / "LICENSE" -> "LICENSE", base / "NOTICE" -> "NOTICE")
|
|
|
|
|
},
|
2016-02-23 00:14:42 +01:00
|
|
|
|
2015-08-11 06:39:34 +02:00
|
|
|
// Misccelaneous publishing stuff...
|
2017-04-27 02:08:26 +02:00
|
|
|
projectID in Debian := {
|
|
|
|
|
val m = moduleID.value
|
|
|
|
|
m.copy(revision = (version in Debian).value)
|
|
|
|
|
},
|
2016-02-23 00:14:42 +01:00
|
|
|
projectID in Windows := {
|
|
|
|
|
val m = moduleID.value
|
|
|
|
|
m.copy(revision = (version in Windows).value)
|
|
|
|
|
},
|
2017-04-27 02:08:26 +02:00
|
|
|
projectID in Rpm := {
|
|
|
|
|
val m = moduleID.value
|
|
|
|
|
m.copy(revision = (version in Rpm).value)
|
|
|
|
|
},
|
|
|
|
|
projectID in Universal := {
|
|
|
|
|
val m = moduleID.value
|
|
|
|
|
m.copy(revision = (version in Universal).value)
|
|
|
|
|
}
|
2015-08-11 06:39:34 +02:00
|
|
|
)
|
|
|
|
|
|
2019-02-22 23:48:37 +01:00
|
|
|
lazy val integrationTest = (project in file("integration-test"))
|
|
|
|
|
.settings(
|
|
|
|
|
name := "integration-test",
|
2019-10-14 08:59:34 +02:00
|
|
|
scalaVersion := scala212,
|
2019-02-22 23:48:37 +01:00
|
|
|
libraryDependencies ++= Seq(
|
|
|
|
|
"io.monix" %% "minitest" % "2.3.2" % Test,
|
|
|
|
|
"com.eed3si9n.expecty" %% "expecty" % "0.11.0" % Test,
|
2019-09-23 07:25:35 +02:00
|
|
|
"org.scala-sbt" %% "io" % "1.3.1" % Test
|
2019-02-22 23:48:37 +01:00
|
|
|
),
|
|
|
|
|
testFrameworks += new TestFramework("minitest.runner.Framework")
|
|
|
|
|
)
|
|
|
|
|
|
2017-02-15 10:57:47 +01:00
|
|
|
lazy val java9rtexport = (project in file("java9-rt-export"))
|
|
|
|
|
.settings(
|
|
|
|
|
name := "java9-rt-export",
|
|
|
|
|
autoScalaLibrary := false,
|
|
|
|
|
crossPaths := false,
|
|
|
|
|
description := "Exports the contents of the Java 9. JEP-220 runtime image to a JAR for compatibility with older tools.",
|
|
|
|
|
homepage := Some(url("http://github.com/retronym/" + name.value)),
|
|
|
|
|
startYear := Some(2017),
|
|
|
|
|
licenses += ("Scala license", url(homepage.value.get.toString + "/blob/master/LICENSE")),
|
|
|
|
|
mainClass in Compile := Some("io.github.retronym.java9rtexport.Export")
|
|
|
|
|
)
|
|
|
|
|
|
2015-08-11 06:39:34 +02:00
|
|
|
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"
|
|
|
|
|
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"
|
2017-04-18 19:28:12 +02:00
|
|
|
case Array(1, _, _*) if v contains ("-20") => "http://repo.scala-sbt.org/scalasbt/maven-snapshots/org/scala-sbt/sbt-launch/"+v+"/sbt-launch.jar"
|
2016-05-09 06:25:16 +02:00
|
|
|
case Array(1, _, _*) => "http://repo.scala-sbt.org/scalasbt/maven-releases/org/scala-sbt/sbt-launch/"+v+"/sbt-launch.jar"
|
2015-08-11 06:39:34 +02:00
|
|
|
case _ => "http://repo.typesafe.com/typesafe/ivy-releases/org.scala-tools.sbt/sbt-launch/"+v+"/sbt-launch.jar"
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
def makePublishToForConfig(config: Configuration) = {
|
2016-05-09 06:25:16 +02:00
|
|
|
val v = sbtVersionToRelease
|
2017-04-07 07:40:05 +02:00
|
|
|
|
2015-08-11 06:39:34 +02:00
|
|
|
// Add the publish to and ensure global resolvers has the resolver we just configured.
|
|
|
|
|
inConfig(config)(Seq(
|
2017-04-09 16:37:42 +02:00
|
|
|
name := "sbt",
|
2017-04-07 07:40:05 +02:00
|
|
|
bintrayOrganization := {
|
|
|
|
|
// offline installation exceeds 50MB file limit for OSS organization
|
2017-04-07 10:13:13 +02:00
|
|
|
if (sbtOfflineInstall) Some("sbt")
|
2017-04-07 07:40:05 +02:00
|
|
|
else Some("sbt")
|
|
|
|
|
},
|
|
|
|
|
bintrayRepository := bintrayTripple.value._1,
|
2015-08-11 07:30:16 +02:00
|
|
|
bintrayRepo := Bintray.cachedRepo(bintrayEnsureCredentials.value,
|
|
|
|
|
bintrayOrganization.value,
|
|
|
|
|
bintrayRepository.value),
|
|
|
|
|
bintrayPackage := "sbt",
|
2017-04-07 07:40:05 +02:00
|
|
|
|
|
|
|
|
bintrayDebianUrl := s"https://api.bintray.com/content/${bintrayOrganization.value.get}/debian/",
|
|
|
|
|
bintrayDebianExperimentalUrl := s"https://api.bintray.com/content/${bintrayOrganization.value.get}/debian-experimental/",
|
|
|
|
|
bintrayRpmUrl := s"https://api.bintray.com/content/${bintrayOrganization.value.get}/rpm/",
|
|
|
|
|
bintrayRpmExperimentalUrl := s"https://api.bintray.com/content/${bintrayOrganization.value.get}/rpm-experimental/",
|
|
|
|
|
bintrayGenericPackagesUrl := s"https://api.bintray.com/content/${bintrayOrganization.value.get}/native-packages/",
|
|
|
|
|
bintrayTripple := {
|
|
|
|
|
config.name match {
|
|
|
|
|
case Debian.name if isExperimental => ("debian-experimental", bintrayDebianExperimentalUrl.value, bintrayLinuxPattern)
|
|
|
|
|
case Debian.name => ("debian", bintrayDebianUrl.value, bintrayLinuxPattern)
|
|
|
|
|
case Rpm.name if isExperimental => ("rpm-experimental", bintrayRpmExperimentalUrl.value, bintrayLinuxPattern)
|
|
|
|
|
case Rpm.name => ("rpm", bintrayRpmUrl.value, bintrayLinuxPattern)
|
|
|
|
|
case _ => ("native-packages", bintrayGenericPackagesUrl.value, bintrayGenericPattern)
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
publishTo := {
|
|
|
|
|
val (id, url, pattern) = bintrayTripple.value
|
|
|
|
|
val resolver = Resolver.url(id, new URL(url))(Patterns(pattern))
|
|
|
|
|
Some(resolver)
|
|
|
|
|
},
|
2015-08-11 07:30:16 +02:00
|
|
|
bintrayReleaseAllStaged := bintrayRelease(bintrayRepo.value, bintrayPackage.value, version.value, sLog.value)
|
|
|
|
|
// Uncomment to release right after publishing
|
|
|
|
|
// publish <<= (publish, bintrayRepo, bintrayPackage, version, sLog) apply { (publish, bintrayRepo, bintrayPackage, version, sLog) =>
|
|
|
|
|
// for {
|
|
|
|
|
// pub <- publish
|
|
|
|
|
// repo <- bintrayRepo
|
|
|
|
|
// } yield bintrayRelease(repo, bintrayPackage, version, sLog)
|
|
|
|
|
// }
|
2015-08-11 06:39:34 +02:00
|
|
|
)) ++ Seq(
|
2017-01-21 12:36:33 +01:00
|
|
|
resolvers ++= ((publishTo in config) apply (_.toSeq)).value
|
2015-08-11 06:39:34 +02:00
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|
|
2016-05-09 06:25:16 +02:00
|
|
|
def publishToSettings =
|
2015-08-11 06:39:34 +02:00
|
|
|
Seq[Configuration](Debian, Universal, Windows, Rpm) flatMap makePublishToForConfig
|
|
|
|
|
|
2015-08-11 07:30:16 +02:00
|
|
|
def bintrayRelease(repo: BintrayRepo, pkg: String, version: String, log: Logger): Unit =
|
|
|
|
|
repo.release(pkg, version, log)
|
2017-03-07 04:34:59 +01:00
|
|
|
|
|
|
|
|
def downloadUrl(uri: URI, out: File): Unit =
|
|
|
|
|
{
|
|
|
|
|
import dispatch.classic._
|
|
|
|
|
if(!out.exists) {
|
|
|
|
|
IO.touch(out)
|
|
|
|
|
val writer = new java.io.BufferedOutputStream(new java.io.FileOutputStream(out))
|
|
|
|
|
try Http(url(uri.toString) >>> writer)
|
|
|
|
|
finally writer.close()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
lazy val dist = (project in file("dist"))
|
|
|
|
|
.enablePlugins(ExportRepoPlugin)
|
|
|
|
|
.settings(
|
|
|
|
|
name := "dist",
|
2017-04-18 19:28:12 +02:00
|
|
|
scalaVersion := {
|
|
|
|
|
if (sbtVersionToRelease startsWith "0.13.") scala210
|
|
|
|
|
else scala212
|
|
|
|
|
},
|
|
|
|
|
libraryDependencies ++= Seq(sbtActual, jansi, scala212Compiler, scala212Jline, scala212Xml) ++ sbt013ExtraDeps,
|
2017-03-07 04:34:59 +01:00
|
|
|
exportRepo := {
|
|
|
|
|
val old = exportRepo.value
|
|
|
|
|
sbtVersionToRelease match {
|
2018-03-16 12:41:26 +01:00
|
|
|
case v if v.startsWith("1.") =>
|
2019-05-15 16:52:39 +02:00
|
|
|
sys.error("sbt 1.x should use coursier")
|
2017-03-07 04:34:59 +01:00
|
|
|
case v if v.startsWith("0.13.") =>
|
|
|
|
|
val outbase = exportRepoDirectory.value / "org.scala-sbt" / "compiler-interface" / v
|
|
|
|
|
val uribase = s"https://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/compiler-interface/$v/"
|
|
|
|
|
downloadUrl(uri(uribase + "ivys/ivy.xml"), outbase / "ivys" / "ivy.xml")
|
|
|
|
|
downloadUrl(uri(uribase + "jars/compiler-interface.jar"), outbase / "jars" / "compiler-interface.jar")
|
|
|
|
|
downloadUrl(uri(uribase + "srcs/compiler-interface-sources.jar"), outbase / "srcs" / "compiler-interface-sources.jar")
|
|
|
|
|
case _ =>
|
|
|
|
|
}
|
|
|
|
|
old
|
|
|
|
|
},
|
|
|
|
|
exportRepoDirectory := target.value / "lib" / "local-preloaded",
|
2019-05-15 16:52:39 +02:00
|
|
|
exportRepoCsrDirectory := exportRepoDirectory.value,
|
|
|
|
|
exportRepoUsingCoursier := {
|
|
|
|
|
val outDirectory = exportRepoCsrDirectory.value
|
|
|
|
|
val csr =
|
|
|
|
|
if (isWindows) (baseDirectory in LocalRootProject).value / "bin" / "coursier.bat"
|
|
|
|
|
else (baseDirectory in LocalRootProject).value / "bin" / "coursier"
|
|
|
|
|
val cache = target.value / "coursier"
|
|
|
|
|
IO.delete(cache)
|
|
|
|
|
val v = sbtVersionToRelease
|
|
|
|
|
s"$csr fetch --cache $cache org.scala-sbt:sbt:$v".!
|
|
|
|
|
val mavenCache = cache / "https" / "repo1.maven.org" / "maven2"
|
|
|
|
|
val compilerBridgeVer = IO.listFiles(mavenCache / "org" / "scala-sbt" / "compiler-bridge_2.12", DirectoryFilter).toList.headOption
|
|
|
|
|
compilerBridgeVer match {
|
|
|
|
|
case Some(bridgeDir) =>
|
|
|
|
|
val bridgeVer = bridgeDir.getName
|
|
|
|
|
s"$csr fetch --cache $cache --sources org.scala-sbt:compiler-bridge_2.10:$bridgeVer".!
|
|
|
|
|
s"$csr fetch --cache $cache --sources org.scala-sbt:compiler-bridge_2.11:$bridgeVer".!
|
|
|
|
|
s"$csr fetch --cache $cache --sources org.scala-sbt:compiler-bridge_2.12:$bridgeVer".!
|
|
|
|
|
s"$csr fetch --cache $cache --sources org.scala-sbt:compiler-bridge_2.13:$bridgeVer".!
|
|
|
|
|
case _ =>
|
|
|
|
|
sys.error("bridge not found")
|
|
|
|
|
}
|
|
|
|
|
IO.copyDirectory(mavenCache, outDirectory, true, true)
|
|
|
|
|
outDirectory
|
|
|
|
|
},
|
2017-03-07 04:34:59 +01:00
|
|
|
conflictWarning := ConflictWarning.disable,
|
|
|
|
|
publish := (),
|
2017-03-11 20:29:58 +01:00
|
|
|
publishLocal := (),
|
|
|
|
|
resolvers += Resolver.typesafeIvyRepo("releases")
|
2017-03-07 04:34:59 +01:00
|
|
|
)
|