为什么sbt总是告诉我在Scala选项中添加-deprecation,而它';已经有了吗?
以下是我的多项目结构:为什么sbt总是告诉我在Scala选项中添加-deprecation,而它';已经有了吗?,scala,sbt,Scala,Sbt,以下是我的多项目结构: myApp + build.sbt + sub-prj-1 + build.sbt + sub-prj-2 + build.sbt + project + Build.scala 我通常在project/Build.scala中定义公共设置,如下所示: import sbt._ import Keys._ object ApplicationBuild extends Build { val defaultSc
myApp
+ build.sbt
+ sub-prj-1
+ build.sbt
+ sub-prj-2
+ build.sbt
+ project
+ Build.scala
我通常在project/Build.scala
中定义公共设置,如下所示:
import sbt._
import Keys._
object ApplicationBuild extends Build {
val defaultScalacOptions = Seq(
"-unchecked", "-deprecation", "-feature", "-language:reflectiveCalls", "-language:implicitConversions",
"-language:postfixOps", "-language:dynamics", "-language:higherKinds", "-language:existentials",
"-language:experimental.macros", "-encoding", "UTF-8", "-Xmax-classfile-name", "140")
val defaultResolvers = Seq(
"Typesafe releases repository" at "http://repo.typesafe.com/typesafe/releases/"
)
val defaultSettings = Defaults.defaultSettings ++ Seq(
scalaVersion := "2.10.4",
scalacOptions ++= defaultScalacOptions,
resolvers ++= defaultResolvers
)
}
。。。然后我在每个build.sbt
文件中引用这些常用设置:
name := "myapp"
organization := "Test, Inc."
version := "1.0"
ApplicationBuild.defaultSettings // it looks like common settings defined in
// project/Build.scala are not read...
scalacOptions += "-feature" // already defined in ApplicationBuild.defaultSettings...
// but if I don't define it here, it doesn't work
lazy val `sub-prj-1` = project.in(file("sub-prj-1"))
lazy val `sub-prj-2` = project.in(file("sub-prj-2"))
lazy val brix = project.in(file(".")).settings(
publishArtifact := false
).aggregate(
`sub-prj-1`,
`sub-prj-2`
)
例如,scalacOptions+=“-feature”
已在Build.scala
中定义。。。但是如果我没有在build.sbt
中定义它,我总是会得到以下警告:
[warn] there were 1 deprecation warning(s); re-run with -deprecation for details
[warn] one warning found
有什么想法吗?我错过什么了吗?这个问题在我安装sbt 0.13.5之后首次出现
编辑
以下是scalacOptions
的内容:
[info] sub-prj-1/*:scalacOptions
[info] List(-unchecked, -deprecation, -feature, -language:reflectiveCalls, -language:implicitConversions, -language:postfixOps, -language:dynamics, -language:higherKinds, -language:existentials, -language:experimental.macros, -encoding, UTF-8, -Xmax-classfile-name, 140)
[info] sub-prj-2/*:scalacOptions
[info] List(-unchecked, -deprecation, -feature, -language:reflectiveCalls, -language:implicitConversions, -language:postfixOps, -language:dynamics, -language:higherKinds, -language:existentials, -language:experimental.macros, -encoding, UTF-8, -Xmax-classfile-name, 140)
[info] myapp/*:scalacOptions
[info] List(-unchecked, -deprecation, -feature, -language:reflectiveCalls, -language:implicitConversions, -language:postfixOps, -language:dynamics, -language:higherKinds, -language:existentials, -language:experimental.macros, -encoding, UTF-8, -Xmax-classfile-name, 140)
我只能猜测(并指望在出错时更正其他信息),但是警告
消息来自构建项目(在项目
下),而不是您的
我使用的是sbt 0.13.6-SNAPSHOT(今天从源代码构建),因此您的里程数可能会有所不同
➜ myApp xsbt
[info] Loading global plugins from /Users/jacek/.sbt/0.13/plugins
[info] Loading project definition from /Users/jacek/sandbox/common-settings/myApp/project
[info] Updating {file:/Users/jacek/sandbox/common-settings/myApp/project/}myapp-build...
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[info] Done updating.
[info] Compiling 1 Scala source to /Users/jacek/sandbox/common-settings/myApp/project/target/scala-2.10/sbt-0.13/classes...
[warn] there were 1 deprecation warning(s); re-run with -deprecation for details
[warn] one warning found
[info] Set current project to brix (in build file:/Users/jacek/sandbox/common-settings/myApp/)
当我试图重现您的案例时,我得到了项目下生成定义的消息:
[warn] there were 1 deprecation warning(s); re-run with -deprecation for details
[warn] one warning found
它们是你想要摆脱的吗?如果是,请继续阅读。否则,请在问题中添加其他信息。谢谢
例如,project
下面是另一个构建定义(依此类推)
为了消除这些消息,您应该按照他们的建议,将-deprecation
添加到相应项目的构建定义中。将以下内容添加到项目/build.sbt:
scalacOptions += "-deprecation"
这样,重新加载
,谜团就被揭开了
➜ myApp xsbt
[info] Loading global plugins from /Users/jacek/.sbt/0.13/plugins
[info] Loading project definition from /Users/jacek/sandbox/common-settings/myApp/project
[info] Compiling 1 Scala source to /Users/jacek/sandbox/common-settings/myApp/project/target/scala-2.10/sbt-0.13/classes...
[warn] /Users/jacek/sandbox/common-settings/myApp/project/Build.scala:15: value defaultSettings in object Defaults is deprecated: 0.13.2
[warn] val defaultSettings = Defaults.defaultSettings ++ Seq(
[warn] ^
[warn] one warning found
[info] Set current project to brix (in build file:/Users/jacek/sandbox/common-settings/myApp/)
>
:
要解决这个问题,你应该阅读这篇文章。你能在sbt控制台中显示Scala选项
并将输出添加到问题中吗?刚好在我回答的时候:)我想我可能帮了忙。非常感谢你详尽的回答;-)
@deprecated("0.13.2", "Default settings split into `coreDefaultSettings` and IvyModule/JvmModule plugins.")