Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set scalacOptions used by SBT when compiling Build.scala?

Tags:

scala

sbt

I'm having a bit of trouble trying to figure out how to set/append to scalacOptions used by SBT when compiling Build.scala. Someone on my team copied a bit of code from Akka's Build.scala and the result was a bunch of deprecated warnings and a feature warning.

$ reload
[info] Loading global plugins from /Users/xxx/.sbt/0.13/plugins
[info] Loading project definition from /Users/xxx/yyy/zzz/project
[info] Compiling 1 Scala source to /Users/xxx/yyy/zzz/project/target/scala-2.10/sbt-0.13/classes...
[warn] there were 3 deprecation warning(s); re-run with -deprecation for details
[warn] there were 1 feature warning(s); re-run with -feature for details
[warn] two warnings found

Things I have tried

  1. Add scalacOptions ++= Seq("-unchecked", "-feature") to build.sbt. I was hoping this would get loaded before Build.scala was compiled.
  2. Already had scalacOptions ++= Seq(...., "-unchecked", "-feature") in Build.scala
  3. Attempt to set scalacOptions prior to reload but it appears to be discarded

    $ ;set scalacOptions ++= Seq("-feature", "-deprecated") ;reload
    [info] Defining zzz/*:scalacOptions
    [info] The new value will be used by zzz/compile:scalacOptions
    [info] Reapplying settings...
    [info] Set current project to zzz (in build file:/Users/xxx/yyy/zzz/)
    [info] Loading global plugins from /Users/xxx/.sbt/0.13/plugins
    [info] Loading project definition from /Users/xxx/yyy/zzz/project
    [info] Compiling 1 Scala source to /Users/xxx/yyy/zzz/project/target/scala-2.10/sbt-0.13/classes...
    [warn] there were 3 deprecation warning(s); re-run with -deprecation for details
    [warn] there were 1 feature warning(s); re-run with -feature for details
    [warn] two warnings found
    [warn] Discarding 1 session setting.  Use 'session save' to persist session settings.
    

Through much blood sweat I was able to find the cause of the deprecated warnings, but I can't find the cause of the feature warning.

like image 841
drstevens Avatar asked Jun 18 '14 15:06

drstevens


1 Answers

Sbt is recursive, which means the Build.scala in project directory is build by another definition in its parent directory or build.sbt in the project directory.

Therefore you have to create build.sbt in project directory. In the project/build.sbt you should be able to set scalacOptions ++= Seq("-unchecked", "-feature").

like image 186
lpiepiora Avatar answered Sep 19 '22 15:09

lpiepiora