summaryrefslogtreecommitdiff
path: root/project
diff options
context:
space:
mode:
authorStefan Zeiger <szeiger@novocode.com>2016-01-21 17:56:46 +0100
committerStefan Zeiger <szeiger@novocode.com>2016-01-21 17:56:46 +0100
commit842ae5a78e4d9675c6bfb53c5cd4d52026d37bef (patch)
treea75efcbec967d7f5ab626fe4b0aead254ede010c /project
parente97bc1fb8e5c82da2a53d5bb0a5b08e0e53847e2 (diff)
downloadscala-842ae5a78e4d9675c6bfb53c5cd4d52026d37bef.tar.gz
scala-842ae5a78e4d9675c6bfb53c5cd4d52026d37bef.tar.bz2
scala-842ae5a78e4d9675c6bfb53c5cd4d52026d37bef.zip
Use Windows classpath in sh scripts when building in sbt on Windows
The generated scripts for "quick" are not portable anyway (neither in the sbt build nor in the ant build) because they contain absolute paths. When using the sh versions on Windows in MSYS or Cygwin, the classpath must be in Windows format because "java" expects it that way. Note that none of this applies to "pack" (and thus to distribution builds) where the classpath is constructed dynamically by the launcher scripts itself.
Diffstat (limited to 'project')
-rw-r--r--project/ScalaTool.scala14
1 files changed, 10 insertions, 4 deletions
diff --git a/project/ScalaTool.scala b/project/ScalaTool.scala
index 559b215c18..a30f5f0a73 100644
--- a/project/ScalaTool.scala
+++ b/project/ScalaTool.scala
@@ -1,4 +1,5 @@
import sbt._
+import org.apache.commons.lang3.SystemUtils
import org.apache.commons.lang3.StringUtils.replaceEach
/**
@@ -17,6 +18,14 @@ case class ScalaTool(mainClass: String,
// `@SCALA_HOME@`) and automatically translated for you.
def patchedToolScript(template: String, platform: String) = {
val varRegex = """@(\w+)@""" // the group should be able to capture each of the keys of the map below
+ val platformClasspath = platform match {
+ case "unix" =>
+ // When building on Windows, use a Windows classpath in the shell script (for MSYS/Cygwin).
+ // This is only used for "quick", which uses absolute paths, so it is not portable anyway.
+ if(SystemUtils.IS_OS_WINDOWS) classpath.mkString(";").replace("\\", "\\\\").replaceAll(varRegex, """\${$1}""")
+ else classpath.mkString(":").replace('\\', '/').replaceAll(varRegex, """\${$1}""")
+ case "windows" => classpath.mkString(";").replace('/', '\\').replaceAll(varRegex, "%$1%")
+ }
val variables = Map(
("@@" -> "@"), // for backwards compatibility
@@ -24,10 +33,7 @@ case class ScalaTool(mainClass: String,
("@properties@" -> (properties map { case (k, v) => s"""-D$k="$v""""} mkString " ")),
("@javaflags@" -> javaOpts),
("@toolflags@" -> toolFlags),
- ("@classpath@" -> (platform match {
- case "unix" => classpath.mkString(":").replace('\\', '/').replaceAll(varRegex, """\${$1}""")
- case "windows" => classpath.mkString(";").replace('/', '\\').replaceAll(varRegex, "%$1%")
- }))
+ ("@classpath@" -> platformClasspath)
)
val (from, to) = variables.unzip