Run "sbt show subproject/dependencyClasspathAsJars" from shell - scala

In my multi-project build, I can list all dependencies of one of my subproject:
$ sbt
[info] ...
sbt:MyProject> show subproject2/dependencyClasspathAsJars
/path/jar1:/path/jar2:...:/home/.../MyProject/build/subproject1.jar
sbt:MyProject>
However, I'd need to run this in CI, but...:
$ sbt show subproject2/dependencyClasspathAsJars
[info] Loading global plugins from /home/.../plugins
[info] Loading project definition from /home/.../MyProject/project
[info] Loading settings for project MyProject from build.sbt,modules.sbt ...
[info] Set current project to MyProject (in build file:/home/.../MyProject/)
[error] Not a valid command: show (similar: shell)
[error] Expected whitespace character
[error] Not a valid project ID: show
[error] Expected ':'
[error] Not a valid key: show (similar: showTiming, sLog, ps)
[error] show
[error] ^
To get this classpath from (shell) command line, what should I do? I'm using sbt 1.2.8 & scala 2.10.

show dependencyClasspathAsJars needs to be passed to sbt as a single argument. With common shells, this works:
$ sbt "project subproject2" "show dependencyClasspathAsJars"
project subproject2 selects your subproject and show dependencyClasspathAsJars computes the task on the subproject.

Related

How to run an SBT task prefixed with a configuration in batch mode?

In SBT interactive mode I can prefix tasks with configuration names (scoped commands):
$ sbt
> compile
> Compile / compile
> Test / compile
I can also run tasks in batch mode (non-interactive mode)
$ sbt compile
but running
$ sbt Test / compile
gives an error
[info] Executing in batch mode. For better performance use sbt's shell
[error] Not a valid command: Test (similar: set, last, exit)
[error] Not a valid project ID: Test
[error] Expected ':'
[error] Expected '/'
[error] Not a valid key: Test (similar: test, testOnly, dist)
[error] Test
[error] ^
How do I run configuration-prefixed tasks in batch mode in SBT?
To run configuration-level tasks in batch mode try using test: prefix like so
sbt test:compile
sbt test:clean test:compile
or surrounded with quotes
sbt "Test / compile"
sbt ";Test / clean; Test / compile"
Also we could set configuration scope once and then all subsequent commands would be scoped to this configuration like so
sbt ";set configuration := Test; clean; compile"

failed to create .ensime file, how can I do?

I have been trying to use ensime with sublime to use Scala. To install ensime I created a plugin.sbt in this location
~/.sbt/1.0/plugins/plugins.sbt
here is the screen shot
I also added "addSbtPlugin("org.ensime" % "sbt-ensime" % "2.0.1")" in the plugin.sbt. But when I run sbt and run the command "ensimeConfig" to create .ensime file I get error
C:\Users\Mahadi>sbt
"C:\Users\Mahadi\.sbt\preloaded\org.scala-sbt\sbt\"1.0.1"\jars\sbt.jar"
Java HotSpot(TM) 64-Bit Server VM warning: ignoring option MaxPermSize=256m; sup
port was removed in 8.0
[info] Loading global plugins from C:\Users\Mahadi\.sbt\1.0\plugins\project
[info] Loading settings from plugins.sbt ...
[info] Loading global plugins from C:\Users\Mahadi\.sbt\1.0\plugins
[info] Loading project definition from C:\Users\Mahadi\project
[info] Set current project to mahadi (in build file:/C:/Users/Mahadi/)
[info] sbt server started at 127.0.0.1:5547
sbt:mahadi> ensimeConfig
[error] Not a valid command: ensimeConfig
[error] Not a valid project ID: ensimeConfig
[error] Expected ':' (if selecting a configuration)
[error] Not a valid key: ensimeConfig
[error] ensimeConfig
[error] ^
sbt:mahadi>
So I am looking for your help.
Youn should run sbt in the root directory of your sbt project, as the ensime configuration file is built based on it.

Warning message running Play - activator eclipse

