Nefron
Nefron

Reputation: 709

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.

Upvotes: 22

Views: 8557

Answers (4)

jpllosa
jpllosa

Reputation: 2202

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.

Upvotes: 1

nemoo
nemoo

Reputation: 3319

  1. Run 'play eclipse' on the command line
  2. In Eclipse, refresh your Project via hitting F5

Upvotes: 4

Iulian Dragos
Iulian Dragos

Reputation: 5712

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

Upvotes: 5

ndeverge
ndeverge

Reputation: 21564

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.

Upvotes: 6

Related Questions