I use sbt 0.13.1.
To list the tasks in a sbt project, one can use sbt tasks -V.
As A "command" looks similar to a task: it's a named operation that can be executed from the sbt console and Typically, you would resort to a command when you need to do something that's impossible in a regular task, how can I know what commands are available for a sbt project?
Is there a similar command to list all of the commands in a sbt project?
Say, the sbt-idea plugin's installed in a sbt project. How could I query the project to find out about the gen-idea command?
It's so confusing given the comment of #Mark Harrah: "gen-idea is a command, not a task." and the documentation of the sbt-idea plugin where it says "Use the gen-idea sbt task to create Idea project files." (note the use of task). I am confused.
Doesn't "help" without any arguments do that? From my understanding "tasks" without any arguments will list available tasks and "help" w/o arguments will do a similar things for commands.
I'd argue it's an implementation detail.
Do you have a real use case where you require to list only commands? :-)
--
Update 1:
sbt
$ <tab><tab>
Display all 339 possibilities? (y or n) [y]
# ...
gen-idea
# ...
Simply tabbing in the terminal gives you all actions you can perform, including gen-idea - your use-case.
Related
like scala shell, does sbt shell provides a way to play around with sbt code
i.e. can I use sbt shell to create temporary tasks/settings and play with them
e.g. redefine existing definitions(in build.sbt) on sbt shell
I see set and eval commands but not sure how can I use sbt shell for testing some small sbt expression. I see that there session command as well.
Please provide a overview on how to try sbt shell as an interpreter of sbt expressions
You can try using consoleProject that allows you to eval settings and tasks and generally explore around your build. Its not the exact same thing that you're asking but maybe offers similar functionality?
Console Project Docs
I currently have a command line sbt -Dsome.configuration.option test doing what I want, but I would like it to apply that configuration option automatically for sbt test (and no other sbt phase). If my terminology is correct, then I want to set a Java Option for the Test Configuration. How do I do this?
Searching on these terms has led me to http://www.scala-sbt.org/release/docs/Testing.html but I have not yet been able to understand it.
This question looks similar to mine: Define custom test configurations in sbt
Try this:
testOptions in Test +=
Tests.Setup(() => sys.props += "some.configuration.option" -> "true")
Caveat:
Because you're not forking this mutates the state of the system property in the JVM running sbt itself.
Which means that after running test the first time it that system property will also be set if you, for instance, run your main from within sbt (run/runMain).
I use sbt with the native packager plugin, in order to build Debian packages for our Play 2.2 applications. We use the debian:publish in order to upload the packages to our Artifactory server, and the publish command to publish the regular Java jars.
I'd like to be able to use the regular publish command to published both the jar files and the Debian packages. I think I need to somehow combine the publish task in the Debian scope with the regular one in the Compile scope, but I can't really find any documentation on how to do that.
I came up with the following code, which works, but seems to me to be the 'wrong' way to do it:
publish := { // Also publish deb files
val value = publish.value
(publish in Debian).value
}
Especially the second line seems wrong, since it's ignoring the value. The val is there to quiet a warning, which is another smell.
Is there a better way to do this?
You can use triggeredBy. In your build.sbt add following line:
publish in Debian <<= (publish in Debian).triggeredBy(publish in Compile)
PS. I think the way you did it is also fine. If you're worried about the warning you can assign the result to some val.
Here, the dependsOn task is appropriate, if you don't care about the return value:
publish := publish.dependsOn(publish in Debian).value
How can I run external shell commands once I am in sbt interactive shell?
That is, after I type sbt and see the prompt showing up, how can I do things like ls, or cd etc.? There should be a way to do this, correct?
Thank you.
On http://www.scala-sbt.org/release/docs/Community/Community-Plugins.html is a list of SBT plugins.
A plugin for your purpose can be https://github.com/steppenwells/sbt-sh .
I need something like make i.e. dependencies + executing shell commands where failing command stops make execution.
But more deeply integrated with shell i.e. now in make each line is executed in separate context so it is not easy to set variable in one line and use it in following line (I do not want escape char at end of line because it is not readable).
I want simple syntax (no XML) with control flow and functions (what is missing in make).
It does not have to have support for compilation. I have to just bind together several components built using autotools, package them, trigger test and publish results.
I looked at: make, ant, maven, scons, waf, nant, rake, cons, cmake, jam and they do not fit my needs.
take a look at doit
you can use shell commands or python functions to define tasks (builds).
very easy to use. write scripts in python. "no api" (you dont need to import anything in your script)
it has good support to track dependencies and targets
Have a look at fabricate.
If that does not fulfill your needs or if you would rather not write your build script in Python, you could also use a combination of shell scripting and fabricate. Write the script as you would to build your project manually, but prepend build calls with "fabricate.py" so build dependencies are managed automatically.
Simple example:
#!/bin/bash
EXE="myapp"
CC="fabricate.py gcc" # let fabricate handle dependencies
FILES="file1.c file2.c file3.c"
OBJS=""
# build link
for F in $FILES; do
echo $CC -c $F
if [ $? -ne 0 ]; then
echo "Build failed while compiling $F" >2
exit $?
fi
OBJS="$OBJS ${F/.c/.o}"
done
# link
$CC -o $EXE $OBJS
Given that you want control flow, functions, everything operating in the same environment and no XML, it sounds like you want to use the available shell script languages (sh/bash/ksh/zsh), or Perl (insert your own favourite scripting language here!).
I note you've not looked at a-a-p. I'm not familiar with this, other than it's a make system from the people who brought us vim. So you may want to look over that.
A mix of makefile and a scripting language to choose which makefile to run at a time could do it.
I have had the same needs. My current solution is to use makefiles to accurately represent the graph dependency (you have to read "Recursive make considered harmful"). Those makefiles trigger bash scripts that take makefiles variables as parameters. This way you have not to deal with the problem of shell context and you get a clear separation between the dependencies and the actions.
I'm currently considering waf as it seems well designed and fast enough.
You might want to look at SCons; it's a Make-replacement written in Python.