Merge branch 'full-packaging' of github.com:sbt/sbt-launcher-package into full-packaging

This commit is contained in:
Josh Suereth 2012-01-18 09:49:15 -05:00
commit 7e27da416e
3 changed files with 78 additions and 12 deletions

View File

@ -9,6 +9,10 @@ object Packaging {
val sbtLaunchJarLocation = SettingKey[File]("sbt-launch-jar-location") val sbtLaunchJarLocation = SettingKey[File]("sbt-launch-jar-location")
val sbtLaunchJar = TaskKey[File]("sbt-launch-jar", "Resolves SBT launch jar") val sbtLaunchJar = TaskKey[File]("sbt-launch-jar", "Resolves SBT launch jar")
val jansiJarUrl = SettingKey[String]("jansi-jar-url")
val jansiJarLocation = SettingKey[File]("jansi-jar-location")
val jansiJar = TaskKey[File]("jansi-jar", "Resolves Jansi jar")
val winowsReleaseUrl = "http://typesafe.artifactoryonline.com/typesafe/windows-releases" val winowsReleaseUrl = "http://typesafe.artifactoryonline.com/typesafe/windows-releases"
def localWindowsPattern = "[organisation]/[module]/[revision]/[module].[ext]" def localWindowsPattern = "[organisation]/[module]/[revision]/[module].[ext]"
@ -26,6 +30,18 @@ object Packaging {
// TODO - GPG Trust validation. // TODO - GPG Trust validation.
file file
}, },
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
},
// GENERAL LINUX PACKAGING STUFFS // GENERAL LINUX PACKAGING STUFFS
maintainer := "Josh Suereth <joshua.suereth@typesafe.com>", maintainer := "Josh Suereth <joshua.suereth@typesafe.com>",
packageSummary := "Simple Build Tool for Scala-driven builds", packageSummary := "Simple Build Tool for Scala-driven builds",
@ -93,18 +109,37 @@ object Packaging {
wixConfig <<= (sbtVersion, sourceDirectory in Windows) map makeWindowsXml, wixConfig <<= (sbtVersion, sourceDirectory in Windows) map makeWindowsXml,
//wixFile <<= sourceDirectory in Windows map (_ / "sbt.xml"), //wixFile <<= sourceDirectory in Windows map (_ / "sbt.xml"),
mappings in packageMsi in Windows <+= sbtLaunchJar map { f => f -> "sbt-launch.jar" }, mappings in packageMsi in Windows <+= sbtLaunchJar map { f => f -> "sbt-launch.jar" },
mappings in packageMsi in Windows <+= jansiJar map { f => f -> "jansi.jar" },
mappings in packageMsi in Windows <+= sourceDirectory in Windows map { d => mappings in packageMsi in Windows <+= sourceDirectory in Windows map { d =>
(d / "sbt.bat") -> "sbt.bat" } (d / "sbt.bat") -> "sbt.bat" },
mappings in packageMsi in Windows <+= (compile in Compile, classDirectory in Compile) map { (c, d) =>
compile;
(d / "SbtJansiLaunch.class") -> "SbtJansiLaunch.class"
},
javacOptions := Seq("-source", "1.5", "-target", "1.5"),
unmanagedJars in Compile <+= sbtLaunchJar map identity,
unmanagedJars in Compile <+= jansiJar map identity
// WINDOWS MSI Publishing // WINDOWS MSI Publishing
) ++ inConfig(Windows)(Classpaths.publishSettings) ++ Seq( ) ++ (inConfig(Windows)(Classpaths.publishSettings)) ++ (inConfig(Windows)(Seq(
packagedArtifacts in Windows <<= (packageMsi in Windows, name in Windows) map { (msi, name) => packagedArtifacts <<= (packageMsi, name) map { (msi, name) =>
val artifact = Artifact(name, "msi", "msi", classifier = None, configurations = Iterable.empty, url = None, extraAttributes = Map.empty) val artifact = Artifact(name, "msi", "msi", classifier = None, configurations = Iterable.empty, url = None, extraAttributes = Map.empty)
Map(artifact -> msi) Map(artifact -> msi)
}, },
publishTo in Windows := Some(Resolver.url("windows-releases", new URL(winowsReleaseUrl))(Patterns(localWindowsPattern))) publishMavenStyle := true,
) projectID <<= (organization, name, sbtVersion) apply { (o,n,v) => ModuleID(o,n,v) },
moduleSettings <<= Classpaths.moduleSettings0,
deliverLocalConfiguration <<= (crossTarget, ivyLoggingLevel) map { (outDir, level) => Classpaths.deliverConfig(outDir, logging = level) },
deliverConfiguration <<= deliverLocalConfiguration,
publishTo := Some(Resolver.url("windows-releases", new URL(winowsReleaseUrl))(Patterns(localWindowsPattern))),
publishConfiguration <<= (packagedArtifacts, publishTo, publishMavenStyle, deliver, checksums in publish, ivyLoggingLevel) map { (arts, publishTo, mavenStyle, ivyFile, checks, level) =>
Classpaths.publishConfig(arts, if(mavenStyle) None else Some(ivyFile), resolverName = Classpaths.getPublishTo(publishTo).name, checksums = checks, logging = level)
},
publishLocalConfiguration <<= (packagedArtifacts, deliverLocal, checksums in publishLocal, ivyLoggingLevel) map {
(arts, ivyFile, checks, level) => Classpaths.publishConfig(arts, Some(ivyFile), checks, logging = level )
}
)))
def makeWindowsXml(sbtVersion: String, sourceDir: File) = { def makeWindowsXml(sbtVersion: String, sourceDir: File): scala.xml.Node = {
val version = (sbtVersion split "\\.") match { val version = (sbtVersion split "\\.") match {
case Array(major,minor,bugfix, _*) => Seq(major,minor,bugfix, "1") mkString "." case Array(major,minor,bugfix, _*) => Seq(major,minor,bugfix, "1") mkString "."
case Array(major,minor) => Seq(major,minor,"0","1") mkString "." case Array(major,minor) => Seq(major,minor,"0","1") mkString "."
@ -129,9 +164,17 @@ object Packaging {
<Directory Id='TARGETDIR' Name='SourceDir'> <Directory Id='TARGETDIR' Name='SourceDir'>
<Directory Id='ProgramFilesFolder' Name='PFiles'> <Directory Id='ProgramFilesFolder' Name='PFiles'>
<Directory Id='INSTALLDIR' Name='sbt'> <Directory Id='INSTALLDIR' Name='sbt'>
<Directory Id='classes_dir' Name='classes'>
<Component Id='JansiLaunch' Guid='*'>
<File Id='jansi_launch' Name='SbtJansiLaunch.class' DiskId='1' Source='SbtJansiLaunch.class' />
</Component>
</Directory>
<Component Id='SbtLauncherScript' Guid='*'> <Component Id='SbtLauncherScript' Guid='*'>
<File Id='sbt_bat' Name='sbt.bat' DiskId='1' Source='sbt.bat' /> <File Id='sbt_bat' Name='sbt.bat' DiskId='1' Source='sbt.bat' />
</Component> </Component>
<Component Id='JansiJar' Guid='*'>
<File Id='jansi_jar' Name='jansi.jar' DiskId='1' Source='jansi.jar' />
</Component>
<Component Id='SbtLauncherJar' Guid='*'> <Component Id='SbtLauncherJar' Guid='*'>
<File Id='sbt_launch_jar' Name='sbt-launch.jar' DiskId='1' Source='sbt-launch.jar' /> <File Id='sbt_launch_jar' Name='sbt-launch.jar' DiskId='1' Source='sbt-launch.jar' />
</Component> </Component>
@ -145,20 +188,37 @@ object Packaging {
<Feature Id='Complete' Title='Simple Build Tool' Description='The windows installation of Simple Build Tool.' <Feature Id='Complete' Title='Simple Build Tool' Description='The windows installation of Simple Build Tool.'
Display='expand' Level='1' ConfigurableDirectory='INSTALLDIR'> Display='expand' Level='1' ConfigurableDirectory='INSTALLDIR'>
<Feature Id='SbtLauncher' Title='Sbt Launcher Script' Description='The application which downloads and launches SBT.' Level='1'> <Feature Id='SbtLauncher' Title='Sbt Launcher Script' Description='The application which downloads and launches SBT.' Level='1' Absent='disallow'>
<ComponentRef Id='SbtLauncherScript'/> <ComponentRef Id='SbtLauncherScript'/>
<ComponentRef Id='SbtLauncherJar' /> <ComponentRef Id='SbtLauncherJar' />
<ComponentRef Id='JansiLaunch' />
<ComponentRef Id='JansiJar' />
</Feature> </Feature>
<Feature Id='SbtLauncherPathF' Title='Add SBT to windows system PATH' Description='This will append SBT to your windows system path.' Level='1'> <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'/> <ComponentRef Id='SbtLauncherPath'/>
</Feature> </Feature>
</Feature> </Feature>
<Property Id="JAVAVERSION">
<UIRef Id="WixUI_Mondo"/> <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]]>
</Condition>
<MajorUpgrade
AllowDowngrades="no"
Schedule="afterInstallInitialize"
DowngradeErrorMessage="A later version of [ProductName] is already installed. Setup will no exit."/>
<UIRef Id="WixUI_FeatureTree"/>
<UIRef Id="WixUI_ErrorProgressText"/> <UIRef Id="WixUI_ErrorProgressText"/>
<Property Id="WIXUI_INSTALLDIR" Value="INSTALLDIR"/> <Property Id="WIXUI_INSTALLDIR" Value="INSTALLDIR"/>
<WixVariable Id="WixUILicenseRtf" Value={sourceDir.getAbsolutePath + "\\License.rtf"} /> <WixVariable Id="WixUILicenseRtf" Value={sourceDir.getAbsolutePath + "\\License.rtf"} />
</Product> </Product>
</Wix>) </Wix>
)
} }
} }

View File

@ -0,0 +1,6 @@
class SbtJansiLaunch {
public static void main(String[] args) {
org.fusesource.jansi.AnsiConsole.systemInstall();
xsbt.boot.Boot.main(args);
}
}

View File

@ -1,3 +1,3 @@
@echo off @echo off
set SCRIPT_DIR=%~dp0 set SBT_HOME=%~dp0
java -Xmx512M -jar "%SCRIPT_DIR%sbt-launch.jar" %* java -Xmx512M -Dsbt.log.format=true -cp "%SBT_HOME%jansi.jar;%SBT_HOME%sbt-launch.jar;%SBT_HOME%classes" SbtJansiLaunch %*