Skip to content

Commit

Permalink
Merge pull request #54 from scala-ide/issue/update-play-tutorial-53
Browse files Browse the repository at this point in the history
Updated Play tutorial for Play 2.1 and Scala IDE 3.0.0
  • Loading branch information
dotta committed Apr 3, 2013
2 parents eea215a + 608f9eb commit 3690d8b
Show file tree
Hide file tree
Showing 25 changed files with 20 additions and 313 deletions.
2 changes: 1 addition & 1 deletion src/sphinx/tutorials/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ Tutorials
:maxdepth: 2

m2eclipse/index.rst
play20scalaide20/index.rst
play/index.rst
lift24scalaide20/index.rst
continuations-plugin/index.rst
scalac-trunk/index.rst
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
Setup and use Play framework 2.0 in Scala IDE 2.0
Setup and use Play framework 2.1 in Scala IDE 3.0
=================================================

|frflag| :doc:`version française<index-fr>`

.. |frflag| image:: /images/frflag.png

What is in this guide?
----------------------

Expand All @@ -13,7 +9,7 @@ This guide will show you how to configure a Play web application to import it in
Prerequisites
.............

* `Eclipse`_ 3.6.2 (Helios) with Scala IDE for Scala 2.9 installed (update site: http://download.scala-ide.org/releases-29/stable/site).
* `Eclipse`_ 3.7 (Indigo) with Scala IDE for `Scala 2.10 installed <http://scala-ide.org/download/current.html#for_scala_210x>`_.

Check the :doc:`getting started </current-user-doc/gettingstarted/index>` page for instructions on how to install Scala IDE.

Expand All @@ -23,22 +19,22 @@ Prerequisites

* No knowledge of the Play framework is required (in this guide).

Setting up Play 2.0
Setting up Play 2.1
-------------------

To be able to create a Play web application, the Play framework need to be installed. If you have not installed it already, follow this few steps, or use the `Play documentation`_.

* Download Play framework 2.0 from http://www.playframework.org/.
* Download Play framework 2.1 from http://www.playframework.org/.

* Unzip it in your preferred location. Let's say ``/path/to/play20`` for the purpose of this document.
* Unzip it in your preferred location. Let's say ``/path/to/play21`` for the purpose of this document.

* For convenience, add the Play folder to your system PATH:

.. code-block:: bash
export PATH=$PATH:/path/to/play20
export PATH=$PATH:/path/to/play21
Creating a Play 2.0 application
Creating a Play 2.1 application
-------------------------------

* In your development folder, ask Play to create a new web application, as a ``simple Scala application``.
Expand Down Expand Up @@ -76,12 +72,12 @@ Creating a Play 2.0 application
:width: 100%
:target: ../../_images/play20-scalaide20-05.png

Configuring the Play 2.0 web application for Scala IDE
Configuring the Play 2.1 web application for Scala IDE
------------------------------------------------------

Now that the Play application is running, it needs to be configured so it can be imported into Scala IDE.

Play 2.0-RC1 integrates `sbteclipse`_, which allow to create configuration files of a project for Eclipse.
Play 2.1 integrates `sbteclipse`_, which allow to create configuration files of a project for Eclipse.

* First, exit the 'run' mode in Play using ``ctrl-d``.

Expand All @@ -90,7 +86,7 @@ Play 2.0-RC1 integrates `sbteclipse`_, which allow to create configuration files
:width: 100%
:target: ../../_images/play20-scalaide20-06.png

* ``eclipsify`` is the command to invoke sbteclipse in Play. (In Play 2.1, the command is ``eclipse``)
* ``eclipse`` is the command to invoke sbteclipse in Play. (or ``eclipse with-source=true`` if you want to also download sources attachment of your dependencies)

.. image:: images/play20-scalaide20-09.png
:alt: eclipse
Expand All @@ -104,7 +100,7 @@ Play 2.0-RC1 integrates `sbteclipse`_, which allow to create configuration files
:width: 100%
:target: ../../_images/play20-scalaide20-10.png

Configuring Scala IDE for the Play 2.0 web application
Configuring Scala IDE for the Play 2.1 web application
------------------------------------------------------

Setting a few preferences in Eclipse will make everything easier to use.
Expand All @@ -118,10 +114,10 @@ Setting a few preferences in Eclipse will make everything easier to use.

* Configure Eclipse so changes on the file system are automatically picked up.

.. image:: images/play20-scalaide20-13.png
.. image:: images/refresh-on-access.png
:alt: refresh automatically
:width: 100%
:target: ../../_images/play20-scalaide20-13.png
:target: ../../_images/refresh-on-access.png

* If you don't have the Web Development Tools for Eclipse installed, Eclipse opens ``.html`` files in a web browser. Configure it to use the ``Text Editor`` instead.

Expand All @@ -135,29 +131,13 @@ Importing the Play web application into Scala IDE

Everything is setup, it is time to import the project in the IDE.

* Import the Play 2.0 application as an ``Existing Projects into Workspace``.
* Import the Play 2.1 application as an ``Existing Projects into Workspace``.

.. image:: images/play20-scalaide20-15.png
:alt: import project
:width: 100%
:target: ../../_images/play20-scalaide20-15.png

* The configuration generated by sbteclipse is working fine in Eclipse, but it is not optimal when using with Scala IDE.

Add the ``target/src_managed/scala`` folder as a source folder.

.. image:: images/play20-scalaide20-20.png
:alt: add the managed sources folder
:width: 100%
:target: ../../_images/play20-scalaide20-20.png

* And remove the ``classes_managed`` folder for the build path.

.. image:: images/play20-scalaide20-21.png
:alt: remove managed classes folder
:width: 100%
:target: ../../_images/play20-scalaide20-21.png

* Everything is good, everything compiles.

.. image:: images/play20-scalaide20-16.png
Expand Down Expand Up @@ -185,17 +165,15 @@ Let's change the main page to display a quote instead of the default page.
package models
case class Quote(val text: String, val author: String) {
}
case class Quote(text: String, author: String)
* Add an extra parameter to the ``index.scala.html`` view and update the layout.

.. code-block:: scala
@(message: String, quote: models.Quote)
@main("Welcome to Play 2.0") {
@main("Welcome to Play 2.1") {
<p>@quote.text<em> - @quote.author</em></p>
Expand Down Expand Up @@ -230,9 +208,9 @@ Let's change the main page to display a quote instead of the default page.
Going further
-------------

You now have all you need to create great web applications with Play 2.0 and Scala.
You now have all you need to create great web applications with Play 2.1 and Scala.

For more information about Play 2.0, check out the `embedded documentation`_.
For more information about Play 2.1, check out the `embedded documentation`_.

For more information about Scala, go to the `documentation website`_ or get the downloadable `eBook`_.

Expand All @@ -245,11 +223,10 @@ Please use github tickets and pull requests system for feedback.
Luc Bourlier - `+Luc Bourlier`_ `@sky1uc`_


.. _#1000907: http://www.assembla.com/spaces/scala-ide/tickets/1000907
.. _Scala IDE: http://www.scala-ide.org
.. _Scala IDE documentation project: https://github.com/scala-ide/docs
.. _Eclipse: http://www.eclipse.org/
.. _Play documentation: http://www.playframework.org/documentation/2.0/Installing
.. _Play documentation: http://www.playframework.com/documentation/2.1.0/Home
.. _sbteclipse: https://github.com/typesafehub/sbteclipse
.. _embedded documentation: http://localhost:9000/@documentation/Home
.. _documentation website: http://docs.scala-lang.org/
Expand Down
Binary file not shown.
Binary file not shown.
Loading

0 comments on commit 3690d8b

Please sign in to comment.