mirror of https://github.com/sbt/sbt.git
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).
This commit is contained in:
parent
0270ac078f
commit
c039925748
|
|
@ -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"
|
||||
}
|
||||
|
|
@ -13,7 +13,9 @@ $ exists "target/api/java"
|
|||
|
||||
> 'set sources in (Compile, doc) <<= sources in (Compile, doc) map { _.filterNot(_.getName endsWith ".java") }'
|
||||
|
||||
> ; clean ; 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
|
||||
|
||||
# pure scala project, only scaladoc at top level
|
||||
$ exists "target/api/index.js"
|
||||
|
|
|
|||
Loading…
Reference in New Issue