21

I would like to use Eclipse as IDE for a Scala web application using Play Framework. I downloaded Eclipse 3.6.2. Then I installed Scala IDE 2.0 (beta) for Eclipse. I downloaded Play Framework 1.2.2RC1 and installed the Scala Module using play install scala-0.9.1 and generated a new site with play new mysite. Then I eclipsified it with play eclipsify mysite and imported the project in Eclipse.

But now I get many errors in Eclipse. Is this anything I can fix or are the different projects incompatible?

This is the generated code that contains errors in Eclipse (but it works when I run the application).

package controllers

import play._
import play.mvc._

object Application extends Controller {

  import views.Application._

    def index = {
        html.index("Your Scala application is ready to go home!")
    } 
}

And this is how it looks like in Eclipse:Scala Play application in Eclipse

Jonas
  • 97,987
  • 90
  • 271
  • 355

2 Answers2

19

The error shown highlighted in your screenshot is caused by the new Scala template sources not being in the project Build Path. The eclipsify command doesn't currently do this for you.

Manually add tmp/classes to the Build Path to resolve it.

But please note that new Scala template files are not generated from within Eclipse. So if you add a new template/page to your project, you must run 'play run' (or equivalent) first to have the file appear there. Also note that if you run the eclipsify command again in the future you will need to re-add this folder to your Build Path.

Community
  • 1
  • 1
Ike
  • 773
  • 1
  • 7
  • 14
  • I did this and the editor told me there were errors using those little red squigglies even though there were none reported in the Problems View. To get rid of these, I right-clicked on the editor and selected Preferences. In the dialog that appears, I unchecked "Report problems as you type". This removed the red squigglies from the editor window. – geowa4 Jun 17 '11 at 02:17
  • 1
    I had to add target/scala-2.10/classes – Mark Butler Jul 10 '13 at 02:18
5

It seems that eclipse thinks that your views package is empty. Did you try to refresh project via F5 command?

Nikolay Ivanov
  • 8,637
  • 3
  • 29
  • 33
  • 1
    Ah, thanks! Now I understand. The views package contains Scala Template files that probably are specific for Play Framework, and Scala IDE doesn't understand them. – Jonas May 31 '11 at 10:32
  • In eclipse I had to explicitly select the project name at the project explorer top, right click and hit 'refresh'. Hitting F5 didn't work for me. Also the play framework must have already compiled the view. – seand Jul 15 '13 at 21:05
  • Wow, just pressing F5 fixed everything, thanks so much – SobiborTreblinka Feb 12 '14 at 17:35