Departing from this question, I want to be able to compile an sbt projects in two different manners, i.e. with different scalacOptions. The answer to the duplicate questions explains why introducing another configuration doesn't help because you would also need dedicated sources.
So. But I don't want dedicated sources. I want to compile exactly the same sources but with different compiler settings. So I imagine the solution must be to define a new task instead that does the compilation. Like
val myCompile = taskKey[???]("Compiles my way")
scalacOptions in MyCompile ++= Seq("-elide-below", "1")
I would then want the minimum effort to duplicate the default compile task with a separate target directory, and could that feed than into a myCompile:assembly...? How would I do that?
tl;dr Use inspect to learn the return type of compile.
> inspect compile
[info] Task: sbt.inc.Analysis
...
With this, you should have the following in build.sbt:
val myCompile = taskKey[sbt.inc.Analysis]("Compiles my way")
myCompile <<= compile in Compile
scalacOptions in myCompile ++= Seq("-elide-below", "1")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With