2011-11-29 00:52:47 +01:00
|
|
|
import sbt._
|
2011-12-21 17:21:16 +01:00
|
|
|
import com.typesafe.packager.Keys._
|
|
|
|
|
import sbt.Keys._
|
|
|
|
|
import com.typesafe.packager.PackagerPlugin._
|
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
|
|
|
|
2012-01-17 18:03:26 +01:00
|
|
|
val jansiJarUrl = SettingKey[String]("jansi-jar-url")
|
|
|
|
|
val jansiJarLocation = SettingKey[File]("jansi-jar-location")
|
|
|
|
|
val jansiJar = TaskKey[File]("jansi-jar", "Resolves Jansi jar")
|
|
|
|
|
|
2012-01-17 15:32:44 +01:00
|
|
|
val winowsReleaseUrl = "http://typesafe.artifactoryonline.com/typesafe/windows-releases"
|
|
|
|
|
|
|
|
|
|
def localWindowsPattern = "[organisation]/[module]/[revision]/[module].[ext]"
|
2011-12-20 03:15:10 +01:00
|
|
|
|
2011-12-21 17:21:16 +01:00
|
|
|
val settings: Seq[Setting[_]] = packagerSettings ++ Seq(
|
2011-12-21 20:39:57 +01:00
|
|
|
sbtLaunchJarUrl <<= sbtVersion apply ("http://typesafe.artifactoryonline.com/typesafe/ivy-releases/org.scala-tools.sbt/sbt-launch/"+_+"/sbt-launch.jar"),
|
|
|
|
|
sbtLaunchJarLocation <<= target apply (_ / "sbt-launch.jar"),
|
|
|
|
|
sbtLaunchJar <<= (sbtLaunchJarUrl, sbtLaunchJarLocation) map { (uri, file) =>
|
|
|
|
|
import dispatch._
|
|
|
|
|
if(!file.exists) {
|
|
|
|
|
val writer = new java.io.BufferedOutputStream(new java.io.FileOutputStream(file))
|
|
|
|
|
try Http(url(uri) >>> writer)
|
|
|
|
|
finally writer.close()
|
|
|
|
|
}
|
|
|
|
|
// TODO - GPG Trust validation.
|
|
|
|
|
file
|
|
|
|
|
},
|
2012-01-17 18:03:26 +01:00
|
|
|
jansiJarUrl := "http://repo.fusesource.com/nexus/content/groups/public/org/fusesource/jansi/jansi/1.7/jansi-1.7.jar",
|
|
|
|
|
jansiJarLocation <<= target apply (_ / "jansi-1.7.jar"),
|
|
|
|
|
jansiJar <<= (jansiJarUrl, jansiJarLocation) map { (uri, file) =>
|
|
|
|
|
import dispatch._
|
|
|
|
|
if(!file.exists) {
|
|
|
|
|
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.""",
|
2012-02-01 15:42:40 +01:00
|
|
|
linuxPackageMappings <+= (sourceDirectory in Linux) map { bd =>
|
|
|
|
|
(packageMapping((bd / "sbt") -> "/usr/bin/sbt",
|
2012-02-02 19:03:52 +01:00
|
|
|
bd -> "/usr/share/sbt",
|
2012-02-02 18:28:40 +01:00
|
|
|
(bd / "sbt-launch-lib.bash") -> "/usr/share/sbt/sbt-launch-lib.bash")
|
2011-12-21 04:25:02 +01:00
|
|
|
withUser "root" withGroup "root" withPerms "0755")
|
|
|
|
|
},
|
|
|
|
|
linuxPackageMappings <+= (sourceDirectory) map { bd =>
|
2011-12-21 17:21:16 +01:00
|
|
|
(packageMapping(
|
2011-12-21 04:25:02 +01:00
|
|
|
(bd / "linux" / "usr/share/man/man1/sbt.1") -> "/usr/share/man/man1/sbt.1.gz"
|
2011-12-21 17:21:16 +01:00
|
|
|
) withPerms "0644" gzipped) asDocs()
|
2011-12-21 04:25:02 +01:00
|
|
|
},
|
2011-12-21 19:52:26 +01:00
|
|
|
linuxPackageMappings <+= (sourceDirectory in Linux) map { bd =>
|
2011-12-21 17:21:16 +01:00
|
|
|
packageMapping(
|
2011-12-21 04:25:02 +01:00
|
|
|
(bd / "usr/share/doc/sbt/copyright") -> "/usr/share/doc/sbt/copyright"
|
2011-12-21 17:21:16 +01:00
|
|
|
) withPerms "0644" asDocs()
|
2011-12-21 04:25:02 +01:00
|
|
|
},
|
2011-12-21 19:52:26 +01:00
|
|
|
linuxPackageMappings <+= (sourceDirectory in Linux) map { bd =>
|
2011-12-21 17:21:16 +01:00
|
|
|
packageMapping(
|
|
|
|
|
(bd / "usr/share/doc/sbt") -> "/usr/share/doc/sbt"
|
|
|
|
|
) asDocs()
|
|
|
|
|
},
|
2011-12-21 20:20:16 +01:00
|
|
|
linuxPackageMappings <+= (sourceDirectory in Linux) map { bd =>
|
|
|
|
|
packageMapping(
|
|
|
|
|
(bd / "etc/sbt") -> "/etc/sbt"
|
|
|
|
|
) withConfig()
|
|
|
|
|
},
|
|
|
|
|
linuxPackageMappings <+= (sourceDirectory in Linux) map { bd =>
|
|
|
|
|
packageMapping(
|
|
|
|
|
(bd / "etc/sbt/sbtopts") -> "/etc/sbt/sbtopts"
|
2012-01-11 20:10:10 +01:00
|
|
|
) withPerms "0644" withConfig("noreplace")
|
2011-12-21 20:20:16 +01:00
|
|
|
},
|
2011-12-21 20:39:57 +01:00
|
|
|
linuxPackageMappings <+= (sbtLaunchJar, sourceDirectory in Linux, sbtVersion) map { (jar, dir, v) =>
|
|
|
|
|
packageMapping(dir -> "/usr/lib/sbt",
|
|
|
|
|
dir -> ("/usr/lib/sbt/" + v),
|
|
|
|
|
jar -> ("/usr/lib/sbt/"+v+"/sbt-launch.jar")) withPerms "0755"
|
|
|
|
|
},
|
2011-12-21 04:25:02 +01:00
|
|
|
// DEBIAN SPECIFIC
|
2011-11-29 00:52:47 +01:00
|
|
|
name in Debian := "sbt",
|
|
|
|
|
version in Debian <<= (version, sbtVersion) apply { (v, sv) =>
|
2011-12-20 03:15:10 +01:00
|
|
|
sv + "-build-" + (v split "\\." map (_.toInt) dropWhile (_ == 0) map ("%02d" format _) mkString "")
|
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",
|
|
|
|
|
version in Rpm <<= sbtVersion.identity,
|
|
|
|
|
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",
|
2012-01-11 17:50:57 +01:00
|
|
|
lightOptions ++= Seq("-ext", "WixUIExtension", "-cultures:en-us"),
|
|
|
|
|
wixConfig <<= (sbtVersion, sourceDirectory in Windows) map makeWindowsXml,
|
|
|
|
|
//wixFile <<= sourceDirectory in Windows map (_ / "sbt.xml"),
|
|
|
|
|
mappings in packageMsi in Windows <+= sbtLaunchJar map { f => f -> "sbt-launch.jar" },
|
2012-01-17 18:03:26 +01:00
|
|
|
mappings in packageMsi in Windows <+= jansiJar map { f => f -> "jansi.jar" },
|
2012-01-18 16:50:17 +01:00
|
|
|
mappings in packageMsi in Windows <++= sourceDirectory in Windows map { d => Seq(
|
|
|
|
|
(d / "sbt.bat") -> "sbt.bat",
|
2012-01-18 16:58:30 +01:00
|
|
|
(d / "sbt") -> "sbt",
|
2012-01-18 16:50:17 +01:00
|
|
|
(d / "jansi-license.txt") -> "jansi-license.txt"
|
|
|
|
|
)},
|
2012-01-17 18:03:26 +01:00
|
|
|
mappings in packageMsi in Windows <+= (compile in Compile, classDirectory in Compile) map { (c, d) =>
|
2012-01-17 19:15:39 +01:00
|
|
|
compile;
|
|
|
|
|
(d / "SbtJansiLaunch.class") -> "SbtJansiLaunch.class"
|
2012-01-17 15:32:44 +01:00
|
|
|
},
|
2012-01-17 18:03:26 +01:00
|
|
|
javacOptions := Seq("-source", "1.5", "-target", "1.5"),
|
|
|
|
|
unmanagedJars in Compile <+= sbtLaunchJar map identity,
|
2012-01-17 20:15:00 +01:00
|
|
|
unmanagedJars in Compile <+= jansiJar map identity,
|
2012-03-15 19:22:10 +01:00
|
|
|
|
|
|
|
|
// Universal ZIP download install. TODO - Share the above windows code, here....
|
|
|
|
|
mappings in Universal <+= sbtLaunchJar map { f => f -> "bin/sbt-launch.jar" },
|
|
|
|
|
mappings in Universal <+= jansiJar map { f => f -> "bin/jansi.jar" },
|
|
|
|
|
mappings in Universal <++= sourceDirectory in Windows map { d => Seq(
|
|
|
|
|
(d / "sbt.bat") -> "bin/sbt.bat",
|
|
|
|
|
(d / "sbt") -> "bin/win-sbt",
|
|
|
|
|
(d / "jansi-license.txt") -> "jansi-license.txt"
|
|
|
|
|
)},
|
|
|
|
|
mappings in Universal <+= (compile in Compile, classDirectory in Compile) map { (c, d) =>
|
|
|
|
|
compile;
|
|
|
|
|
(d / "SbtJansiLaunch.class") -> "bin/SbtJansiLaunch.class"
|
2012-01-17 18:56:30 +01:00
|
|
|
}
|
2012-03-15 19:22:10 +01:00
|
|
|
// TODO - Adapt global `sbt`/`sbt-launch-lib` scripts for universal install...
|
|
|
|
|
)
|
2012-01-11 17:50:57 +01:00
|
|
|
|
2012-01-17 19:15:39 +01:00
|
|
|
def makeWindowsXml(sbtVersion: String, sourceDir: File): scala.xml.Node = {
|
2012-01-11 17:50:57 +01:00
|
|
|
val version = (sbtVersion split "\\.") match {
|
2011-12-28 16:14:19 +01:00
|
|
|
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 "."
|
|
|
|
|
}
|
|
|
|
|
(
|
2012-01-18 16:58:30 +01:00
|
|
|
<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi' xmlns:util='http://schemas.microsoft.com/wix/UtilExtension'>
|
2012-01-11 17:50:57 +01:00
|
|
|
<Product Id='ce07be71-510d-414a-92d4-dff47631848a'
|
2011-12-28 16:14:19 +01:00
|
|
|
Name='Simple Build Tool'
|
|
|
|
|
Language='1033'
|
|
|
|
|
Version={version}
|
|
|
|
|
Manufacturer='Typesafe, Inc.'
|
|
|
|
|
UpgradeCode='4552fb0e-e257-4dbd-9ecb-dba9dbacf424'>
|
|
|
|
|
<Package Description='Simple Build Tool launcher script.'
|
|
|
|
|
Comments='First attempt to create an SBT windows installer, bear with me.'
|
|
|
|
|
Manufacturer='Typesafe, Inc.'
|
2012-02-02 21:35:38 +01:00
|
|
|
InstallScope='perMachine'
|
2011-12-28 16:14:19 +01:00
|
|
|
InstallerVersion='200'
|
|
|
|
|
Compressed='yes' />
|
|
|
|
|
|
|
|
|
|
<Media Id='1' Cabinet='sbt.cab' EmbedCab='yes' />
|
|
|
|
|
|
|
|
|
|
<Directory Id='TARGETDIR' Name='SourceDir'>
|
|
|
|
|
<Directory Id='ProgramFilesFolder' Name='PFiles'>
|
|
|
|
|
<Directory Id='INSTALLDIR' Name='sbt'>
|
2012-01-17 18:03:26 +01:00
|
|
|
<Directory Id='classes_dir' Name='classes'>
|
|
|
|
|
<Component Id='JansiLaunch' Guid='*'>
|
|
|
|
|
<File Id='jansi_launch' Name='SbtJansiLaunch.class' DiskId='1' Source='SbtJansiLaunch.class' />
|
|
|
|
|
</Component>
|
|
|
|
|
</Directory>
|
2012-01-18 16:58:30 +01:00
|
|
|
<Component Id='SbtLauncherScript' Guid='DE0A5B50-0792-40A9-AEE0-AB97E9F845F5'>
|
|
|
|
|
<File Id='sbt_bat' Name='sbt.bat' DiskId='1' Source='sbt.bat'>
|
|
|
|
|
<!-- <util:PermissionEx User="Users" Domain="[LOCAL_MACHINE_NAME]" GenericRead="yes" Read="yes" GenericExecute="yes" ChangePermission="yes"/> -->
|
|
|
|
|
</File>
|
|
|
|
|
<File Id='sbt_sh' Name='sbt' DiskId='1' Source='sbt'>
|
|
|
|
|
<!-- <util:PermissionEx User="Users" Domain="[LOCAL_MACHINE_NAME]" GenericRead="yes" Read="yes" GenericExecute="yes" ChangePermission="yes"/> -->
|
|
|
|
|
</File>
|
2011-12-28 16:14:19 +01:00
|
|
|
</Component>
|
2012-01-18 16:50:17 +01:00
|
|
|
<Component Id='JansiJar' Guid='3370A26B-E8AB-4143-B837-CE9A8573BF60'>
|
2012-01-17 18:03:26 +01:00
|
|
|
<File Id='jansi_jar' Name='jansi.jar' DiskId='1' Source='jansi.jar' />
|
2012-01-18 16:50:17 +01:00
|
|
|
<File Id='jansi_license' Name='jansi-license.txt' DiskId='1' Source='jansi-license.txt' />
|
2012-01-17 18:03:26 +01:00
|
|
|
</Component>
|
2011-12-28 16:14:19 +01:00
|
|
|
<Component Id='SbtLauncherJar' Guid='*'>
|
|
|
|
|
<File Id='sbt_launch_jar' Name='sbt-launch.jar' DiskId='1' Source='sbt-launch.jar' />
|
|
|
|
|
</Component>
|
2012-01-11 17:50:57 +01:00
|
|
|
<Component Id='SbtLauncherPath' Guid='17EA4092-3C70-11E1-8CD8-1BB54724019B'>
|
|
|
|
|
<CreateFolder/>
|
|
|
|
|
<Environment Id="PATH" Name="PATH" Value="[INSTALLDIR]" Permanent="no" Part="last" Action="set" System="yes" />
|
2012-02-03 03:10:37 +01:00
|
|
|
<Environment Id="SBT_HOME" Name="SBT_HOME" Value="[INSTALLDIR]" Permanent="no" Action="set" System="yes" />
|
2012-01-11 17:50:57 +01:00
|
|
|
</Component>
|
|
|
|
|
</Directory>
|
2011-12-28 16:14:19 +01:00
|
|
|
</Directory>
|
|
|
|
|
</Directory>
|
|
|
|
|
|
2012-01-11 17:50:57 +01:00
|
|
|
<Feature Id='Complete' Title='Simple Build Tool' Description='The windows installation of Simple Build Tool.'
|
|
|
|
|
Display='expand' Level='1' ConfigurableDirectory='INSTALLDIR'>
|
2012-01-17 18:56:30 +01:00
|
|
|
<Feature Id='SbtLauncher' Title='Sbt Launcher Script' Description='The application which downloads and launches SBT.' Level='1' Absent='disallow'>
|
2012-01-11 17:50:57 +01:00
|
|
|
<ComponentRef Id='SbtLauncherScript'/>
|
|
|
|
|
<ComponentRef Id='SbtLauncherJar' />
|
2012-01-17 18:03:26 +01:00
|
|
|
<ComponentRef Id='JansiLaunch' />
|
|
|
|
|
<ComponentRef Id='JansiJar' />
|
2012-01-11 17:50:57 +01:00
|
|
|
</Feature>
|
|
|
|
|
<Feature Id='SbtLauncherPathF' Title='Add SBT to windows system PATH' Description='This will append SBT to your windows system path.' Level='1'>
|
|
|
|
|
<ComponentRef Id='SbtLauncherPath'/>
|
|
|
|
|
</Feature>
|
2011-12-28 16:14:19 +01:00
|
|
|
</Feature>
|
2012-02-15 13:05:52 +01:00
|
|
|
<!--<Property Id="JAVAVERSION">
|
2012-01-17 18:56:30 +01:00
|
|
|
<RegistrySearch Id="JavaVersion"
|
|
|
|
|
Root="HKLM"
|
|
|
|
|
Key="SOFTWARE\Javasoft\Java Runtime Environment"
|
|
|
|
|
Name="CurrentVersion"
|
|
|
|
|
Type="raw"/>
|
|
|
|
|
</Property>
|
|
|
|
|
<Condition Message="This application requires a JVM available. Please install Java, then run this installer again.">
|
|
|
|
|
<![CDATA[Installed OR JAVAVERSION]]>
|
2012-02-15 13:05:52 +01:00
|
|
|
</Condition>-->
|
2012-01-17 18:56:30 +01:00
|
|
|
<MajorUpgrade
|
|
|
|
|
AllowDowngrades="no"
|
|
|
|
|
Schedule="afterInstallInitialize"
|
|
|
|
|
DowngradeErrorMessage="A later version of [ProductName] is already installed. Setup will no exit."/>
|
|
|
|
|
<UIRef Id="WixUI_FeatureTree"/>
|
2012-01-11 17:50:57 +01:00
|
|
|
<UIRef Id="WixUI_ErrorProgressText"/>
|
|
|
|
|
<Property Id="WIXUI_INSTALLDIR" Value="INSTALLDIR"/>
|
|
|
|
|
<WixVariable Id="WixUILicenseRtf" Value={sourceDir.getAbsolutePath + "\\License.rtf"} />
|
2012-01-17 18:56:30 +01:00
|
|
|
|
2011-12-28 16:14:19 +01:00
|
|
|
</Product>
|
2012-01-17 19:15:39 +01:00
|
|
|
</Wix>
|
|
|
|
|
)
|
2012-01-11 17:50:57 +01:00
|
|
|
}
|
2011-11-29 00:52:47 +01:00
|
|
|
}
|