When documentation's Usage merely says `> fooBar` what does that mean? - scala

Yes, a beginner question! I'm looking at https://github.com/sbt/sbt-license-report and see the usage section of:
> dumpLicenseReport
This dumps a ...
Well no, that is a partial application of the greater-than operator, >. But seriously, I think this means:
One: Run sbt
$ sbt
... debug info ...
[proj-name] $
OK, we're in a sort of REPL. Now two: dumpLicenseReport:
[proj-name] $ dumpLicenseReport
[error] dumpLicenseReport
[error] ^
Ok so that wasn't a repl so much as an "sbt shell". In this shell one valid command is console which does get to a repl:
[proj-name] $ console
...
scala> dumpLicenseReport
^
error: not found: value dumpLicenseReport
OOps, I didn't define the license.sbt file they show in the instructions. Doing that then...
[proj-name] $ console
...
scala> dumpLicenseReport
...
[error] stack trace is suppressed; run last update for the full output
[error] (update) sbt.librarymanagement.ResolveException: Error downloading com.typesafe.sbt:sbt-license-report;sbtVersion=1.0;scalaVersion=2.13:1.2.0
[error] Not found
[error] Not found
[error] not found: .../.ivy2/local/com.typesafe.sbt/sbt-license-report/scala_2.13/sbt_1.0/1.2.0/ivys/ivy.xml
[error] not found: https://repo1.maven.org/maven2/com/typesafe/sbt/sbt-license-report_2.13_1.0/1.2.0/sbt-license-report-1.2.0.pom
[error] not found: https://repo.typesafe.com/typesafe/releases/com/typesafe/sbt/sbt-license-report_2.13_1.0/1.2.0/sbt-license-report-1.2.0.pom
[error] Total time: 1 s, completed Feb 5, 2021, 10:18:25 PM
Now I'm guessing I just need to enter the right upstream location somewhere but I've not used sbt before. Would someone show me how to go from a *nix system with bash + sbt + jdk11 to running sbt-license-report?

#LuisMiguelMejíaSuárez indicated this is an SBT command intended to be ran from an SBT shell so the process is:
Enter your repository directory
Ensure you created license.sbt correctly, including having it under the project sub directory.
run sbt compile
run sbt dumpLicenseReport
Or Instead of steps 3 and 4 you can enter the shell with just sbt and execute commands of compile then dumpLicenseReport. The > prompt in the readme of the sbt-license-report repository indicates an SBT shell and not a repl (the "console") and certainly not a naked *nix shell (bash, zsh, etc).

Related

PlayFramework - Creating Scala seed template with sbt

I am attempting to create the PlayFramework Scala seed project.
So far I've used sbt new playframework/play-scala-seed.g8 command and it has created the necessary files within my root directory movie-app.
From this point, PlayFramework says to run sbt run, so I tried that, but I get the following error:
[info] Updated file *omitting personal directories*/Movie-App/project/build.properties: set sbt.version to 1.4.7
[info] welcome to sbt 1.4.7 (Ubuntu Java 11.0.10)
[info] loading project definition from *omitting personal directories*/Movie-App/project
[info] set current project to movie-app (in build file:*omitting personal directories*/Movie-App/)
[error] java.lang.RuntimeException: No main class detected.
[error] at scala.sys.package$.error(package.scala:30)
[error] stack trace is suppressed; run last Compile / bgRun for the full output
[error] (Compile / bgRun) No main class detected.
[error] Total time: 0 s, completed Jul 2, 2021, 11:27:33 PM
I haven't found anything helpful online yet.
Do I need to set the current project to "movie-app" like the error says? If so what do I need to write in the build.properties file?
If not, can anyone please explain the issue?
Thanks
$> sbt new playframework/play-scala-seed.g8
This template generates a Play Scala project.
Give it a name when asked. Skip rest by pressing enter.
name [play-scala-seed]: movie-app
$> cd movie-app
$> sbt run

I have installed sbt, but still I do not get the REPL

I need to install the scala interpreter (aka repl). The official website https://scala-lang.org/download/ gives me instructions on how to install sbt. I have installed sbt, but still do not have the interpreter. What am I missing here? I am supposed to type scala followed by the Enter key.
[Edit] Someone suggested me to type "console" after sbt is running, but I got an error message
sbt:slides> console
[info] Compiling 1 Scala source to /Users/zell/slides/target/scala-2.12/classes ...
[error] /Users/zell/slides/examFakeSolution.scala:108:10: not found: value fpinscala
[error] import fpinscala.monoids.Monoid
[error] ^
[error] /Users/zell/slides/examFakeSolution.scala:128:45: not found: type Monoid
[error] def foldBack[A] (l :List[A]) (implicit M :Monoid[A]) :A =
[error]
....
If you have sbt, you have the REPL. You are doing it right, you can run sbt and then console or directly run sbt console
The error is a compilation error. Fix it first and then you'll be able to run the REPL in that folder.
When you run the REPL, sbt tries to compile the project first. So you can also run it in any folder other than the one from the project and it will work fine.
If you want start scala REPL inside SBT, type sbt firstly, then console
To start REPL without installing SBT, download the Scala from official site, add %SCALA_HOME%/bin to PATH and type scala in the terminal.

How to run sbt multiple command in interactive mode as one command? [duplicate]

This question already has an answer here:
How to pass command line args to program in SBT 0.13.1?
(1 answer)
Closed 5 years ago.
I want to refine sbt assembly/package operation by combine two step to one.
The two step is:
$ sbt
> project XXX
....
> assembly
Ctrl + c to exit
Besides, assembly is a task form fat jar sbt plugin.
I have attempt with sbt project analysis assembly but not works.A error encounter:
[error] Not a valid command: analysis (similar: alias)
[error] Not a valid key: analysis (similar: readAnalysis, mainClass, less)
[error] analysis
[error] ^
How to achieve this?Thanks
Within the sbt shell, use ; to chain commands:
;project XXX; assembly
Calling from the command line, enclose individual commands with quotes:
sbt "project XXX" assembly
or enclose a whole chain in quotes:
sbt ";project XXX; assembly"
To call a task in subproject XXX from the context of another project in the shell:
XXX/assembly

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)

'sbt run' with CLI arguments from shell

I tried running my scala project with CLI arguments using sbt launcher version 0.12.1. It works OK when run from the scala prompt:
$ sbt
[info] (...)
> run sth
(...)
[success] Total time: 0 s, completed Nov 9, 2012 3:04:47 PM
But when I want to run it whole from shell, as per this answer for example, I'm getting an error:
$ sbt "run sth"
[info] (...)
you need to provide source file name
[success] Total time: 0 s, completed Nov 9, 2012 3:07:07 PM
[error] Not a valid command: sth (similar: set, last, shell)
[error] Expected '/'
[error] Expected ':'
[error] Not a valid key: sth (similar: test, state, watch)
[error] sth
[error] ^
And the "you need to provide source file name" info is given by my scala project to indicate that main didn't get any CLI arguments.
Is it something that worked in the previous version of sbt (in the referenced question), or am I doing something wrong?
The problem could be the way you pass arguments in your sbt launch file to Java. In my case it is:
java -Xmx4096M -jar `dirname $0`/sbt-launch_0.12.1.jar "$#"
And I just confirmed: It works with both 0.12 and 0.12.1. For instance, for a program that just prints its arguments I get:
$ sbt "run-main SomeMain blah blah"
Outut:
[blah, blah]
By using run-main you can also avoid the possibility that sbt somehow does not see your main function.
That's a bug in the 0.12.1 launcher: https://github.com/sbt/sbt-launcher-package/issues/34