In this post I'll explain how I managed to setup Eclipse for a Play 2.0 beta application.
Guillaume Bort has already announced eclipsify/netbeansify/idealize support to be the next thing on his todo list.
So fortunately we will be saved from this manual configuration in the near future.
I expect that you have a working Play 2.0 installation to start with.
Note that the file locations starting with "application" are relative to your Play 2.0 application.
Locations starting with "play" are relative to your Play 2.0 installation.
Step 1 - new application and sbteclipse
Execute play new application and follow the instructions.
I will be configuring a Java application so I choose option 2.
Now open the file "application\projectplugins.sbt" and add the following lines to the bottom:
resolvers += Classpaths.typesafeResolver
addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse" % "1.4.0")
According to the sbteclipse documentation it is necessary to include the two blank lines. I didn't test whether that's true or not, just included them.
Now cd application and run play to enter the Play 2.0 shell.
Type run to start the application and check localhost:9000 in your browser to check if it is working fine. Stop the server with Ctrl + D.
Step 2 - generate eclipse project and import it
We are in the play shell and execute the eclipse command to generate the eclipse project files. Ok, that was easy!
Now import the eclipse project into eclipse (File -> Import... -> Existing Projects into Workspace) select the application folder and finish.
When you explore the project you will notice Eclipse complaining about a couple of things that can't be found or built.
Step 3 - fix eclipse project setup
There are some settings that need to be modified in Project -> Properties -> Java Build Path.
First go to the tab-sheet Source, there is a duplicate entry for app, so we remove it. However when we remove one and click OK, the other will disappear too!!
So we have to add the "app" folder to Source again.
Now go to the tab-sheet Libraries and Add External JAR "play\repository\local\org.scala-lang\scala-library\2.9.1\jars\scala-library.jar".
We will also Add Class Folder "target\scala-2.9.1\classes" and "target\scala-2.9.1\classes_managed".
The last thing we do is go to the library "play_2.9.1.jar" in the library list, fold it open and click on source attachment and select the folder "play/framework/play/src/main/java".
Now you should have a minimal Play 2.0 application setup in Eclipse, have fun!