Can sbt execute “compile test:compile it:compile” as a single command, say “*:compile”?

后端 未结 1 673
一个人的身影
一个人的身影 2021-01-04 04:13

I\'m running compile test:compile it:compile quite often and...would like to cut the number of keystrokes to something like *:compile. It doesn\'t

相关标签:
1条回答
  • 2021-01-04 04:18

    test:compile implies a compile so compile doesn't need to be explicitly run before test:compile. If your IntegrationTest configuration extends Test, it:compile implies test:compile.

    One option is to define an alias that executes multiple commands:

    sbt> alias compileAll = ; test:compile ; it:compile
    

    See help alias and help ; for details. You can make this a part of your build with:

    addCommandAlias("compileAll", "; test:compile ; it:compile")
    

    The other option is to define a custom task that depends on the others and call that:

    lazy val compileAll = taskKey[Unit]("Compiles sources in all configurations.")
    
    compileAll := { 
       val a = (compile in Test).value
       val b = (compile in IntegrationTest).value
       ()
    }
    
    0 讨论(0)
提交回复
热议问题