mirror of https://github.com/sbt/sbt.git
Merge pull request #47 from sbt/wip/windows-jansi-fixes
Wip/windows jansi fixes
This commit is contained in:
commit
e5972108a3
|
|
@ -1,25 +0,0 @@
|
|||
import sbt._
|
||||
import com.typesafe.packager.Keys._
|
||||
import sbt.Keys._
|
||||
import com.typesafe.packager.PackagerPlugin._
|
||||
|
||||
|
||||
object MetaPackaging {
|
||||
|
||||
def settings(pkg: Project): Seq[Setting[_]] = packagerSettings ++ Seq(
|
||||
name := "sbt",
|
||||
version <<= sbtVersion apply {
|
||||
case "0.11.3" => "0.11.3-build0300"
|
||||
case v => v
|
||||
},
|
||||
// GENERAL LINUX PACKAGING STUFFS
|
||||
maintainer := "Josh Suereth <joshua.suereth@typesafe.com>",
|
||||
packageSummary := "Simple Build Tool for Scala-driven builds",
|
||||
packageDescription := """This meta-package provides the most up-to-date version of the SBT package.""",
|
||||
debianPackageDependencies in Debian <+= (name in Debian in pkg),
|
||||
// STUBBED values
|
||||
wixConfig := <dummy/>,
|
||||
rpmRelease := "1",
|
||||
rpmVendor := "typesafe"
|
||||
)
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
sbt.version=0.12.4-RC1
|
||||
|
|
@ -1,13 +1,11 @@
|
|||
import sbt._
|
||||
import Keys._
|
||||
|
||||
object SbtExtras extends Build {
|
||||
object SbtLauncherPackage extends Build {
|
||||
// This build creates a SBT plugin with handy features *and* bundles the SBT script for distribution.
|
||||
val root = Project("sbt-packaging", file(".")) settings(Packaging.settings:_*) settings(
|
||||
sbtVersion <<= sbtVersion apply { v =>
|
||||
sys.props.getOrElse("sbt.build.version", sys.env.getOrElse("sbt.build.version", v))
|
||||
}
|
||||
)
|
||||
|
||||
val meta = Project("metapackage", file("metapackage")) settings(MetaPackaging.settings(root):_*)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import sbt._
|
||||
import com.typesafe.packager.Keys._
|
||||
import com.typesafe.sbt.packager.Keys._
|
||||
import sbt.Keys._
|
||||
import com.typesafe.packager.PackagerPlugin._
|
||||
import com.typesafe.sbt.SbtNativePackager._
|
||||
|
||||
object Packaging {
|
||||
|
||||
|
|
@ -9,15 +9,8 @@ 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 fixedScriptDir = SettingKey[File]("fixed-script-dir")
|
||||
val fixedLinuxScriptDir = SettingKey[File]("fixed-linux-script-dir")
|
||||
val fixedUniversalScriptDir = SettingKey[File]("fixed-universal-script-dir")
|
||||
val linuxFixedScripts = TaskKey[File]("linux-fixed-scripts")
|
||||
val universalFixedScripts = TaskKey[File]("universal-fixed-scripts")
|
||||
val stagingDirectory = SettingKey[File]("staging-directory")
|
||||
val stage = TaskKey[File]("stage")
|
||||
|
||||
def localWindowsPattern = "[organisation]/[module]/[revision]/[module].[ext]"
|
||||
|
||||
|
|
@ -30,26 +23,7 @@ object Packaging {
|
|||
case _ => "http://repo.typesafe.com/typesafe/ivy-releases/org.scala-tools.sbt/sbt-launch/"+v+"/sbt-launch.jar"
|
||||
}
|
||||
|
||||
def fixScripts(launchJar: String, bashLib: String)(scriptDir: File, target: File): File = {
|
||||
if(!target.exists) target.mkdirs()
|
||||
for(file <- (scriptDir.*** --- scriptDir).get) {
|
||||
val tfile = target / file.getName
|
||||
// TODO - Speedier version
|
||||
val lines =
|
||||
for {
|
||||
line <- IO.readLines(file).view
|
||||
} yield line.replaceAll("@@BASH-LIB-LOCATION@@", bashLib).replaceAll("@@LAUNCH-JAR-LOCATION@@", launchJar)
|
||||
IO.writeLines(tfile, lines)
|
||||
}
|
||||
target
|
||||
}
|
||||
|
||||
val settings: Seq[Setting[_]] = packagerSettings ++ deploymentSettings ++ Seq(
|
||||
fixedScriptDir <<= sourceDirectory / "scripts",
|
||||
fixedLinuxScriptDir <<= target / "linux-scripts",
|
||||
fixedUniversalScriptDir <<= target / "universal-scripts",
|
||||
linuxFixedScripts <<= (fixedScriptDir, fixedLinuxScriptDir) map fixScripts("/usr/lib/sbt/sbt-launch.jar", "/usr/share/sbt/sbt-launch-lib.bash"),
|
||||
universalFixedScripts <<= (fixedScriptDir, fixedUniversalScriptDir) map fixScripts("\\$(dirname \\$(realpath \\$0))/sbt-launch.jar", "\\$(dirname \\$(realpath \\$0))/sbt-launch-lib.bash"),
|
||||
val settings: Seq[Setting[_]] = packagerSettings ++ deploymentSettings ++ mapGenericFilesToLinux ++ mapGenericFilesToWinows ++ Seq(
|
||||
sbtLaunchJarUrl <<= sbtVersion apply downloadUrlForVersion,
|
||||
sbtLaunchJarLocation <<= target apply (_ / "sbt-launch.jar"),
|
||||
sbtLaunchJar <<= (sbtLaunchJarUrl, sbtLaunchJarLocation) map { (uri, file) =>
|
||||
|
|
@ -64,59 +38,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) {
|
||||
// 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
|
||||
},
|
||||
// GENERAL LINUX PACKAGING STUFFS
|
||||
maintainer := "Josh Suereth <joshua.suereth@typesafe.com>",
|
||||
packageSummary := "Simple Build Tool for Scala-driven builds",
|
||||
packageDescription := """This script provides a native way to run the Simple Build Tool,
|
||||
a build tool for Scala software, also called SBT.""",
|
||||
linuxPackageMappings <+= (linuxFixedScripts) map { bd =>
|
||||
(packageMapping((bd / "sbt") -> "/usr/bin/sbt",
|
||||
bd -> "/usr/share/sbt",
|
||||
(bd / "sbt-launch-lib.bash") -> "/usr/share/sbt/sbt-launch-lib.bash")
|
||||
withUser "root" withGroup "root" withPerms "0755")
|
||||
},
|
||||
linuxPackageMappings <+= (sourceDirectory) map { bd =>
|
||||
(packageMapping(
|
||||
(bd / "linux" / "usr/share/man/man1/sbt.1") -> "/usr/share/man/man1/sbt.1.gz"
|
||||
) withPerms "0644" gzipped) asDocs()
|
||||
},
|
||||
linuxPackageMappings <+= (sourceDirectory in Linux) map { bd =>
|
||||
packageMapping(
|
||||
(bd / "usr/share/doc/sbt/copyright") -> "/usr/share/doc/sbt/copyright"
|
||||
) withPerms "0644" asDocs()
|
||||
},
|
||||
linuxPackageMappings <+= (sourceDirectory in Linux) map { bd =>
|
||||
packageMapping(
|
||||
(bd / "usr/share/doc/sbt") -> "/usr/share/doc/sbt"
|
||||
) asDocs()
|
||||
},
|
||||
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"
|
||||
) withPerms "0644" withConfig("noreplace")
|
||||
},
|
||||
linuxPackageMappings <+= (sbtLaunchJar, sourceDirectory in Linux, sbtVersion) map { (jar, dir, v) =>
|
||||
packageMapping(dir -> "/usr/lib/sbt",
|
||||
jar -> ("/usr/lib/sbt/sbt-launch.jar")) withPerms "0755"
|
||||
// Here we remove the jar file and launch lib from the symlinks:
|
||||
linuxPackageSymlinks <<= linuxPackageSymlinks map { links =>
|
||||
for {
|
||||
link <- links
|
||||
if !(link.destination endsWith "sbt-launch-lib.bash")
|
||||
if !(link.destination endsWith "sbt-launch.jar")
|
||||
} yield link
|
||||
},
|
||||
// DEBIAN SPECIFIC
|
||||
name in Debian <<= (sbtVersion) apply { (sv) => "sbt" /* + "-" + (sv split "[^\\d]" take 3 mkString ".")*/ },
|
||||
|
|
@ -143,177 +76,35 @@ object Packaging {
|
|||
|
||||
// WINDOWS SPECIFIC
|
||||
name in Windows := "sbt",
|
||||
candleOptions ++= Seq("-ext", "WixUtilExtension"),
|
||||
lightOptions ++= Seq("-ext", "WixUIExtension",
|
||||
"-ext", "WixUtilExtension",
|
||||
"-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" },
|
||||
mappings in packageMsi in Windows <+= jansiJar map { f => f -> "jansi.jar" },
|
||||
mappings in packageMsi in Windows <++= sourceDirectory in Windows map { d => Seq(
|
||||
(d / "sbt.bat") -> "sbt.bat",
|
||||
(d / "sbt") -> "sbt",
|
||||
(d / "sbtconfig.txt") -> "sbtconfig.txt",
|
||||
(d / "jansi-license.txt") -> "jansi-license.txt"
|
||||
)},
|
||||
mappings in packageMsi in Windows <+= (compile in Compile, classDirectory in Compile) map { (c, d) =>
|
||||
compile;
|
||||
(d / "SbtJansiLaunch.class") -> "SbtJansiLaunch.class"
|
||||
version in Windows <<= (sbtVersion) apply { sv =>
|
||||
(sv split "[^\\d]" filterNot (_.isEmpty)) match {
|
||||
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 "."
|
||||
}
|
||||
},
|
||||
maintainer in Windows := "Typesafe, Inc.",
|
||||
packageSummary in Windows := "Simple Build Tool",
|
||||
packageDescription in Windows := "THE reactive build tool.",
|
||||
wixProductId := "ce07be71-510d-414a-92d4-dff47631848a",
|
||||
wixProductUpgradeId := "4552fb0e-e257-4dbd-9ecb-dba9dbacf424",
|
||||
javacOptions := Seq("-source", "1.5", "-target", "1.5"),
|
||||
unmanagedJars in Compile <+= sbtLaunchJar map identity,
|
||||
unmanagedJars in Compile <+= jansiJar map identity,
|
||||
|
||||
// Universal ZIP download install. TODO - Share the above windows code, here....
|
||||
// Universal ZIP download install.
|
||||
name in Universal := "sbt",
|
||||
mappings in Universal <+= sbtLaunchJar map { _ -> "bin/sbt-launch.jar" },
|
||||
mappings in Universal <+= jansiJar map { f => f -> "bin/jansi.jar" },
|
||||
mappings in Universal <++= universalFixedScripts map { d =>
|
||||
Seq(
|
||||
(d / "sbt") -> "bin/sbt",
|
||||
(d / "sbt-launch-lib.bash") -> "bin/sbt-launch-lib.bash"
|
||||
)
|
||||
},
|
||||
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/classes/SbtJansiLaunch.class"
|
||||
},
|
||||
// TODO - Adapt global `sbt`/`sbt-launch-lib` scripts for universal install...
|
||||
|
||||
// Misccelaneous publishing stuff...
|
||||
projectID in Debian <<= (organization, sbtVersion) apply { (o,v) => ModuleID(o,"sbt",v) },
|
||||
projectID in Windows <<= (organization, sbtVersion) apply { (o,v) => ModuleID(o,"sbt",v) },
|
||||
projectID in Rpm <<= (organization, sbtVersion) apply { (o,v) => ModuleID(o,"sbt",v) },
|
||||
projectID in Universal <<= (organization, sbtVersion) apply { (o,v) => ModuleID(o,"sbt",v) }
|
||||
projectID in Universal <<= (organization, sbtVersion) apply { (o,v) => ModuleID(o,"sbt",v) },
|
||||
stagingDirectory <<= (target) apply { (t) => t / "stage" },
|
||||
stage <<= (stagingDirectory, mappings in Universal) map { (dir, m) =>
|
||||
val files = for((file, name) <- m)
|
||||
yield file -> (dir / name)
|
||||
IO copy files
|
||||
dir
|
||||
}
|
||||
)
|
||||
|
||||
def makeWindowsXml(sbtVersion: String, sourceDir: File): scala.xml.Node = {
|
||||
val version = (sbtVersion split "[^\\d]" filterNot (_.isEmpty)) match {
|
||||
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 "."
|
||||
}
|
||||
(
|
||||
<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'
|
||||
xmlns:util='http://schemas.microsoft.com/wix/UtilExtension'>
|
||||
<Product Id='ce07be71-510d-414a-92d4-dff47631848a'
|
||||
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.'
|
||||
InstallScope='perMachine'
|
||||
InstallerVersion='200'
|
||||
Compressed='yes' />
|
||||
|
||||
<Media Id='1' Cabinet='sbt.cab' EmbedCab='yes' />
|
||||
|
||||
<Property Id='NOTEPADEXE'>
|
||||
<DirectorySearch Id='NotePadContainer' Path='[SystemFolder]' Depth='0'>
|
||||
<FileSearch Id='NotepadFile' Name='notepad.exe'/>
|
||||
</DirectorySearch>
|
||||
</Property>
|
||||
|
||||
<Directory Id='TARGETDIR' Name='SourceDir'>
|
||||
<Directory Id="ProgramMenuFolder">
|
||||
<Directory Id="ApplicationProgramsFolder" Name="sbt"/>
|
||||
</Directory>
|
||||
<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='DE0A5B50-0792-40A9-AEE0-AB97E9F845F5'>
|
||||
<File Id='sbt_bat' Name='sbt.bat' DiskId='1' Source='sbt.bat'>
|
||||
<util:PermissionEx User="Administrators" GenericAll="yes" />
|
||||
<util:PermissionEx User="Users" GenericAll="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>
|
||||
</Component>
|
||||
<Component Id='SbtConfigFile' Guid='*'>
|
||||
<File Id='sbtconfig_txt' Name='sbtconfig.txt' DiskId='1' Source='sbtconfig.txt'>
|
||||
<util:PermissionEx User="Administrators" GenericAll="yes" />
|
||||
<util:PermissionEx User="Users" GenericAll="yes" />
|
||||
</File>
|
||||
</Component>
|
||||
<Component Id='JansiJar' Guid='3370A26B-E8AB-4143-B837-CE9A8573BF60'>
|
||||
<File Id='jansi_jar' Name='jansi.jar' DiskId='1' Source='jansi.jar' />
|
||||
<File Id='jansi_license' Name='jansi-license.txt' DiskId='1' Source='jansi-license.txt' />
|
||||
</Component>
|
||||
<Component Id='SbtLauncherJar' Guid='*'>
|
||||
<File Id='sbt_launch_jar' Name='sbt-launch.jar' DiskId='1' Source='sbt-launch.jar' />
|
||||
</Component>
|
||||
<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" />
|
||||
<Environment Id="SBT_HOME" Name="SBT_HOME" Value="[INSTALLDIR]" Permanent="no" Action="set" System="yes" />
|
||||
</Component>
|
||||
</Directory>
|
||||
</Directory>
|
||||
</Directory>
|
||||
<!-- Step 2: Add the shortcut to your installer package -->
|
||||
<DirectoryRef Id="ApplicationProgramsFolder">
|
||||
<Component Id="ConfigShortcut" Guid="3370A26B-E8AB-4143-B837-CE9A8573BF61">
|
||||
<Shortcut Id="ConfigStartMenuShortcut"
|
||||
Name="sbt configuration"
|
||||
Description="Modify sbt configuration settings"
|
||||
Target="[INSTALLDIR]sbtconfig.txt"
|
||||
WorkingDirectory="INSTALLDIR"/>
|
||||
<RemoveFolder Id="ApplicationProgramsFolder" On="uninstall"/>
|
||||
<RegistryValue Root="HKCU" Key="Software\Typesafe\sbt" Name="installed" Type="integer" Value="1" KeyPath="yes"/>
|
||||
</Component>
|
||||
</DirectoryRef>
|
||||
|
||||
<Feature Id='Complete' Title='Simple Build Tool' Description='The windows installation of Simple Build Tool.'
|
||||
Display='expand' Level='1' ConfigurableDirectory='INSTALLDIR'>
|
||||
<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' />
|
||||
<ComponentRef Id='SbtConfigFile' />
|
||||
</Feature>
|
||||
<Feature Id='SbtLauncherPathF' Title='Add SBT to windows system PATH' Description='This will append SBT to your windows system path (Requires Restart).' Level='1'>
|
||||
<ComponentRef Id='SbtLauncherPath'/>
|
||||
</Feature>
|
||||
<Feature Id='SbtLauncherConfigF' Title='Add Menu Shortcuts' Description='This will add menu shortcuts for sbt configuration.' Level='1'>
|
||||
<ComponentRef Id='ConfigShortcut'/>
|
||||
</Feature>
|
||||
</Feature>
|
||||
<!--<Property Id="JAVAVERSION">
|
||||
<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"/>
|
||||
<Property Id="WIXUI_INSTALLDIR" Value="INSTALLDIR"/>
|
||||
<WixVariable Id="WixUILicenseRtf" Value={sourceDir.getAbsolutePath + "\\License.rtf"} />
|
||||
|
||||
</Product>
|
||||
</Wix>
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,7 +6,10 @@ object PluginBuild extends Build {
|
|||
|
||||
val root = Project("root", file(".")) settings(
|
||||
resolvers += Resolver.url("scalasbt", new URL("http://scalasbt.artifactoryonline.com/scalasbt/sbt-plugin-releases"))(Resolver.ivyStylePatterns),
|
||||
addSbtPlugin("com.typesafe" % "sbt-native-packager" % "0.4.4"),
|
||||
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "0.6.0-symlink-3"),
|
||||
libraryDependencies += "net.databinder" % "dispatch-http_2.9.1" % "0.8.6"
|
||||
)
|
||||
) //dependsOn(nativePackager)
|
||||
|
||||
|
||||
//lazy val nativePackager = uri("file:///C:/projects/sbt-native-packager")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +0,0 @@
|
|||
class SbtJansiLaunch {
|
||||
public static void main(String[] args) {
|
||||
org.fusesource.jansi.AnsiConsole.systemInstall();
|
||||
xsbt.boot.Boot.main(args);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,31 +1,67 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
|
||||
### ------------------------------- ###
|
||||
### Helper methods for BASH scripts ###
|
||||
### ------------------------------- ###
|
||||
|
||||
realpath () {
|
||||
(
|
||||
TARGET_FILE=$1
|
||||
TARGET_FILE="$1"
|
||||
|
||||
cd $(dirname $TARGET_FILE)
|
||||
TARGET_FILE=$(basename $TARGET_FILE)
|
||||
cd $(dirname "$TARGET_FILE")
|
||||
TARGET_FILE=$(basename "$TARGET_FILE")
|
||||
|
||||
COUNT=0
|
||||
while [ -L "$TARGET_FILE" -a $COUNT -lt 100 ]
|
||||
do
|
||||
TARGET_FILE=$(readlink $TARGET_FILE)
|
||||
cd $(dirname $TARGET_FILE)
|
||||
TARGET_FILE=$(basename $TARGET_FILE)
|
||||
TARGET_FILE=$(readlink "$TARGET_FILE")
|
||||
cd $(dirname "$TARGET_FILE")
|
||||
TARGET_FILE=$(basename "$TARGET_FILE")
|
||||
COUNT=$(($COUNT + 1))
|
||||
done
|
||||
|
||||
echo $(pwd -P)/$TARGET_FILE
|
||||
# make sure we grab the actual windows path, instead of cygwin's path.
|
||||
echo $(cygwinpath "$(pwd -P)/$TARGET_FILE")
|
||||
)
|
||||
}
|
||||
|
||||
. @@BASH-LIB-LOCATION@@
|
||||
|
||||
# Uses uname to detect if we're in the odd cygwin environment.
|
||||
is_cygwin() {
|
||||
local os=$(uname -s)
|
||||
case "$os" in
|
||||
CYGWIN*) return 0 ;;
|
||||
*) return 1 ;;
|
||||
esac
|
||||
}
|
||||
|
||||
# TODO - Use nicer bash-isms here.
|
||||
CYGWIN_FLAG=$(if is_cygwin; then echo true; else echo false; fi)
|
||||
|
||||
|
||||
# This can fix cygwin style /cygdrive paths so we get the
|
||||
# windows style paths.
|
||||
cygwinpath() {
|
||||
local file="$1"
|
||||
if [[ "$CYGWIN_FLAG" == "true" ]]; then
|
||||
echo $(cygpath -w $file)
|
||||
else
|
||||
echo $file
|
||||
fi
|
||||
}
|
||||
|
||||
if [[ "$CYGWIN_FLAG" == "true" ]]; then
|
||||
. $(dirname "$(cygpath "$(realpath "$0")")")/sbt-launch-lib.bash
|
||||
else
|
||||
. $(dirname "$(realpath "$0")")/sbt-launch-lib.bash
|
||||
fi
|
||||
|
||||
|
||||
declare -r noshare_opts="-Dsbt.global.base=project/.sbtboot -Dsbt.boot.directory=project/.boot -Dsbt.ivy.home=project/.ivy"
|
||||
declare -r sbt_opts_file=".sbtopts"
|
||||
declare -r etc_sbt_opts_file="/etc/sbt/sbtopts"
|
||||
declare -r etc_sbt_opts_file="${sbt_home}/conf/sbtopts"
|
||||
declare -r win_sbt_opts_file="${sbt_home}/conf/sbtconfig.txt"
|
||||
|
||||
usage() {
|
||||
cat <<EOM
|
||||
|
|
@ -99,8 +135,16 @@ loadConfigFile() {
|
|||
done
|
||||
}
|
||||
|
||||
# if sbtopts files exist, prepend their contents to $@ so it can be processed by this runner
|
||||
# TODO - Pull in config based on operating system... (MSYS + cygwin should pull in txt file).
|
||||
# Here we pull in the global settings configuration.
|
||||
[[ -f "$etc_sbt_opts_file" ]] && set -- $(loadConfigFile "$etc_sbt_opts_file") "$@"
|
||||
# -- Windows behavior stub'd
|
||||
# JAVA_OPTS=$(cat "$WDIR/sbtconfig.txt" | sed -e 's/\r//g' -e 's/^#.*$//g' | sed ':a;N;$!ba;s/\n/ /g')
|
||||
|
||||
|
||||
# Pull in the project-level config file, if it exists.
|
||||
[[ -f "$sbt_opts_file" ]] && set -- $(loadConfigFile "$sbt_opts_file") "$@"
|
||||
|
||||
|
||||
run "$@"
|
||||
|
||||
48
src/scripts/sbt-launch-lib.bash → src/universal/bin/sbt-launch-lib.bash
Normal file → Executable file
48
src/scripts/sbt-launch-lib.bash → src/universal/bin/sbt-launch-lib.bash
Normal file → Executable file
|
|
@ -17,6 +17,8 @@ declare -a java_args
|
|||
declare -a scalac_args
|
||||
declare -a sbt_commands
|
||||
declare java_cmd=java
|
||||
declare -r sbt_bin_dir="$(dirname "$(realpath "$0")")"
|
||||
declare -r sbt_home="$(dirname "$sbt_bin_dir")"
|
||||
|
||||
echoerr () {
|
||||
echo 1>&2 "$@"
|
||||
|
|
@ -29,7 +31,8 @@ dlog () {
|
|||
}
|
||||
|
||||
jar_file () {
|
||||
echo "@@LAUNCH-JAR-LOCATION@@"
|
||||
# TODO - Is this where we want the launch jar?
|
||||
echo "${sbt_home}/bin/sbt-launch.jar"
|
||||
}
|
||||
|
||||
acquire_sbt_jar () {
|
||||
|
|
@ -128,6 +131,31 @@ process_args () {
|
|||
}
|
||||
}
|
||||
|
||||
# Detect that we have java installed.
|
||||
checkJava() {
|
||||
local required_version="$1"
|
||||
# Now check to see if it's a good enough version
|
||||
declare -r java_version=$("$java_cmd" -version 2>&1 | awk -F '"' '/version/ {print $2}')
|
||||
if [[ "$java_version" == "" ]]; then
|
||||
echo
|
||||
echo No java installations was detected.
|
||||
echo Please go to http://www.java.com/getjava/ and download
|
||||
echo
|
||||
exit 1
|
||||
elif [[ ! "$java_version" > "$required_version" ]]; then
|
||||
echo
|
||||
echo The java installation you have is not up to date
|
||||
echo $script_name requires at least version $required_version+, you have
|
||||
echo version $java_version
|
||||
echo
|
||||
echo Please go to http://www.java.com/getjava/ and download
|
||||
echo a valid Java Runtime and install before running $script_name.
|
||||
echo
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
|
||||
run() {
|
||||
# no jar? download it.
|
||||
[[ -f "$sbt_jar" ]] || acquire_sbt_jar "$sbt_version" || {
|
||||
|
|
@ -141,6 +169,16 @@ run() {
|
|||
set -- "${residual_args[@]}"
|
||||
argumentCount=$#
|
||||
|
||||
# TODO - java check should be configurable...
|
||||
checkJava "1.6"
|
||||
|
||||
#If we're in cygwin, we should use the windows config, and terminal hacks
|
||||
if [[ "$CYGWIN_FLAG" == "true" ]]; then
|
||||
stty -icanon min 1 -echo > /dev/null 2>&1
|
||||
addJava "-Djline.terminal=jline.UnixTerminal"
|
||||
addJava "-Dsbt.cygwin=true"
|
||||
fi
|
||||
|
||||
# run sbt
|
||||
execRunner "$java_cmd" \
|
||||
${SBT_OPTS:-$default_sbt_opts} \
|
||||
|
|
@ -150,6 +188,14 @@ run() {
|
|||
-jar "$sbt_jar" \
|
||||
"${sbt_commands[@]}" \
|
||||
"${residual_args[@]}"
|
||||
|
||||
exit_code=$?
|
||||
|
||||
# Clean up the terminal from cygwin hacks.
|
||||
if [[ "$IS_CYGWIN" == "true" ]]; then
|
||||
stty icanon echo > /dev/null 2>&1
|
||||
fi
|
||||
exit $exit_code
|
||||
}
|
||||
|
||||
runAlternateBoot() {
|
||||
|
|
@ -14,7 +14,7 @@ set SBT_HOME=%~dp0
|
|||
set ERROR_CODE=0
|
||||
|
||||
rem FIRST we load the config file of extra options.
|
||||
set FN=%SBT_HOME%sbtconfig.txt
|
||||
set FN=%SBT_HOME%\..\conf\sbtconfig.txt
|
||||
set CFG_OPTS=
|
||||
FOR /F "tokens=* eol=# usebackq delims=" %%i IN ("%FN%") DO (
|
||||
set DO_NOT_REUSE_ME=%%i
|
||||
|
|
@ -40,7 +40,7 @@ if "%_JAVA_OPTS%"=="" set _JAVA_OPTS=%CFG_OPTS%
|
|||
|
||||
:run
|
||||
|
||||
"%_JAVACMD%" %_JAVA_OPTS% %SBT_OPTS% -cp "%SBT_HOME%jansi.jar;%SBT_HOME%sbt-launch.jar;%SBT_HOME%classes" SbtJansiLaunch %*
|
||||
"%_JAVACMD%" %_JAVA_OPTS% %SBT_OPTS% -cp "%SBT_HOME%sbt-launch.jar" xsbt.boot.Boot %*
|
||||
if ERRORLEVEL 1 goto error
|
||||
goto end
|
||||
|
||||
|
|
@ -1,202 +0,0 @@
|
|||
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
||||
|
|
@ -24,12 +24,15 @@ if [ -z "$JAVA_OPTS" ]; then
|
|||
JAVA_OPTS=$(cat "$WDIR/sbtconfig.txt" | sed -e 's/\r//g' -e 's/^#.*$//g' | sed ':a;N;$!ba;s/\n/ /g')
|
||||
fi
|
||||
|
||||
# TODO - this check should detect cygwin terminal, not just xterm.
|
||||
if [ "_$TERM" = "_xterm" ]; then
|
||||
# Let the terminal handle ANSI sequences
|
||||
stty -icanon min 1 -echo > /dev/null 2>&1
|
||||
"$JAVA_CMD" $JAVA_OPTS -Djline.terminal=jline.UnixTerminal $SBT_OPTS -jar "$WDIR/sbt-launch.jar" "$@"
|
||||
"$JAVA_CMD" $JAVA_OPTS -Djline.terminal=jline.UnixTerminal -Dsbt.cygwin=true $SBT_OPTS -jar "$WDIR/sbt-launch.jar" "$@"
|
||||
SCALA_STATUS=$?
|
||||
stty icanon echo > /dev/null 2>&1
|
||||
exit $SCALA_STATUS
|
||||
else
|
||||
# Use Jansi to intercept ANSI sequences
|
||||
"$JAVA_CMD" -Dsbt.log.format=true $JAVA_OPTS $SBT_OPTS -cp "$WDIR/jansi.jar;$WDIR/sbt-launch.jar;$WDIR/classes" SbtJansiLaunch "$@"
|
||||
"$JAVA_CMD" -Dsbt.log.format=true $JAVA_OPTS $SBT_OPTS -cp "$WDIR/sbt-launch.jar" xsbt.boot.Boot "$@"
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -1,36 +0,0 @@
|
|||
<?xml version='1.0'?>
|
||||
<Wix xmlns='http://schemas.microsoft.com/wix/2006/wi'>
|
||||
<Product Id='ce07be71-510d-414a-92d4-dff47631848a'
|
||||
Name='Simple Build Tool'
|
||||
Language='1033'
|
||||
Version='0.10.2.1'
|
||||
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.'
|
||||
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'>
|
||||
<Component Id='SbtLauncherScript' Guid='*'>
|
||||
<File Id='sbt_bat' Name='sbt.bat' DiskId='1' Source='sbt.bat' />
|
||||
<Environment Id="PATH" Name="PATH" Value="[INSTALLDIR]" Permanent="no" Part="last" Action="set" System="yes" />
|
||||
</Component>
|
||||
<Component Id='SbtLauncherJar' Guid='*'>
|
||||
<File Id='sbt_launch_jar' Name='sbt-launch.jar' DiskId='1' Source='sbt-launch.jar' />
|
||||
</Component>
|
||||
</Directory>
|
||||
</Directory>
|
||||
</Directory>
|
||||
|
||||
<Feature Id='SbtLauncher' Title='Sbt Launcher Script' Level='1'>
|
||||
<ComponentRef Id='SbtLauncherScript' />
|
||||
<ComponentRef Id='SbtLauncherJar' />
|
||||
</Feature>
|
||||
</Product>
|
||||
</Wix>
|
||||
Loading…
Reference in New Issue