From 14c88ba747393bf5a23a4d41b37059d51e8ac718 Mon Sep 17 00:00:00 2001 From: michelou Date: Tue, 17 Apr 2007 16:55:01 +0000 Subject: added variable JAVA_OPTS to the generated Unix ... added variable JAVA_OPTS to the generated Unix tools --- src/compiler/scala/tools/ant/FastScalac.scala | 13 +- src/compiler/scala/tools/ant/ScalaBazaar.scala | 16 +- src/compiler/scala/tools/ant/ScalaTool.scala | 411 +++++++++++---------- src/compiler/scala/tools/ant/Scalac.scala | 13 +- src/compiler/scala/tools/ant/Scaladoc.scala | 13 +- .../scala/tools/ant/templates/tool-unix.tmpl | 2 +- 6 files changed, 242 insertions(+), 226 deletions(-) (limited to 'src') diff --git a/src/compiler/scala/tools/ant/FastScalac.scala b/src/compiler/scala/tools/ant/FastScalac.scala index 8af86c6759..1fd5155c09 100644 --- a/src/compiler/scala/tools/ant/FastScalac.scala +++ b/src/compiler/scala/tools/ant/FastScalac.scala @@ -1,9 +1,10 @@ -/* __ ______________ *\ -** / |/ / ____/ ____/ ** -** / | | /___ / /___ ** -** /_/|__/_____/_____/ Copyright 2005-2007 LAMP/EPFL ** -** ** -\* */ +/* __ *\ +** ________ ___ / / ___ Scala Ant Tasks ** +** / __/ __// _ | / / / _ | (c) 2005-2007, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ // $Id$ diff --git a/src/compiler/scala/tools/ant/ScalaBazaar.scala b/src/compiler/scala/tools/ant/ScalaBazaar.scala index 312686e37c..6d60d98d5a 100644 --- a/src/compiler/scala/tools/ant/ScalaBazaar.scala +++ b/src/compiler/scala/tools/ant/ScalaBazaar.scala @@ -1,10 +1,12 @@ -/* __ ______________ *\ -** / |/ / ____/ ____/ ** -** / | | /___ / /___ ** -** /_/|__/_____/_____/ Copyright 2005-2006 LAMP/EPFL ** -** -** $Id$ -\* */ +/* __ *\ +** ________ ___ / / ___ Scala Ant Tasks ** +** / __/ __// _ | / / / _ | (c) 2005-2007, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ + +// $Id$ package scala.tools.ant { diff --git a/src/compiler/scala/tools/ant/ScalaTool.scala b/src/compiler/scala/tools/ant/ScalaTool.scala index b024a62527..0a18098b74 100644 --- a/src/compiler/scala/tools/ant/ScalaTool.scala +++ b/src/compiler/scala/tools/ant/ScalaTool.scala @@ -1,205 +1,218 @@ -/* __ ______________ *\ -** / |/ / ____/ ____/ ** -** / | | /___ / /___ ** -** /_/|__/_____/_____/ Copyright 2005-2007 LAMP/EPFL ** -** ** -\* */ +/* __ *\ +** ________ ___ / / ___ Scala Ant Tasks ** +** / __/ __// _ | / / / _ | (c) 2005-2007, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ // $Id$ -package scala.tools.ant { - - import compat.StringBuilder - - import scala.collection.immutable.{Map, ListMap} - - import java.io.{File, InputStream, FileWriter} - import java.net.{URL, URLClassLoader} - import java.util.{ArrayList, Vector} - - import org.apache.tools.ant.{AntClassLoader, BuildException, - DirectoryScanner, Project} - import org.apache.tools.ant.taskdefs.MatchingTask - import org.apache.tools.ant.types.Path - import org.apache.tools.ant.util.{FileUtils, GlobPatternMapper, - SourceFileScanner} - import org.apache.tools.ant.types.{EnumeratedAttribute, Reference} - - /**

- * An Ant task that generates a shell or batch script to execute a - * Scala program. - * This task can take the following parameters as attributes: - *

- * - * @author Gilles Dubochet - * @version 1.0 - */ - class ScalaTool extends MatchingTask { - - /** The unique Ant file utilities instance to use in this task. */ - private val fileUtils = FileUtils.newFileUtils() +package scala.tools.ant + +import scala.collection.immutable.{Map, ListMap} + +import java.io.{File, InputStream, FileWriter} + +import org.apache.tools.ant.BuildException +import org.apache.tools.ant.taskdefs.MatchingTask +import org.apache.tools.ant.types.Path +import org.apache.tools.ant.util.FileUtils + +/**

+ * An Ant task that generates a shell or batch script to execute a + * Scala program. + * This task can take the following parameters as attributes: + *

+ * + * @author Gilles Dubochet + * @version 1.0 + */ +class ScalaTool extends MatchingTask { + + /** The unique Ant file utilities instance to use in this task. */ + private val fileUtils = FileUtils.newFileUtils() /*============================================================================*\ ** Ant user-properties ** \*============================================================================*/ - abstract class PermissibleValue { - val values: List[String] - def isPermissible(value: String): Boolean = - (value == "") || values.exists(.startsWith(value)) - } + abstract class PermissibleValue { + val values: List[String] + def isPermissible(value: String): Boolean = + (value == "") || values.exists(.startsWith(value)) + } - /** Defines valid values for the platforms property. */ - object Platforms extends PermissibleValue { - val values = List("unix", "windows") - } + /** Defines valid values for the platforms property. */ + object Platforms extends PermissibleValue { + val values = List("unix", "windows") + } + + /** The path to the exec script file. ".bat" will be appended for the + * Windows BAT file, if generated. + */ + private var file: Option[File] = None + + /** The main class to run. */ + private var mainClass: Option[String] = None + + /** The name of this tool. Can only be set when a main class is defined, + * default this is equal to the file name. + */ + private var name: Option[String] = None + + /** Supported platforms for the script. Either "unix" or "windows". + * Defaults to both. + */ + private var platforms: List[String] = Nil + + /** The optional version number. If set, when "-version" is passed to the + * script, this value will be printed. + */ + 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. + */ + private var extclasspath: List[String] = Nil + + /** Comma-separated Java system properties to pass to the JRE. Properties + * are formated as name=value. Properties scala.home, scala.tool.name and + * scala.tool.version are always set. + */ + private var properties: List[Pair[String,String]] = Nil - /** The path to the exec script file. ".bat" will be appended for the - * Windows BAT file, if generated. */ - private var file: Option[File] = None - /** The main class to run. */ - private var mainClass: Option[String] = None - /** The name of this tool. Can only be set when a main class is defined, - * default this is equal to the file name. */ - private var name: Option[String] = None - /** Supported platforms for the script. Either "unix" or "windows". Defaults - * to both. */ - private var platforms: List[String] = Nil - /** The optional version number. If set, when "-version" is passed to the - * script, this value will be printed. */ - 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. */ - private var extclasspath: List[String] = Nil - /** Comma-separated Java system properties to pass to the JRE. Properties - * are formated as name=value. Properties scala.home, scala.tool.name and - * scala.tool.version are always set. */ - private var properties: List[Pair[String,String]] = Nil - /** Additional flags passed to the JRE ("java [javaFlags] class"). */ - private var javaFlags: String = "" - /** Additional flags passed to the tool ("java class [toolFlags]"). Can only - * be set when a main class is defined */ - private var toolFlags: String = "" + /** Additional flags passed to the JRE ("java [javaFlags] class"). */ + private var javaFlags: String = "" + + /** Additional flags passed to the tool ("java class [toolFlags]"). Can only + * be set when a main class is defined. + */ + private var toolFlags: String = "" /*============================================================================*\ ** Properties setters ** \*============================================================================*/ - /** Sets the file attribute. - * Used by Ant. - * - * @param input The value of file. - */ - def setFile(input: File) = - file = Some(input) - - /** Sets the file attribute. - * Used by Ant. - * - * @param input The value of file. - */ - def setName(input: String) = - name = Some(input) - - /** Sets the main class attribute. - * Used by Ant. - * - * @param input The value of mainClass. - */ - def setClass(input: String) = - mainClass = Some(input) - - /** Sets the platforms attribute. Used by Ant. - * @param input The value for platforms. */ - def setPlatforms(input: String) = { - platforms = List.fromArray(input.split(",")).flatMap { s: String => - val st = s.trim() - if (Platforms.isPermissible(st)) - (if (input != "") List(st) else Nil) - else { - error("Platform " + st + " does not exist.") - Nil - } + /** Sets the file attribute. + * Used by Ant. + * + * @param input The value of file. + */ + def setFile(input: File) = + file = Some(input) + + /** Sets the file attribute. + * Used by Ant. + * + * @param input The value of file. + */ + def setName(input: String) = + name = Some(input) + + /** Sets the main class attribute. + * Used by Ant. + * + * @param input The value of mainClass. + */ + def setClass(input: String) = + mainClass = Some(input) + + /** Sets the platforms attribute. Used by Ant. + * + * @param input The value for platforms. + */ + def setPlatforms(input: String) = { + platforms = List.fromArray(input.split(",")).flatMap { s: String => + val st = s.trim() + if (Platforms.isPermissible(st)) + (if (input != "") List(st) else Nil) + else { + error("Platform " + st + " does not exist.") + Nil } } + } - /** Sets the version attribute. - * Used by Ant. - * - * @param input The value of version. - */ - def setVersion(input: String) = - version = input - - /** Sets the copyright attribute. - * Used by Ant. - * - * @param input The value of copyright. - */ - def setCopyright(input: String) = - copyright = input - - /** Sets the boot classpath attribute. - * Used by Ant. - * - * @param input The value of bootclasspath. - */ - def setBootclasspath(input: String) = - bootclasspath = bootclasspath ::: List.fromArray(input.split(":")) - - /** Sets the extension classpath attribute. - * Used by Ant. - * - * @param input The value of extclasspath. - */ - def setExtclasspath(input: String) = - extclasspath = extclasspath ::: List.fromArray(input.split(":")) - - /** Sets the properties attribute. - * Used by Ant. - * - * @param input The value for properties. - */ - def setProperties(input: String) = { - properties = List.fromArray(input.split(",")).flatMap { s: String => - val st = s.trim(); val stArray = st.split("=", 2) - if (stArray.length == 2) { - if (input != "") List(Pair(stArray(0), stArray(1))) else Nil - } else error("Property " + st + " does not conform to specification.") - } + /** Sets the version attribute. + * Used by Ant. + * + * @param input The value of version. + */ + def setVersion(input: String) = + version = input + + /** Sets the copyright attribute. + * Used by Ant. + * + * @param input The value of copyright. + */ + def setCopyright(input: String) = + copyright = input + + /** Sets the boot classpath attribute. + * Used by Ant. + * + * @param input The value of bootclasspath. + */ + def setBootclasspath(input: String) = + bootclasspath = bootclasspath ::: List.fromArray(input.split(":")) + + /** Sets the extension classpath attribute. + * Used by Ant. + * + * @param input The value of extclasspath. + */ + def setExtclasspath(input: String) = + extclasspath = extclasspath ::: List.fromArray(input.split(":")) + + /** Sets the properties attribute. + * Used by Ant. + * + * @param input The value for properties. + */ + def setProperties(input: String) = { + properties = List.fromArray(input.split(",")).flatMap { s: String => + val st = s.trim(); val stArray = st.split("=", 2) + if (stArray.length == 2) { + if (input != "") List(Pair(stArray(0), stArray(1))) else Nil + } else error("Property " + st + " does not conform to specification.") } + } - /** Sets the version attribute. - * Used by Ant. - * - * @param input The value of version. - */ - def setJavaflags(input: String) = - javaFlags = input - - /** Sets the version attribute. - * Used by Ant. - * - * @param input The value of version. - */ - def setToolflags(input: String) = - toolFlags = input + /** Sets the version attribute. + * Used by Ant. + * + * @param input The value of version. + */ + def setJavaflags(input: String) = + javaFlags = input + + /** Sets the version attribute. + * Used by Ant. + * + * @param input The value of version. + */ + def setToolflags(input: String) = + toolFlags = input /*============================================================================*\ ** Properties getters ** @@ -327,24 +340,22 @@ package scala.tools.ant { ** The big execute method ** \*============================================================================*/ - /** Performs the compilation. */ - override def execute() = { - // Tests if all mandatory attributes are set and valid. - if (file.isEmpty) error("Attribute 'file' is not set.") - if (mainClass.isEmpty) error("Main class must be set.") - if (platforms.isEmpty) platforms = Platforms.values - if (name.isEmpty) name = Some(file.get.getName) - val patches = ListMap.empty. - update("name", name.get). - update("class", mainClass.get). - update("version", version). - update("copyright", copyright). - update("properties", getProperties). - update("javaflags", javaFlags). - update("toolflags", toolFlags) - pipeTemplate("tool", patches) - } - + /** Performs the compilation. */ + override def execute() = { + // Tests if all mandatory attributes are set and valid. + if (file.isEmpty) error("Attribute 'file' is not set.") + if (mainClass.isEmpty) error("Main class must be set.") + if (platforms.isEmpty) platforms = Platforms.values + if (name.isEmpty) name = Some(file.get.getName) + val patches = ListMap.empty. + update("name", name.get). + update("class", mainClass.get). + update("version", version). + update("copyright", copyright). + update("properties", getProperties). + update("javaflags", javaFlags). + update("toolflags", toolFlags) + pipeTemplate("tool", patches) } } diff --git a/src/compiler/scala/tools/ant/Scalac.scala b/src/compiler/scala/tools/ant/Scalac.scala index 7664c2c785..39d4f5e167 100644 --- a/src/compiler/scala/tools/ant/Scalac.scala +++ b/src/compiler/scala/tools/ant/Scalac.scala @@ -1,9 +1,10 @@ -/* __ ______________ *\ -** / |/ / ____/ ____/ ** -** / | | /___ / /___ ** -** /_/|__/_____/_____/ Copyright 2005-2007 LAMP/EPFL ** -** ** -\* */ +/* __ *\ +** ________ ___ / / ___ Scala Ant Tasks ** +** / __/ __// _ | / / / _ | (c) 2005-2007, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ // $Id$ diff --git a/src/compiler/scala/tools/ant/Scaladoc.scala b/src/compiler/scala/tools/ant/Scaladoc.scala index 7f0edeb2f8..67d36d1180 100644 --- a/src/compiler/scala/tools/ant/Scaladoc.scala +++ b/src/compiler/scala/tools/ant/Scaladoc.scala @@ -1,9 +1,10 @@ -/* __ ______________ *\ -** / |/ / ____/ ____/ ** -** / | | /___ / /___ ** -** /_/|__/_____/_____/ Copyright 2005-2007 LAMP/EPFL ** -** ** -\* */ +/* __ *\ +** ________ ___ / / ___ Scala Ant Tasks ** +** / __/ __// _ | / / / _ | (c) 2005-2007, LAMP/EPFL ** +** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** +** /____/\___/_/ |_/____/_/ | | ** +** |/ ** +\* */ // $Id$ diff --git a/src/compiler/scala/tools/ant/templates/tool-unix.tmpl b/src/compiler/scala/tools/ant/templates/tool-unix.tmpl index 8c7dbbd5c6..2233056bb3 100644 --- a/src/compiler/scala/tools/ant/templates/tool-unix.tmpl +++ b/src/compiler/scala/tools/ant/templates/tool-unix.tmpl @@ -70,4 +70,4 @@ if $cygwin; then BOOT_CLASSPATH=`cygpath --path --$format "$BOOT_CLASSPATH"` fi -${JAVACMD:=java} @javaflags@ -Xbootclasspath/a:"$BOOT_CLASSPATH" -cp "$EXTENSION_CLASSPATH" -Dscala.home="$SCALA_HOME" -Denv.classpath="$CLASSPATH" @properties@ @class@ @toolflags@ "$@@" +${JAVACMD:=java} ${JAVA_OPTS:=@javaflags@} -Xbootclasspath/a:"$BOOT_CLASSPATH" -cp "$EXTENSION_CLASSPATH" -Dscala.home="$SCALA_HOME" -Denv.classpath="$CLASSPATH" @properties@ @class@ @toolflags@ "$@@" -- cgit v1.2.3