diff options
author | michelou <michelou@epfl.ch> | 2006-03-28 18:10:56 +0000 |
---|---|---|
committer | michelou <michelou@epfl.ch> | 2006-03-28 18:10:56 +0000 |
commit | 65f9252a9ae23c5091bd898bb66e3d8227992718 (patch) | |
tree | a6da98dcad79c77848bb0edb472216d968123163 | |
parent | d9942ba66f0d2abe7d97a31f62144deb13526340 (diff) | |
download | scala-65f9252a9ae23c5091bd898bb66e3d8227992718.tar.gz scala-65f9252a9ae23c5091bd898bb66e3d8227992718.tar.bz2 scala-65f9252a9ae23c5091bd898bb66e3d8227992718.zip |
reintroduced attribute 'bootclasspath' in Ant t...
reintroduced attribute 'bootclasspath' in Ant task 'ScalaTool'
5 files changed, 58 insertions, 22 deletions
diff --git a/src/compiler/scala/tools/ant/ScalaTool.scala b/src/compiler/scala/tools/ant/ScalaTool.scala index 94ab2d9918..caadcaf688 100644 --- a/src/compiler/scala/tools/ant/ScalaTool.scala +++ b/src/compiler/scala/tools/ant/ScalaTool.scala @@ -2,10 +2,11 @@ ** / |/ / ____/ ____/ ** ** / | | /___ / /___ ** ** /_/|__/_____/_____/ Copyright 2005-2006 LAMP/EPFL ** -** -** $Id$ +** ** \* */ +// $Id$ + package scala.tools.ant { import scala.collection.immutable.{Map, ListMap} @@ -30,7 +31,8 @@ package scala.tools.ant { * <li>platforms,</li> * <li>version,</li> * <li>copyright,</li> - * <li>classpath,</li> + * <li>bootclasspath,</li> + * <li>extclasspath,</li> * <li>properties,</li> * <li>javaflags,</li> * <li>toolflags,</li> @@ -73,6 +75,8 @@ package scala.tools.ant { private var version: String = "" /** The optional copyright notice, that will be printed in the script. */ private var copyright: String = "This file is copyrighted by its owner" + /** The optional boot classpath */ + private var bootclasspath: List[String] = Nil /** An (optional) path to all JARs that this script depend on. Paths must be * relative to the scala home directory. If not set, all JAR archives in * "lib/" are automatically added. */ @@ -132,8 +136,13 @@ package scala.tools.ant { def setCopyright(input: String) = copyright = input + /** Sets the boot classpath attribute. Used by Ant. + * @param input The value of <code>bootclasspath</code>. */ + def setBootclasspath(input: String) = + bootclasspath = bootclasspath ::: List.fromArray(input.split(":")) + /** Sets the extension classpath attribute. Used by Ant. - * @param input The value of <code>classpath</code>. */ + * @param input The value of <code>extclasspath</code>. */ def setExtclasspath(input: String) = extclasspath = extclasspath ::: List.fromArray(input.split(":")) @@ -168,6 +177,17 @@ package scala.tools.ant { if (file.isEmpty) error("Member 'file' is empty.") else getProject().resolveFile(file.get.toString()) + /** Gets the value of the bootclasspath attribute in a Scala-friendly form. + * @returns The boot class path as a list of files. */ + private def getUnixBootClasspath: String = + bootclasspath.mkString("", ":", "") + + /** Gets the value of the bootclasspath attribute in a Scala-friendly form. + * @returns The boot class path as a list of files. */ + private def getWinBootClasspath: String = + bootclasspath.map(.replace('/', '\\')). + mkString("", ";", "") + /** Gets the value of the classpath attribute in a Scala-friendly form. * @returns The class path as a list of files. */ private def getUnixExtClasspath: String = @@ -256,6 +276,7 @@ package scala.tools.ant { val resourceRoot = "scala/tools/ant/templates/" if (platforms.contains("unix")) { val unixPatches = expandUnixVar(patches. + update("bootclasspath", getUnixBootClasspath). update("extclasspath", getUnixExtClasspath)) val unixTemplateResource = resourceRoot + template + "-unix.tmpl" val unixTemplate = readResource(unixTemplateResource, unixPatches) @@ -263,6 +284,7 @@ package scala.tools.ant { } if (platforms.contains("windows")) { val winPatches = expandWinVar(patches. + update("bootclasspath", getWinBootClasspath). update("extclasspath", getWinExtClasspath)) val winTemplateResource = resourceRoot + template + "-windows.tmpl" val winTemplate = readResource(winTemplateResource, winPatches) diff --git a/src/compiler/scala/tools/ant/templates/generic-unix.tmpl b/src/compiler/scala/tools/ant/templates/generic-unix.tmpl index dd25bac505..ec21780c2b 100644 --- a/src/compiler/scala/tools/ant/templates/generic-unix.tmpl +++ b/src/compiler/scala/tools/ant/templates/generic-unix.tmpl @@ -36,7 +36,7 @@ USER_CLASSPATH="." USER_ARGS="" if [ "$EXTENSION_CLASSPATH" == "" ] ; then - for jar in `ls $SCALA_HOME/lib/*.jar` ; do + for jar in `ls "$SCALA_HOME"/lib/*.jar` ; do EXTENSION_CLASSPATH="$EXTENSION_CLASSPATH:$jar" done EXTENSION_CLASSPATH=${EXTENSION_CLASSPATH:1} @@ -72,8 +72,8 @@ else fi fi -BOOT_CLASSPATH="" -if [ -f "$SCALA_HOME/lib/scala-library.jar" ] ; then +BOOT_CLASSPATH="@bootclasspath@" +if [[ "$BOOT_CLASSPATH" == "" && -f "$SCALA_HOME/lib/scala-library.jar" ]] ; then BOOT_CLASSPATH="$SCALA_HOME/lib/scala-library.jar" fi diff --git a/src/compiler/scala/tools/ant/templates/generic-windows.tmpl b/src/compiler/scala/tools/ant/templates/generic-windows.tmpl index 2320695701..02d3c1fe6e 100644 --- a/src/compiler/scala/tools/ant/templates/generic-windows.tmpl +++ b/src/compiler/scala/tools/ant/templates/generic-windows.tmpl @@ -25,20 +25,27 @@ set _JAVACMD=%JAVACMD% if "%_JAVACMD%"=="" set _JAVACMD=java set _EXTENSION_CLASSPATH=@extclasspath@ -if "%_EXTENSION_CLASSPATH%"=="" for %%f in ("%_SCALA_HOME%\lib\*.jar") do call :add_cpath "%%f" +if "%_EXTENSION_CLASSPATH%"=="" ( + for %%f in ("%_SCALA_HOME%\lib\*.jar") do call :add_cpath "%%f" +) -set _BOOT_CLASSPATH= -if exist "%_SCALA_HOME%/lib/scala-library.jar" set _BOOT_CLASSPATH=%_SCALA_HOME%/lib/scala-library.jar +set _BOOT_CLASSPATH=@bootclasspath@ +if "%_BOOT_CLASSPATH%"=="" ( + if exist "%_SCALA_HOME%\lib\scala-library.jar" ( + set _BOOT_CLASSPATH=%_SCALA_HOME%\lib\scala-library.jar + ) +) set _USER_CLASSPATH=%CLASSPATH% if "%_USER_CLASSPATH%"=="" set _USER_CLASSPATH=. set _ARGS= :loop -if "%1"=="" goto exec -if "%1"=="-classpath" goto cpath -if "%1"=="-cp" goto cpath -if "%1"=="-version" goto version +rem Argument %1 may contain quotes so we use parentheses here +if (%1)==() goto exec +if (%1)==(-classpath) goto cpath +if (%1)==(-cp) goto cpath +if (%1)==(-version) goto version set _ARGS=%_ARGS% %1 shift goto loop diff --git a/src/compiler/scala/tools/ant/templates/tool-unix.tmpl b/src/compiler/scala/tools/ant/templates/tool-unix.tmpl index cf1837371d..0af1990cff 100644 --- a/src/compiler/scala/tools/ant/templates/tool-unix.tmpl +++ b/src/compiler/scala/tools/ant/templates/tool-unix.tmpl @@ -33,14 +33,14 @@ SCALA_HOME=`cd "$SCALA_HOME"; pwd`; EXTENSION_CLASSPATH="@extclasspath@" if [ "$EXTENSION_CLASSPATH" == "" ] ; then - for jar in `ls $SCALA_HOME/lib/*.jar` ; do + for jar in `ls "$SCALA_HOME"/lib/*.jar` ; do EXTENSION_CLASSPATH="$EXTENSION_CLASSPATH:$jar" done EXTENSION_CLASSPATH=${EXTENSION_CLASSPATH:1} fi -BOOT_CLASSPATH="" -if [ -f "$SCALA_HOME/lib/scala-library.jar" ] ; then +BOOT_CLASSPATH="@bootclasspath@" +if [[ "$BOOT_CLASSPATH" == "" && -f "$SCALA_HOME/lib/scala-library.jar" ]] ; then BOOT_CLASSPATH="$SCALA_HOME/lib/scala-library.jar" fi diff --git a/src/compiler/scala/tools/ant/templates/tool-windows.tmpl b/src/compiler/scala/tools/ant/templates/tool-windows.tmpl index 0429535258..fc2a784d32 100644 --- a/src/compiler/scala/tools/ant/templates/tool-windows.tmpl +++ b/src/compiler/scala/tools/ant/templates/tool-windows.tmpl @@ -25,18 +25,25 @@ set _JAVACMD=%JAVACMD% if "%_JAVACMD%"=="" set _JAVACMD=java set _EXTENSION_CLASSPATH=@extclasspath@ -if "%_EXTENSION_CLASSPATH%"=="" for %%f in ("%_SCALA_HOME%\lib\*.jar") do call :add_cpath "%%f" +if "%_EXTENSION_CLASSPATH%"=="" ( + for %%f in ("%_SCALA_HOME%\lib\*.jar") do call :add_cpath "%%f" +) -set _BOOT_CLASSPATH= -if exist "%_SCALA_HOME%/lib/scala-library.jar" set _BOOT_CLASSPATH=%_SCALA_HOME%/lib/scala-library.jar +set _BOOT_CLASSPATH=@bootclasspath@ +if "%_BOOT_CLASSPATH%"=="" ( + if exist "%_SCALA_HOME%\lib\scala-library.jar" ( + set _BOOT_CLASSPATH=%_SCALA_HOME%\lib\scala-library.jar + ) +) set _MYCLASSPATH=%_EXTENSION_CLASSPATH% if not "%_BOOT_CLASSPATH%"=="" set _MYCLASSPATH=%_BOOT_CLASSPATH%;%_MYCLASSPATH% set _ARGS= :loop -if "%1"=="" goto exec -if "%1"=="-version" goto version +rem Argument %1 may contain quotes so we use parentheses here +if (%1)==() goto exec +if (%1)==(-version) goto version set _ARGS=%_ARGS% %1 shift goto loop |