2014-06-18 15 views
7

Tôi đang gặp một chút khó khăn khi cố tìm ra cách đặt/nối thêm scalacOptions được SBT sử dụng khi biên dịch Build.scala. Ai đó trong nhóm của tôi đã sao chép một đoạn mã từ số Build.scala của Akka và kết quả là một loạt cảnh báo không được chấp nhận và cảnh báo tính năng.Làm thế nào để thiết lập scalacOptions được sử dụng bởi SBT khi biên dịch 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 

Những điều tôi đã cố gắng

  1. Thêm scalacOptions ++= Seq("-unchecked", "-feature")-build.sbt. Tôi đã hy vọng điều này sẽ được tải trước khi Build.scala được biên soạn.
  2. Đã có scalacOptions ++= Seq(...., "-unchecked", "-feature") trong Build.scala
  3. Cố gắng để thiết lập scalacOptions trước reload nhưng nó dường như bị loại bỏ

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

Qua mồ hôi máu nhiều tôi đã có thể tìm ra nguyên nhân của những lời cảnh báo bị phản đối , nhưng tôi không thể tìm thấy nguyên nhân của cảnh báo tính năng.

Trả lời

7

Sbt is recursive, có nghĩa là Build.scala trong thư mục project được tạo bằng một định nghĩa khác trong thư mục chính hoặc build.sbt trong thư mục project.

Vì vậy, bạn phải tạo build.sbt trong thư mục project. Trong project/build.sbt bạn sẽ có thể đặt scalacOptions ++= Seq("-unchecked", "-feature").

+0

Tôi đã có 'build.sbt' ở sai vị trí. Điều này làm việc khi tôi di chuyển 'build.sbt' từ thư mục gốc sang' project/build.sbt' – drstevens

+1

@drstevens bạn nói đúng, nó phải nằm trong 'project/build.sbt', tôi đã cập nhật câu trả lời của mình. Nếu bạn muốn tạo 'Build.scala', bạn sẽ tạo một trong' project/project/Build.scala'. – lpiepiora

Các vấn đề liên quan