拥有以下构建定义文件和sbt 0.13.1
:
name := "foobar"
val foo = taskKey[Unit]("foo")
val bar = taskKey[Unit]("bar")
foo := { println("foo") }
bar := { println("bar"); throw new Exception("bar exception") }
bar <<= bar triggeredBy foo
当我执行foo
任务时,触发的bar
任务抛出的异常没有报告:
$ sbt foo
Loading /opt/local/sbt/bin/sbt-launch-lib.bash
[info] Loading global plugins from /home/s.savulchik/.sbt/0.13/plugins
[info] Loading project definition from /home/s.savulchik/projects/foobar/project
[info] Set current project to foobar (in build file:/home/s.savulchik/projects/foobar/)
foo
bar
[success] Total time: 0 s, completed Mar 12, 2014 6:34:52 PM
相反,当我直接执行bar
任务时,异常按照预期报告:
$ sbt bar
Loading /opt/local/sbt/bin/sbt-launch-lib.bash
[info] Loading global plugins from /home/s.savulchik/.sbt/0.13/plugins
[info] Loading project definition from /home/s.savulchik/projects/foobar/project
[info] Updating {file:/home/s.savulchik/projects/foobar/project/}foobar-build...
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[info] Done updating.
[info] Set current project to foobar (in build file:/home/s.savulchik/projects/foobar/)
bar
java.lang.Exception: bar exception
at $df74d6ea1c7cfacc5a14$$anonfun$$sbtdef$1.apply(/home/s.savulchik/projects/foobar/build.sbt:8)
at $df74d6ea1c7cfacc5a14$$anonfun$$sbtdef$1.apply(/home/s.savulchik/projects/foobar/build.sbt:8)
at sbt.std.Transform$$anon$3$$anonfun$apply$2.apply(System.scala:45)
at sbt.std.Transform$$anon$3$$anonfun$apply$2.apply(System.scala:45)
at sbt.std.Transform$$anon$4.work(System.scala:64)
at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:237)
at sbt.Execute$$anonfun$submit$1$$anonfun$apply$1.apply(Execute.scala:237)
at sbt.ErrorHandling$.wideConvert(ErrorHandling.scala:18)
at sbt.Execute.work(Execute.scala:244)
at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:237)
at sbt.Execute$$anonfun$submit$1.apply(Execute.scala:237)
at sbt.ConcurrentRestrictions$$anon$4$$anonfun$1.apply(ConcurrentRestrictions.scala:160)
at sbt.CompletionService$$anon$2.call(CompletionService.scala:30)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:471)
at java.util.concurrent.FutureTask.run(FutureTask.java:262)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
at java.lang.Thread.run(Thread.java:744)
[error] (*:bar) java.lang.Exception: bar exception
[error] Total time: 0 s, completed Mar 12, 2014 6:33:45 PM
任何帮助是非常感激的!谢谢。
正如@jsuereth所评论的那样,这要么是故意的行为,要么是一个bug。http://github.com/sbt/sbt/issues/1187