-
Notifications
You must be signed in to change notification settings - Fork 1
play 2.0 in scala ide 2.0
[luc] all the commands are unix. Do we need to do a translation for Windows? [luc] needs a lot of screenshot, everywhere.
- Install Eclipse Helios from http://www.eclipse.org/downloads/packages/release/helios/sr2
- Install Scala IDE into Eclipse from this update site: http://www.eclipse.org/downloads/packages/release/helios/sr2
- Download Play framework 2.0beta from http://www.playframework.org/2.0
- Install it in your preferred location. Let's say
/path/to/play20
for the purpose of this document. - For convenience, and the Play folder to your system PATH:
export PATH=$PATH:/path/to/play20
- Your development folder, create a new play application, as a
simple Scala application
. - Go into the application folder
- Launch Play
- In Play, launch your newly created web application
- Check that the application works: http://localhost:9000/
The eclipse support is not yet integrated it Play 2.0, so let's use sbteclipse to create the Eclipse project.
- First, exit Play using
ctrl-d
twice - Add sbteclipse to sbt. Add the following at the end of
project/build.sbt
.
resolvers += Classpaths.typesafeResolver
addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse" % "1.4.0")
[luc] move to 1.5.0.
- Generate the Eclipse project configuration
~/dev/play/testApp$ play
[testApp] $ eclipse
- Fix the generated
.classpath
to remove the duplicated line
[testApp] $ exit
~/dev/play/testApp$ uniq .classpath > /tmp/play.tmp
~/dev/play/testApp$ mv /tmp/play.tmp .classpath
- Go back in play, and launch the web application
~/dev/play/testApp$ play
[testApp] $ run
[luc] this is bug, it should not have duplicated lines
-
In Eclipse, import the project
-
File > Import ... > General > Existing Projects into Workspace
. - Set the root directory to
~/dev/play/testApp
. - Hit
Finish
.
-
-
It does not compile. It is normal, we need to tell Scala IDE where to find the generated class files
- Select the
testApp
project. -
File > Properties
. - In the dialog
Java Build Path > Libraries > Add Class Folder...
. - Select
testApp/target/scala-2.9.1/classes_managed
. - Hit
OK
to validate the choice. - Hit
OK
to close the properties dialog.
- Select the
[luc] Maybe sbteclipse could configure this too. But it is not a hard requirement right now.
[luc] add configuration for .html files.
[luc] add explanation on how to open the browser view.
- Everything is setup. everything compiles.
Let's see how well it works.
- Open
testApp/app/controllers/Application.scala
. - Add an extra parameter to the call to the view
def index = Action {
Ok(views.html.index("Your new application is ready.", "Something smart here"))
}
- Save. It doesn't compile. Normal the view need to be change.
- Open
testApp/app/views/html/index.scala.html
- Add the parameter to the definition of the view
@(message: String, citation: String)
- And let's use it somewhere
@play20.welcome(message)
<p>citation</p>
- Save.
- Refresh the page in the browser view. Play regenerates its pages, the compilation problems are resolved, the updated page is correctly displayed.
No special development has been done for the integration of Play 2.0 and Scala IDE 2.0. So sometime Scala IDE is not aware of the files generated by Play 2.0 at all times. When everything compiles in Play, everything should be fine in Scala IDE too.