Permalink
Browse files

Append dummy argument to `-classpath` when it is actually empty.

Scala compiler's way of handling empty classpath argument is problematic.
This workaround appends a dummy classpath argument when the classpath is
actually empty. Fixes #269 (also see #82, #85).
  • Loading branch information...
indrajitr committed Nov 19, 2011
1 parent a336ab2 commit f46fa3804e6d0d0bc23a9e88f300948d225ebcd6
@@ -18,7 +18,10 @@ final class CompilerArguments(scalaInstance: ScalaInstance, cp: ClasspathOptions
{
checkScalaHomeUnset()
val cpWithCompiler = finishClasspath(classpath)
- val classpathOption = Seq("-classpath", if(cpWithCompiler.isEmpty) "" else absString(cpWithCompiler) )
+ // Scala compiler's treatment of empty classpath is troublesome (as of 2.9.1).
+ // We append a random dummy element as workaround.
+ val dummy = "dummy_" + Integer.toHexString(util.Random.nextInt)
+ val classpathOption = Seq("-classpath", if(cpWithCompiler.isEmpty) dummy else absString(cpWithCompiler))
val outputOption = Seq("-d", outputDirectory.getAbsolutePath)
options ++ outputOption ++ bootClasspathOption ++ classpathOption ++ abs(sources)
}
@@ -55,4 +58,4 @@ object CompilerArguments
def abs(files: Set[File]): Seq[String] = abs(files.toSeq)
def absString(files: Seq[File]): String = abs(files).mkString(File.pathSeparator)
def absString(files: Set[File]): String = absString(files.toSeq)
-}
+}
@@ -0,0 +1,5 @@
+package pkg
+
+package object foo {
+ final val foo = "Foo"
+}
@@ -2,6 +2,8 @@
-> doc
-> 'set sources in (Compile, doc) <<= sources in Compile map { _.filter(_.getName contains "A") }'
+> 'set sources in (Compile, doc) <<= sources in Compile map { _.filterNot(_.getName contains "B") }'
-> doc
+# compile task is superfluous. Since doc task preceded by compile task has been problematic due to scala
+# compiler's way of handling empty classpath. We have it here to test that our workaround works.
+> ; clean ; compile ; doc

0 comments on commit f46fa38

Please sign in to comment.