These are chat archives for sbt/sbt

Sep 2017
David Francoeur
Sep 09 2017 16:58

Hi, quick question regarding scopes.
I use sbt(0.13.16) with sbt-twirl, I added scalacOptions suggested by @tpolecat ( but now it fails on my twirl templates.

> inspect subs/compile:twirlCompileTemplates::scalacOptions
[info] Task: scala.collection.Seq[java.lang.String]
[info] Description:
[info]     Options for the Scala compiler.
[info] Provided by:
[info]     {file:/Users/davidfrancoeur/workspace/subs/}subs/compile:twirlCompileTemplates::scalacOptions
[info] Defined at:
[info]     /Users/davidfrancoeur/workspace/subs/build.sbt:10
[info] Delegates:
[info]     compile:twirlCompileTemplates::scalacOptions
[info]     compile:scalacOptions
[info]     *:twirlCompileTemplates::scalacOptions
[info]     *:scalacOptions
[info]     {.}/compile:twirlCompileTemplates::scalacOptions
[info]     {.}/compile:scalacOptions
[info]     {.}/*:twirlCompileTemplates::scalacOptions
[info]     {.}/*:scalacOptions
[info]     */compile:twirlCompileTemplates::scalacOptions
[info]     */compile:scalacOptions
[info]     */*:twirlCompileTemplates::scalacOptions
[info]     */*:scalacOptions
[info] Related:
[info]     compile:ensimeCompileOnly::scalacOptions
[info]     compile:scalacOptions
[info]     compile:twirlSourceEncoding::scalacOptions
[info]     *:scalacOptions
[info]     */*:scalacOptions
[info]     test:scalacOptions
[info]     test:ensimeCompileOnly::scalacOptions

I tried to override the options only for the twirlCompileTemplates task with this:

scalacOptions ++= ScalacOptions.All // all options
scalacOptions in (Compile, TwirlKeys.sourceEncoding) ~= (_ filterNot (_ == "-Ywarn-unused:imports"))
scalacOptions in (Compile, TwirlKeys.compileTemplates) ~= (_ filterNot (_ == "-Ywarn-unused:imports"))

When I show the settings for both sourceEncoding and compileTemplates, I see that the unused scalac setting is removed, but running compile still fails.

Rob Norris
Sep 09 2017 17:02
Getting the scoping right is an exercise in trying shit at random so you might try that. Maybe Twirl by itself, or twirl.
David Francoeur
Sep 09 2017 17:09
quickly do you know a way I can ask sbt for more information regarding the failure when I run compile
maybe explicitly what is the 'subtask' that fails so I know which scalacOptions to override
Guillaume Martres
Sep 09 2017 20:52
When you run compile it should tell you what task failed exactly, e.g. [error] (foo/compile:compileIncremental) Compilation failed near the end
You can also type last to get the debug logs of the compile task, but that probably won't help you
Torsten Schmits
Sep 09 2017 23:17
is there a way to inject a Project into the current state from within a command?