How to create a separate compilation task without a separate configuration, but different scalacOptions?

Starting from this question , I want to be able to compile sbt projects in two different ways, i.e. with different scalacOptions . Answering repetitive questions explains why introducing a different configuration does not help, because you also need special sources.

So. But I do not want loyal sources. I want to compile exactly the same sources, but with different compiler settings. Therefore, I suggest that the solution should be to define a new task, not compilation. how

 val myCompile = taskKey[???]("Compiles my way") scalacOptions in MyCompile ++= Seq("-elide-below", "1") 

Then I would like the minimum effort to duplicate the default compile job with a separate target directory and could it work than in myCompile:assembly ...? How can I do it?

+8
scala sbt
source share
2 answers

tl; dr Use inspect to find out the return type of compile .

 > inspect compile [info] Task: sbt.inc.Analysis ... 

In doing so, in build.sbt you should have the following:

 val myCompile = taskKey[sbt.inc.Analysis]("Compiles my way") myCompile <<= compile in Compile scalacOptions in myCompile ++= Seq("-elide-below", "1") 
+2
source share

You can use a separate configuration and add

 sourceDirectory in MyCompile := (sourceDirectory in Compile).value 

use src/main/* sources, how to compile tasks with various parameters in sbt

0
source share

All Articles