scalaantscala-2.9fsc

Is there a workaround for Scala 2.9.1's buggy fsc Ant task?


The fsc Ant task provided with Scala 2.9.1 is buggy (issues SI-5174 and SI-5196): if the compile fails, everything proceeds as normal. If the compile succeeds, on the other hand, then an internal compilation error is reported—even though everything was compiled directly. One can, of course, run the task and ignore the error, but it's annoying and becomes more difficult to see when things are correct or not. This is clearly a known bug, but what I'm wondering is if there are any known workarounds: ways to still use fsc with Scala 2.9 to get the (significant) speed boost that it provides, but not see an error (even if the error still happens behind the scenes). I know that this has been fixed in Scala 2.10, but I'd rather not install that; it's not yet a stable release, and my collaborator and I already have Scala 2.9 installed.


Additional information that might be applicable:

The error that's reported is

[fsc] /.../build.xml:48: Compile failed; see the compiler error output for details.
[fsc]   at scala.tools.ant.ScalaTask$class.buildError(ScalaMatchingTask.scala:27)
[fsc]   at scala.tools.ant.ScalaMatchingTask.buildError(ScalaMatchingTask.scala:30)
[fsc]   at scala.tools.ant.FastScalac.execute(FastScalac.scala:107)
[fsc]   at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:291)
[fsc]   at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
[fsc]   at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
[fsc]   at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
[fsc]   at java.lang.reflect.Method.invoke(Method.java:597)
[fsc]   at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
[fsc]   at org.apache.tools.ant.Task.perform(Task.java:348)
[fsc]   at org.apache.tools.ant.Target.execute(Target.java:390)
[fsc]   at org.apache.tools.ant.Target.performTasks(Target.java:411)
[fsc]   at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1399)
[fsc]   at org.apache.tools.ant.Project.executeTarget(Project.java:1368)
[fsc]   at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
[fsc]   at org.apache.tools.ant.Project.executeTargets(Project.java:1251)
[fsc]   at org.apache.tools.ant.Main.runBuild(Main.java:809)
[fsc]   at org.apache.tools.ant.Main.startAnt(Main.java:217)
[fsc]   at org.apache.tools.ant.launch.Launcher.run(Launcher.java:280)
[fsc]   at org.apache.tools.ant.launch.Launcher.main(Launcher.java:109)

The relevant portions of the build.xml file are:

<target name="init">
  ...
  <taskdef resource="scala/tools/ant/antlib.xml">
    <classpath>
      <pathelement location="${scala-compiler.jar}" />
      <pathelement location="${scala-library.jar}" />
    </classpath>
  </taskdef>
</target>

...

<target name="compile" depends="init">
  <mkdir dir="${classes.dir}" />
  <fsc srcdir="${source.dir}"
       destdir="${classes.dir}"
       classpathref="build.classpath"
       deprecation="yes"
       unchecked="yes" />
</target>

Solution

  • To be blunt, no, or at least none that I've managed to find. We ended up moving to Maven (tried SBT but it was too buggy).