Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can a Scala compiler option be appended to scalacOptions in sbt?

Tags:

scala

sbt

I use sbt 0.10.

I have the following setting in .sbt file:

scalacOptions += "-usejavacp"

The problem is that when the Scala compiler get executed and the scalacOptions is set:

[debug] Calling Scala compiler with arguments  (CompilerInterface):
[debug]         -usejavacp
[debug]         -d
[debug]         D:\project\target\scala-2.8.1.final\classes
[debug]         -bootclasspath
...

the -usejavacp parameter appears before the actual Scala jars that results in this error:

scala.collection.mutable.ListBuffer does not take type parameters

Is there a way the parameter is appended and not prepended? I also tried the ++= Array("-usejavacp") but the result is the same.

like image 630
Senthess Avatar asked Jun 29 '11 13:06

Senthess


2 Answers

If you look here, you'll see the following comment:

key += value is equivalent to key ~= (_ :+ value) or key <<= key(_ :+ value)

Which, curiously enough, seems to contradict the order you are seeing. I think this is worth opening an issue about, and, meanwhile, you can play with the full syntax to see if you can accomplish what you need.

like image 115
Daniel C. Sobral Avatar answered Oct 30 '22 11:10

Daniel C. Sobral


To directly answer your question, the list of custom scalac options, provided by the scalacOptions setting, are prepended to the options for controlling the classpath, output directory, and source files.

Presumably you are using -usejavacp to use the Scala compiler or interpreter programmatically. There is an entry for this in the SBT FAQ.

like image 32
retronym Avatar answered Oct 30 '22 11:10

retronym