I\'ve created a play project with play 2.3.7
In the project directory, I ran activator and ran the eclipse
command to generate eclipse project files.
Basically we need a way to put the compiled classes on the path for this to work.
I did the following to fix it.
Since the projects compiles to the target
directory.
I went to the Project Properties
-> Java Build Path and added a few folders that look like this,
target/scala-2.12/routes/main target/scala-2.12/twirl target/scala-2.12/twirl/main
Now i dont want you to assume you will have these exact folders in your case too. That depends on your project setup. But you should add the folders inside the target/scala-2.x folder.
Adding target/scala-2.11/twirl/main
which is having views.html
package to source fixed for me.
1) Add the following line to your sbt.build file:
EclipseKeys.preTasks := Seq(compile in Compile)
2) Add the follwing line to your plugins.sbt file under the project folder:
addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "5.1.0")
3) Run the "eclipse" command from within sbt
as explained in the documentation of the play framework:
Setting up your preferred IDE
The other solutions did not work for me. Some would give me different errors, some would clear the Problems tab but leave me with a red squiggle under views.html.index
and auto-complete would not work with the scala.html templates.
What finally worked was to open the project's properties, go to Java Build Path > Source
, and add both of the following directories:
target/scala-2.11/src_managed/main
target/scala-2.11/twirl/main
If you only do target/scala-2.11/twirl/main
then you'll miss out on the class files generated from the conf
directory.
I had the same issue running Play 2.4.0-RC1 using default SBT layout (disablePlugins(PlayLayoutPlugin)
) and solved it by adding to build.sbt
:
sourceDirectories in (Compile, TwirlKeys.compileTemplates) :=
(unmanagedSourceDirectories in Compile).value