Difference between revisions of "Sbt"
From Knowitall
(SBT info) |
|||
Line 6: | Line 6: | ||
* <code>sbt compile</code>, for compiling, of course. | * <code>sbt compile</code>, for compiling, of course. | ||
* <code>sbt test</code>, which builds and runs tests. | * <code>sbt test</code>, which builds and runs tests. | ||
− | * <code>sbt 'run arg1 arg2 ...'</code> to run code. If there's more than one main class, it will prompt you to select a number for which one. You can automate this by just passing in the number through standard input, i.e., <code>echo 2 | sbt 'run arg1 arg2 ...'</code> | + | * <code>sbt 'run arg1 arg2 ...'</code> to run code. If there's more than one main class, it will prompt you to select a number for which one. You can automate this by just passing in the number through standard input, i.e., <code>echo 2 | sbt 'run arg1 arg2 ...'</code> Or, |
+ | * <code> sbt 'run-main edu.washington.cs.knowitall.MyMainClass arg1 arg2 ...'</code> | ||
* <code>sbt publish-local</code>, which is like <code>mvn install</code>. It saves the artifacts from the current project into a local Ivy repository, which other projects can use. | * <code>sbt publish-local</code>, which is like <code>mvn install</code>. It saves the artifacts from the current project into a local Ivy repository, which other projects can use. | ||
* <code>sbt clean</code> for when you want to clean your project. | * <code>sbt clean</code> for when you want to clean your project. | ||
You can also run sbt in interactive mode by just typing <code>sbt</code>. One helpful command is <code>~ compile</code>, which recompiles your code whenever you save a file. | You can also run sbt in interactive mode by just typing <code>sbt</code>. One helpful command is <code>~ compile</code>, which recompiles your code whenever you save a file. |
Revision as of 03:26, 8 May 2013
SBT is a build system for Scala/Java. Many of our projects use it now. You can get sample build files from our projects.
SBT Eclipse is a plugin for SBT that creates Eclipse projects for you based on your build. After setting it up, you just go to the root folder of any sbt project and type: sbt eclipse
. Then, from within Eclipse, you "import an existing Eclipse project."
Useful commands for sbt are:
-
sbt compile
, for compiling, of course. -
sbt test
, which builds and runs tests. -
sbt 'run arg1 arg2 ...'
to run code. If there's more than one main class, it will prompt you to select a number for which one. You can automate this by just passing in the number through standard input, i.e.,echo 2 | sbt 'run arg1 arg2 ...'
Or, -
sbt 'run-main edu.washington.cs.knowitall.MyMainClass arg1 arg2 ...'
-
sbt publish-local
, which is likemvn install
. It saves the artifacts from the current project into a local Ivy repository, which other projects can use. -
sbt clean
for when you want to clean your project.
You can also run sbt in interactive mode by just typing sbt
. One helpful command is ~ compile
, which recompiles your code whenever you save a file.