Not a valid command: it when executing sbt it - scala

I followed the steps for adding integration tests found at http://www.scala-sbt.org/release/docs/Detailed-Topics/Testing#integration-tests.
However, when I run sbt it, see the following:
$ sbt it
[info] Loading project definition from myproj/project
[info] Set current project to myproj (in build file:myproj/)
[error] Not a valid command: it
[error] Not a valid project ID: it
[error] Expected ':' (if selecting a configuration)
[error] Not a valid key: it
[error] it
[error] ^
sbt test works as expected

What's described in Integration Tests is about how to add a new configuration, namely it. There are many configurations available, e.g. Compile, Test, Runtime, Docs, Pom - you can find the default ones as vals in the sbt.Configuration object.
The official documentation of SBT in Selecting the configuration and Scoping by configuration axis should explain why you calling sbt it would require a command or a task with the it name which as it turned out was not the case.
The it configuration binds tasks that you may have used in the other configurations like test be reconfigured so the integration tests are in it directory (rather than in their default one - src/test).

After a bunch of googling, I realized the problem was that integration tests aren't quite the same as tests. To run integration tests, the configuration is slightly different:
sbt it:test
When I do that, everything works fine.

Related

sbt new scala/scalatest.g8 fails on TransportException

When I try to create the ScalaTest example with this command:
sbt new scala/scalatest-example.g8 fails on TransportException
I get the following:
[info] Set current project to scala (in build file:/Users/chasrmartin/Dropbox/Etudes/Scala/)
[error] org.eclipse.jgit.api.errors.TransportException: git#github.com:scala/scalatest-example.g8.git: Auth fail
[error] at org.eclipse.jgit.api.FetchCommand.call(FetchCommand.java:139)
[error] at org.eclipse.jgit.api.CloneCommand.fetch(CloneCommand.java:193)
I've tried several workarounds from around the next (eg this SO question) to no avail. It would seem this has to be a simple problem, I got this command from a beginners tutorial.
Update
I got this command from https://www.scala-lang.org/documentation/getting-started-sbt-track/testing-scala-with-sbt-on-the-command-line.html
This project doesn't seems to exists anymore.
Instead I would prefer to run with the normal scala-seed.g8
> sbt new scala/scala-seed.g8
And add the test classes manually.
This is an equivalent tutorial with the same classes and tests.
The scala seed template already comes with the structure you want, with the test dependency. You can run sbt test normally.

Cannot see jacoco task when executing sbt tasks command (-v is tried as well)

I was trying to use jacoco to integrate test report to my sbt project. https://github.com/sbt/jacoco4sbt
I added jacoco.settings into build.sbt
I also added addSbtPlugin("de.johoop" % "jacoco4sbt" % "2.1.6") into plugins.sbt
When I run sbt jacoco:check, it is working fine. However, when I try to look at how many tasks for jacoco, sbt tasks doesn't show anything related to jacoco.
I have to go to source code to look at it.
https://github.com/sbt/jacoco4sbt/blob/master/src/main/scala/de/johoop/jacoco4sbt/Keys.scala
May I know why jacoco is not shown for sbt tasks command and what is preferable way to look at all the available tasks for the plugins
Edit:
I suspect that the statement lazy val Config = config("jacoco") extend(Test) hide means jacoco extends Test task, so it wont show it in the sbt tasks, but I am not sure.
By running
> tasks -v
Edit: If that doesn't work consider adding more "v"s, such as tasks -vvv, or even tasks -V to see all the tasks.
I see, for instance, cover:
This is a list of tasks defined for the current project.
It does not list the scopes the tasks are defined in; use the 'inspect' command for that.
Tasks produce values. Use the 'show' command to run the task and print the resulting value.
check Executes the tests and saves the execution data in 'jacoco.exec'.
classesToCover compiled classes (filtered by includes and excludes) that will be covered
clean Cleaning JaCoCo's output-directory.
compile Compiles sources.
console Starts the Scala interpreter with the project classes on the classpath.
consoleProject Starts the Scala interpreter with the sbt and the build definition on the classpath and useful imports.
consoleQuick Starts the Scala interpreter with the project dependencies on the classpath.
copyResources Copies resources to the output directory.
cover Executes the tests and creates a JaCoCo coverage report.
coveredSources Covered Sources.
Note also what it says at the beginning (wrapped for clarity):
It does not list the scopes the tasks are defined in;
use the 'inspect' command for that.
which leads to
> inspect cover
[info] No entry for key.
[info] Description:
[info] Executes the tests and creates a JaCoCo coverage report.
[info] Delegates:
[info] *:cover
[info] {.}/*:cover
[info] */*:cover
[info] Related:
[info] jacoco:cover
So you know to run jacoco:cover

