2014-06-18 16 views
7

Ho un po 'di problemi a cercare di capire come impostare/aggiungere a scalacOptions utilizzato da SBT quando si compila Build.scala. Qualcuno nella mia squadra ha copiato un po 'di codice da Akka Build.scala e il risultato è stato un po' di avvertimenti obsoleti e un avviso di funzionalità.Come impostare le scalacOptions utilizzate da SBT durante la compilazione di Build.scala?

$ 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 

Le cose che ho provato

  1. Aggiungi scalacOptions ++= Seq("-unchecked", "-feature")-build.sbt. Speravo che questo sarebbe stato caricato prima della compilazione di Build.scala.
  2. già avuto scalacOptions ++= Seq(...., "-unchecked", "-feature") in Build.scala
  3. Tentativo di impostare scalacOptions prima reload ma sembra essere scartata

    $ ;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. 
    

Attraverso tanto sudore di sangue sono stato in grado di trovare la causa delle avvertenze deprecato , ma non riesco a trovare la causa dell'avviso di funzionalità.

risposta

7

Sbt is recursive, il che significa che la directory Build.scala in project è costruire da un'altra definizione nella sua directory genitore o build.sbt nella directory project.

Pertanto è necessario creare build.sbt nella directory project. Nel project/build.sbt dovresti essere in grado di impostare scalacOptions ++= Seq("-unchecked", "-feature").

+0

Ho avuto 'build.sbt' nel posto sbagliato. Questo ha funzionato quando ho spostato 'build.sbt' dalla directory root a' project/build.sbt' – drstevens

+1

@drstevens hai ragione, dovrebbe essere in 'project/build.sbt', ho aggiornato la mia risposta. Se si volesse creare 'Build.scala', si dovrebbe crearne uno in' project/project/Build.scala'. – lpiepiora

Problemi correlati