Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make Eclipse see the changes in Play! compiled templates?

So, I'm trying out Play 2 with Eclipse. I create a new project, compile it, run eclipsify and import it into Eclipse. So far so good.

The problem I'm having is that when I make a change in the Scala template, my Java controllers can't see it, and Eclipse marks the code as invalid. For example:

I added a second parameter in my index template

@(message: String, nesto:Integer)

When I try to render my file from the controller, the following line displays an error, because Eclipse still thinks that the index.render takes one String.

return ok(index.render("Your new application is ready.",2));

I turned on the workspace refreshing in Eclipse, and play eclipsify automatically added the classes_managed directory to the build path.

like image 600
Nefron Avatar asked Apr 06 '12 11:04

Nefron


4 Answers

I did the following things :

  1. As you did, I turned on the workspace auto-refresh (in settings, General -> Workspace, then select "Refresh using native hooks or pooling")
  2. I removed the classes_managed directory generated by play eclipsify from my build path, and I added it manually using "Add external class folder"

And then it worked for me. It seems that there is a bug with the eclipsify command.

like image 173
ndeverge Avatar answered Oct 23 '22 10:10

ndeverge


The trick is to have Play building automatically in the background (template files are not currently built by Eclipse, so you need Play to translate those for you). It's all explained in detail here:

[dead link] http://scala-ide.org/docs/tutorials/play20scalaide20/index.html

[try this one] http://scala-ide.org/docs/tutorials/play/index.html#installing-the-scala-ide-play2-plug-in

like image 23
Iulian Dragos Avatar answered Oct 23 '22 09:10

Iulian Dragos


  1. Run 'play eclipse' on the command line
  2. In Eclipse, refresh your Project via hitting F5
like image 29
nemoo Avatar answered Oct 23 '22 11:10

nemoo


For Java Play Framework v2.4.6 (activator v1.3.7) with Eclipse Mars:

Instead of @(message: String, nesto:Integer) , have you tried this @(message: String)(nesto: Integer)?

So that you will not have a "can not resolve error" with your index.render(), you can add this <classpathentry kind="lib" path="target/scala-2.11/classes"/> to your .classpath or right-click on your project -> Build Path -> Configure Build Path -> Add Class Folder and make it point to target/scala-2.11/classes.

like image 41
jpllosa Avatar answered Oct 23 '22 11:10

jpllosa