how to get more debugging for sbt compile error? "MethodHandle not found"

Attempting to sbt compile a branch of my project ENSIME (experiment if you're interested) under Java 6 is giving a bizarre compiler warning:
[info] Compiling 48 Scala sources to /home/fommil/Projects/ensime-server/target/scala-2.11/classes...
[error] Class java.lang.invoke.MethodHandle not found - continuing with a stub.
[error] two errors found
[error] (compile:compile) Compilation failed
[error] Total time: 18 s, completed 03-Sep-2014 22:57:44
It works under Java 7.
Calling last reveals nothing more than the classpath of the compile (this would be equivalent to setting --debug level).
I've removed all the plugins from the project, and the problem still shows.
If I remove all my code - leaving just the build system and dependencies - with some stub scala entry points then there is no problem.
However, I can't exactly bisect my source code file because then it doesn't compile.
When the code is compiled, a grep (including binaries) of MethodHandle doesn't give any hits (although there is a jdk8 file in the tests resources, it is not relevant because the problem appears if it is removed).
It is only one (big) patch that has caused the problem (the previous commit compiles ok).
How can I debug this further in sbt? it doesn't want to give any more info
is this a known problem, or can anyone make an informed guess what is going on?
It turns out that this was caused by pulling in Lucene, which requires Java 7.
A bit of an epic message fail from sbt: there doesn't appear to be any way to get it to output anything sensible.

"dist" command gets "not a valid command" error

I have a working Play Framework 2.1 application generated with typesafe activator that I've developed in Scala. I'm trying to deploy it in CloudBees using the instructions that can be found here: http://wiki.cloudbees.com/bin/view/RUN/Playframework#HDeployingaPlay2application using the method described under "Using Cloudbees SDK."
However, when I load up the play console and try to run the "dist" command, I get the error "Not a valid command: dist."
I've tried two run this three different ways:
In the terminal window (I'm using Mac OS X), I navigated to the project directory, ran the "activator" application (there is no application in that directory called "play", but "activator" seems to be the), then from the prompt that appears I enter the command "dist."
I downloaded the regular (non-activator) Play Framework distirbution file, add the directory to my path using "export PATH=$PATH:/Applications/play-2.2.2", navigated to the project directory, and ran the command "play dist."
Installed play using Homebrew. Navigated to the project directory and ran "play dist".
All three methods give me the same error (see below). Is the method different for my version of play? Am I missing something from the sbt file? How can I get this working?
Full output for "play dist":
Macmini-##########-#:nimrandslibrary.searchfu.esl kpyancey$ play dist
[info] Loading project definition from /Users/kpyancey/Projects/NimrandsLibrary.SearchFu.Esl/project
[info] Set current project to NimrandsLibrary.SearchFu.Esl (in build file:/Users/kpyancey/Projects/NimrandsLibrary.SearchFu.Esl/)
[error] Not a valid command: dist (similar: set, iflast, last)
[error] Not a valid project ID: dist
[error] Expected ':' (if selecting a configuration)
[error] Not a valid key: dist (similar: test, ivy-sbt, history)
[error] dist
[error] ^
I think you have misconfigured something in your project.
To double check, generate a new project from Activator or try downloading https://github.com/CloudBees-community/play2-clickstart (which is correctly configured) and run play dist.

Just downloaded the Scala Lift chat application and use the instructions to run it, but it fails

I cloned the project from:
https://github.com/dpp/simply_lift.git
Then I followed the instructions which state:
Change directories into the chat directory and type sbt update ~jetty-run.
SBT fetches dependencies, and then I get this:
[error] Not a valid command: jetty-run
[error] Expected '/'
[error] Expected ':'
[error] Not a valid key: jetty-run (similar: run)
[error] jetty-run
[error]
Now what?
In versions of SBT newer than 0.10.0, ~jetty-run has been removed in favour of:
container:start
container:stop
deployment // compiles the changes made while jetty is running.
You should've used sbt from the packaged archive (./sbt). Instead of a system-wide SBT (which may be new).
Anyway, I suggest to use use the new SBT and everything new, too. This is the official and good starting point for a project: https://github.com/lift/lift_25_sbt/
(personally I use it and I'm cool with how it works)