diff options
-rw-r--r-- | project/ScalaTool.scala | 14 |
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 |