diff --git a/build.xml b/build.xml index c76ff7b32..3f38ec258 100644 --- a/build.xml +++ b/build.xml @@ -755,7 +755,8 @@ MSIL + assemname="${msil.dir}/predef" assemrefs="${lib.dir}" + failonerror="false"> diff --git a/src/compiler/scala/tools/ant/Scalac.scala b/src/compiler/scala/tools/ant/Scalac.scala index 26bbdba65..6fee3e196 100644 --- a/src/compiler/scala/tools/ant/Scalac.scala +++ b/src/compiler/scala/tools/ant/Scalac.scala @@ -49,7 +49,8 @@ import scala.tools.nsc.reporters.{Reporter, ConsoleReporter} *
  • addparams,
  • *
  • scalacdebugging,
  • *
  • deprecation,
  • - *
  • unchecked.
  • + *
  • unchecked,
  • + *
  • failonerror.
  • * *

    * It also takes the following parameters as nested elements: @@ -61,7 +62,9 @@ import scala.tools.nsc.reporters.{Reporter, ConsoleReporter} *

  • bootclasspath,
  • *
  • extdirs.
  • * - * @author Gilles Dubochet, Stephane Micheloud */ + * + * @author Gilles Dubochet, Stephane Micheloud + */ class Scalac extends MatchingTask { /** The unique Ant file utilities instance to use in this task. */ @@ -139,6 +142,8 @@ class Scalac extends MatchingTask { private var deprecation: Option[Boolean] = None /** Instruct the compiler to generate unchecked information. */ private var unchecked: Option[Boolean] = None + /** Indicates whether compilation errors will fail the build; defaults to true. */ + private var failonerror: Boolean = true // Name of the output assembly (only relevant with -target:msil) private var assemname: Option[String] = None @@ -157,9 +162,10 @@ class Scalac extends MatchingTask { /** Sets the srcdir attribute. Used by Ant. * @param input The value of origin. */ - def setSrcdir(input: Path) = + def setSrcdir(input: Path) { if (origin.isEmpty) origin = Some(input) else origin.get.append(input) + } /** Sets the origin as a nested src Ant parameter. * @return An origin path to be configured. */ @@ -175,14 +181,14 @@ class Scalac extends MatchingTask { /** Sets the destdir attribute. Used by Ant. * @param input The value of destination. */ - def setDestdir(input: File) = - destination = Some(input) + def setDestdir(input: File) { destination = Some(input) } /** Sets the classpath attribute. Used by Ant. * @param input The value of classpath. */ - def setClasspath(input: Path) = + def setClasspath(input: Path) { if (classpath.isEmpty) classpath = Some(input) else classpath.get.append(input) + } /** Sets the classpath as a nested classpath Ant parameter. * @return A class path to be configured. */ @@ -193,14 +199,16 @@ class Scalac extends MatchingTask { /** Sets the classpath as an external reference Ant parameter. * @param input A reference to a class path. */ - def setClasspathref(input: Reference) = + def setClasspathref(input: Reference) { createClasspath().setRefid(input) + } /** Sets the sourcepath attribute. Used by Ant. * @param input The value of sourcepath. */ - def setSourcepath(input: Path) = + def setSourcepath(input: Path) { if (sourcepath.isEmpty) sourcepath = Some(input) else sourcepath.get.append(input) + } /** Sets the sourcepath as a nested sourcepath Ant parameter. * @return A source path to be configured. */ @@ -211,15 +219,17 @@ class Scalac extends MatchingTask { /** Sets the sourcepath as an external reference Ant parameter. * @param input A reference to a source path. */ - def setSourcepathref(input: Reference) = + def setSourcepathref(input: Reference) { createSourcepath().setRefid(input) + } /** Sets the boot classpath attribute. Used by Ant. * * @param input The value of bootclasspath. */ - def setBootclasspath(input: Path) = + def setBootclasspath(input: Path) { if (bootclasspath.isEmpty) bootclasspath = Some(input) else bootclasspath.get.append(input) + } /** Sets the bootclasspath as a nested sourcepath Ant * parameter. @@ -266,18 +276,18 @@ class Scalac extends MatchingTask { /** Sets the force attribute. Used by Ant. * @param input The value for force. */ - def setForce(input: Boolean): Unit = - force = input + def setForce(input: Boolean) { force = input } /** Sets the logging level attribute. Used by Ant. * @param input The value for logging. */ - def setLogging(input: String) = + def setLogging(input: String) { if (LoggingLevel.isPermissible(input)) logging = Some(input) else error("Logging level '" + input + "' does not exist.") + } /** Sets the logphase attribute. Used by Ant. * @param input The value for logPhase. */ - def setLogPhase(input: String) = { + def setLogPhase(input: String) { logPhase = List.fromArray(input.split(",")).flatMap { s: String => val st = s.trim() if (CompilerPhase.isPermissible(st)) @@ -291,48 +301,47 @@ class Scalac extends MatchingTask { /** Sets the usepredefs attribute. Used by Ant. * @param input The value for usepredefs. */ - def setUsepredefs(input: Boolean): Unit = - usepredefs = Some(input) + def setUsepredefs(input: Boolean) { usepredefs = Some(input) } /** Set the debug info attribute. * @param input The value for debug. */ - def setDebuginfo(input: String): Unit = - debugInfo = Some(input) + def setDebuginfo(input: String) { debugInfo = Some(input) } /** Set the addparams info attribute. * @param input The value for addparams. */ - def setAddparams(input: String): Unit = - addParams = input + def setAddparams(input: String) { addParams = input } /** Set the deprecation info attribute. * @param input One of the flags yes/no or on/off. */ - def setDeprecation(input: String): Unit = + def setDeprecation(input: String) { if (Flag.isPermissible(input)) deprecation = Some("yes" == input || "on" == input) else error("Unknown deprecation flag '" + input + "'") + } /** Set the unchecked info attribute. * @param input One of the flags yes/no or on/off. */ - def setUnchecked(input: String): Unit = + def setUnchecked(input: String) { if (Flag.isPermissible(input)) unchecked = Some("yes" == input || "on" == input) else error("Unknown unchecked flag '" + input + "'") + } + + /** Sets the force attribute. Used by Ant. + * @param input The value for force. */ + def setFailonerror(input: Boolean) { failonerror = input } /** Set the scalacdebugging info attribute. * @param input The specified flag */ - def setScalacdebugging(input: Boolean): Unit = - scalacDebugging = input + def setScalacdebugging(input: Boolean) { scalacDebugging = input } - def setAssemname(input: String): Unit = - assemname = Some(input) + def setAssemname(input: String) { assemname = Some(input) } - def setAssemrefs(input: String): Unit = - assemrefs = Some(input) + def setAssemrefs(input: String) { assemrefs = Some(input) } - def setGenerics(input: Boolean): Unit = - generics = Some(input) + def setGenerics(input: Boolean) { generics = Some(input) } /*============================================================================*\ ** Properties getters ** @@ -452,7 +461,7 @@ class Scalac extends MatchingTask { \*============================================================================*/ /** Initializes settings and source files */ - protected def initialize: Pair[Settings, List[File]] = { + protected def initialize: (Settings, List[File]) = { // Tests if all mandatory attributes are set and valid. if (origin.isEmpty) error("Attribute 'srcdir' is not set.") if (getOrigin.isEmpty) error("Attribute 'srcdir' is not set.") @@ -549,12 +558,12 @@ class Scalac extends MatchingTask { if (argsBuf eq args) error("Parameter '" + args.head + "' is not recognised by Scalac.") } - Pair(settings, sourceFiles) + (settings, sourceFiles) } /** Performs the compilation. */ override def execute() = { - val Pair(settings, sourceFiles) = initialize + val (settings, sourceFiles) = initialize val reporter = new ConsoleReporter(settings) // Compiles the actual code @@ -573,12 +582,14 @@ class Scalac extends MatchingTask { "(no error message provided); see the error output for details.") } reporter.printSummary() - if (reporter.hasErrors) - error( - "Compile failed with " + - reporter.ERROR.count + " error" + - (if (reporter.ERROR.count > 1) "s" else "") + - "; see the compiler error output for details.") + if (reporter.hasErrors) { + val msg = + "Compile failed with " + + reporter.ERROR.count + " error" + + (if (reporter.ERROR.count > 1) "s" else "") + + "; see the compiler error output for details." + if (failonerror) error(msg) else log(msg) + } else if (reporter.WARNING.count > 0) log( "Compile suceeded with " +