Trying to use Play Framework - scala

Not sure how to describe this error, but I'll try. I'm trying to learn to use the Play Framework for a project I'm collaborating on, and a few hours into but having trouble.
After creating a new project with activator, entering the directory and then typing activator, I then type "play" and get this output:
➜ ix activator
[info] Loading project definition from /Users/ace/Projects/ix/project
[info] Updating {file:/Users/ace/Projects/ix/project/}ix-build...
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[info] Done updating.
[info] Set current project to ix (in build file:/Users/ace/Projects/ix/)
[ix] $ play
[error] Not a valid command: play (similar: apply, last, alias)
[error] Not a valid project ID: play
[error] Expected ':' (if selecting a configuration)
[error] Not a valid key: play (similar: playStop, playConf, play-stop)
[error] play
[error]
I can't make any sense of it. Literally just installed everything today (Scala/Play Framework) and using it on OSX 10.10.

You have to use the "activator" command instead of "play". This has been the case since version 2.3:
The first thing you’ll notice about Play 2.3 is that the play command
has become the activator command. Play has been updated to use
Activator...

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

play command doesn't work when inside of an existing sbt project

So I have an existing sbt project setup:
common
services
project/build.scala
build.sbt
Now when inside this folder, I want to create a play application called 'web'.
I get this error:
error] Not a valid command: new (similar: set)
[error] Not a valid project ID: new
[error] Expected ':' (if selecting a configuration)
[error] Not a valid key: new (similar: name, run, runner)
[error] new
[error] ^
The play command works just fine if I try the same thing in a new folder.
How can I get the play command to work inside of an existing sbt project?
I'm using sbt .13
Why not create the project outside of the current structure, then move the created directory where you want it to live?

"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.

Not a valid command: it when executing sbt it

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.

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)