Skip to content

Commit

Permalink
Merged szeiger's ANSI enhancements for windows. Closes #1
Browse files Browse the repository at this point in the history
  • Loading branch information
jsuereth committed Jan 17, 2012
2 parents b0deb8c + 2f19508 commit 046fb3e
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 5 deletions.
41 changes: 38 additions & 3 deletions project/packaging.scala
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ object Packaging {
val sbtLaunchJarLocation = SettingKey[File]("sbt-launch-jar-location")
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"

def localWindowsPattern = "[organisation]/[module]/[revision]/[module].[ext]"
Expand All @@ -26,6 +30,18 @@ object Packaging {
// TODO - GPG Trust validation.
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
maintainer := "Josh Suereth <joshua.suereth@typesafe.com>",
packageSummary := "Simple Build Tool for Scala-driven builds",
Expand Down Expand Up @@ -93,8 +109,16 @@ object Packaging {
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" },
mappings in packageMsi in Windows <+= jansiJar map { f => f -> "jansi.jar" },
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
) ++ (inConfig(Windows)(Classpaths.publishSettings)) ++ (inConfig(Windows)(Seq(
packagedArtifacts <<= (packageMsi, name) map { (msi, name) =>
Expand All @@ -115,7 +139,7 @@ object Packaging {
}
)))

def makeWindowsXml(sbtVersion: String, sourceDir: File) = {
def makeWindowsXml(sbtVersion: String, sourceDir: File): scala.xml.Node = {
val version = (sbtVersion split "\\.") match {
case Array(major,minor,bugfix, _*) => Seq(major,minor,bugfix, "1") mkString "."
case Array(major,minor) => Seq(major,minor,"0","1") mkString "."
Expand All @@ -140,9 +164,17 @@ object Packaging {
<Directory Id='TARGETDIR' Name='SourceDir'>
<Directory Id='ProgramFilesFolder' Name='PFiles'>
<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='*'>
<File Id='sbt_bat' Name='sbt.bat' DiskId='1' Source='sbt.bat' />
</Component>
<Component Id='JansiJar' Guid='*'>
<File Id='jansi_jar' Name='jansi.jar' DiskId='1' Source='jansi.jar' />
</Component>
<Component Id='SbtLauncherJar' Guid='*'>
<File Id='sbt_launch_jar' Name='sbt-launch.jar' DiskId='1' Source='sbt-launch.jar' />
</Component>
Expand All @@ -159,6 +191,8 @@ object Packaging {
<Feature Id='SbtLauncher' Title='Sbt Launcher Script' Description='The application which downloads and launches SBT.' Level='1' Absent='disallow'>
<ComponentRef Id='SbtLauncherScript'/>
<ComponentRef Id='SbtLauncherJar' />
<ComponentRef Id='JansiLaunch' />
<ComponentRef Id='JansiJar' />
</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'/>
Expand All @@ -184,6 +218,7 @@ object Packaging {
<WixVariable Id="WixUILicenseRtf" Value={sourceDir.getAbsolutePath + "\\License.rtf"} />

</Product>
</Wix>)
</Wix>
)
}
}
6 changes: 6 additions & 0 deletions src/main/java/SbtJansiLaunch.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
class SbtJansiLaunch {
public static void main(String[] args) {
org.fusesource.jansi.AnsiConsole.systemInstall();
xsbt.boot.Boot.main(args);
}
}
4 changes: 2 additions & 2 deletions src/windows/sbt.bat
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
@echo off
set SCRIPT_DIR=%~dp0
java -Xmx512M -jar "%SCRIPT_DIR%sbt-launch.jar" %*
set SBT_HOME=%~dp0
java -Xmx512M -Dsbt.log.format=true -cp "%SBT_HOME%jansi.jar;%SBT_HOME%sbt-launch.jar;%SBT_HOME%classes" SbtJansiLaunch %*

0 comments on commit 046fb3e

Please sign in to comment.