How do I run Scala code in SBT Build.scala just before compiling Scala files?

I'm trying to run some Scala code, just print "Hello" for now, but I want to run the Scala code just before compiling the Scala code in an SBT project. I found that the following works in build.sbt.

compile in Compile <<= compile in Compile map {
  comp => {


However I want to do it in Build.scala, how do I do it in Build.scala?


source to share

1 answer

While you import the usual:

import sbt._
import Keys._


you should be able to use exactly the same code in Build.scala


That being said, you should use dependsOn

instead map


compile in Compile <<= (compile in Compile).dependsOn(Def.task {




All Articles