I'm currently working on a Scala project, that is using SBT, and I'm trying to produce production build settings in which one of the conditions are all asserts are turned off. I simply added the line, to my build.sbt:

scalacOptions ++= Seq(..., "-Xdisable-assertions")

I'm running the logLevel at debug and I see the options being passed to the compiler, but when I run our program(its long running program analysis), I encounter an assert. Though by all signs all asserts should be compiled away. I've tried this with both diable-assertions, and elide-below, without results. If anyone could give me some pointers on what I'm doing wrong, that would be great. I've written a lot of Scala, but haven't used SBT much beyond some basic projects.

有帮助吗?

解决方案

Do you run "reload" in sbt after editing build.sbt? Because I tried building a small project, and all assertions are happily compiled away. For the record, I'm using sbt 0.12.0.


Here is the sample project I used:

btest/
├── [  86]  build.sbt
└── [  45]  Main.scala

build.sbt:

scalacOptions ++= Seq("-deprecation", "-unchecked", "-Xlint", "-Xdisable-assertions")

Main.scala:

object Main extends App {
  assert(1 != 1)
}
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top