I downloaded play framework from here:
https://www.playframework.com/download
And I chose the Offline Distribution download.
I set the path environment variable and added this:
C:\Framework\activator-dist-1.3.10\bin
While trying to create a new project I wrote in the cmd "activator new" and it worked.
Than I wrote activator eclipse but I got this errors:
C:\Users\***\Desktop\***\FirstPlayProject>activator eclipse
ACTIVATOR_HOME=C:\Framework\activator-dist-1.3.10
The system cannot find the file BIN_DIRECTORY\..\conf\sbtconfig.txt.
[info] Loading project definition from C:\Users\***\Desktop\·δ≡σ·\FirstPlayPro
ject\project
[info] Updating {file:/C:/Users/***/Desktop/%D7%AA%D7%9B%D7%A0%D7%95%D7%AA/Fir
stPlayProject/project/}firstplayproject-build...
[info] Resolving com.typesafe.akka#akka-persistence-experimental_2.10;2.3.11 ...
[info] Resolving com.fasterxml.jackson.datatype#jackson-datatype-jsr310;2.5.4 ..
[info] Resolving org.scala-sbt.ivy#ivy;2.3.0-sbt-2cc8d2761242b072cedb0a04cb39435
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[info] Done updating.
[info] Set current project to FirstPlayProject (in build file:/C:/Users/***/De
sktop/%D7%AA%D7%9B%D7%A0%D7%95%D7%AA/FirstPlayProject/)
[error] Not a valid command: eclipse (similar: help, alias)
[error] Not a valid project ID: eclipse
[error] Expected ':' (if selecting a configuration)
[error] Not a valid key: eclipse (similar: deliver, licenses, clean)
[error] eclipse
[error]
Maybe it because of this error: The system cannot find the file BIN_DIRECTORY\..\conf\sbtconfig.txt.
You will need to add sbteclipse for that to work. In your project/plugins.sbt file, add the following:
addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "4.0.0")
Then compile your app first (compile in the activator shell). Then you can use the eclipse command in the activator shell.
More info: https://www.playframework.com/documentation/2.5.x/IDE#Eclipse

Why is Typesafe activator command `activator dependencies` not working?

I created a new project using Typesafe Activator. In the command prompt I execute the command activator dependencies. This results in:
E:\sample_app>activator dependencies
[info] Loading project definition from E:\sample_app\project
[info] Updating {file:/E:/sample_app/project/}sample_app-build...
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[info] Done updating.
[info] Set current project to sample_app (in build file:/E:/sample_app/)
[error] Not a valid command: dependencies
[error] Not a valid project ID: dependencies
[error] Expected ':' (if selecting a configuration)
[error] Not a valid key: dependencies (similar: all-dependencies, rpm-dependencies, allDependencies)
[error] dependencies
[error] ^
Versions used:
Java version is 1.8.0_51,
Activator is 1.3.6,
OS is windows 8,
64 - bit OS.
Analysis
First, dependencies is not valid sbt commands. (All sbt commands can be used also in activator.)
Solution
Either you mean libraryDependencies (which is an sbt setting) so call
activator libraryDependencies
Or you want to see the classpath of the dependencies ( a sbt task, so you need to use show to see the output of the sbt task), e.g.
activator "show dependencyClasspath"
Edit as of 2015-09-30,3:50am
If calling from console, the combined command must be put into quotes. Here: "show dependencyClasspath"

"./sbt/sbt assembly" errors "Not a valid command: assembly" for Apache Spark project

I'm having trouble with installing Apache Spark on Ubuntu 13.04. Im using spark-0.8.1-incubating, and both ./sbt/sbt update and ./sbt/sbt compile work fine. However, when I do a ./sbt/sbt assembly I get the following error:
[info] Set current project to default-289e76 (in build file:/node-insights/server/lib/spark-0.8.1-incubating/sbt/)
[error] Not a valid command: assembly
[error] Not a valid project ID: assembly
[error] Not a valid configuration: assembly
[error] Not a valid key: assembly
[error] assembly
[error]
I googled for stuff related to this but couldn't find anything useful. Any guidance would be much appreciated.
The current project set to default-289e76 message suggests that sbt was called from outside of the Spark sources directory:
$ /tmp ./spark-0.8.1-incubating/sbt/sbt assembly
[info] Loading global plugins from /Users/joshrosen/.dotfiles/.sbt/plugins/project
[info] Loading global plugins from /Users/joshrosen/.dotfiles/.sbt/plugins
[info] Set current project to default-d0f036 (in build file:/private/tmp/)
[error] Not a valid command: assembly
[error] Not a valid project ID: assembly
[error] Not a valid configuration: assembly
[error] Not a valid key: assembly
[error] assembly
[error] ^
Running ./sbt/sbt assembly works fine from the spark-0.8.1-incubating directory (note the log output showing that the current project was set correctly):
$ spark-0.8.1-incubating sbt/sbt assembly
[info] Loading global plugins from /Users/joshrosen/.dotfiles/.sbt/plugins/project
[info] Loading global plugins from /Users/joshrosen/.dotfiles/.sbt/plugins
[info] Loading project definition from /private/tmp/spark-0.8.1-incubating/project/project
[info] Loading project definition from /private/tmp/spark-0.8.1-incubating/project
[info] Set current project to root (in build file:/private/tmp/spark-0.8.1-incubating/)
...
You typed "abt" twice, but shouldn't that be "sbt"? Apache Spark has its own copy of sbt, so make sure you're running Spark's version to pick up the "assembly" plugin among other customizations.
To run the Spark installation of sbt, go to the Spark directory and run ./sbt/sbt assembly .