Skip to content

Instantly share code, notes, and snippets.

@hyysguyang
Last active August 29, 2015 14:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hyysguyang/4aae328e6f36b1e21006 to your computer and use it in GitHub Desktop.
Save hyysguyang/4aae328e6f36b1e21006 to your computer and use it in GitHub Desktop.
SBT tip

#Add depend on task

It's easy to add a task with dependOn within build.sbt, but it's not easy for build.scala, it's very very ..... eh...

 object ProjectBuild extends Build {
  //Fucking SBT........
  val install = TaskKey[Unit]("install", "Run all test and then publish to local")
  val installTask1 = install := println("Run install complete.")
  val installTask2 = install <<= install.dependsOn(test in Test)
  val installTask3 = install <<= install.dependsOn(test in IntegrationTest)

  lazy val integrationTest = Project("integration-test", file("integration-test"))
    .configs(IntegrationTest)
    .settings(installTask1,installTask2,installTask3)
    .settings(Defaults.itSettings: _*)
    .settings(fork in IntegrationTest := true)
}

Here is some tip: SBT is not usable

Don't try to 'use' SBT. Learn SBT first.

#Alias

addCommandAlias("install", ";compile;test;package")

We can use alias to setup lifecycle, just as maven.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment