My projects still use sbt 0.7.7, and itβs very convenient for me to have utility classes that I can run from the sbt prompt. I can also combine this with properties that are separately supported β typically for environment-related values ββthat change from hosts to hosts. This is an example of my project definition in the project/build directory:
class MyProject(info: ProjectInfo) extends DefaultProject(info) { //... lazy val extraProps = new BasicEnvironment { // use the project Logger for any properties-related logging def log = MyProject.this.log def envBackingPath = path("paths.properties") // define some properties that will go in paths.properties lazy val inputFile = property[String] } lazy val myTask = task { args => runTask(Some("foo.bar.MyTask"), runClasspath, extraProps.inputFile.value :: args.toList).dependsOn(compile) describedAs "my-task [options]" } }
Then I can use my task as my-task option1 option2 under the sbt shell.
I read the new sbt 0.11 documentation at https://github.com/harrah/xsbt/wiki , including the Tasks and TaskInputs sections , and to be honest, I'm still struggling with how to achieve what I did on 0.7.7 .
It seems that additional properties can simply be replaced by a separate environment.sbt , that tasks should be defined in project/build.scala before being set in build.sbt . It also looks like there is support for completion that looks very interesting.
In addition, I am somewhat overloaded. How to accomplish what I did with the new sbt?
scala sbt
huynhjl
source share