v5.0 breaks Play Java apps when using pure Eclipse
mkurz opened this issue · 3 comments
@benmccann you did release v5.0 a couple of days a ago which breaks Play projects when imported in pure Eclipse IDE (not ScalaIDE).
For reproduction:
activator new myApp
- Choose
play-java
- Add to
project/plugins.sbt
:
addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "5.0.0")
- Add to
build.sbt
(like described in the Play docs here):
// Compile the project before generating Eclipse files, so that generated .scala or .class files for views and routes are present
EclipseKeys.preTasks := Seq(compile in Compile)
EclipseKeys.projectFlavor := EclipseProjectFlavor.Java // Java project. Don't expect Scala IDE
EclipseKeys.createSrc := EclipseCreateSrc.ValueSet(EclipseCreateSrc.ManagedClasses, EclipseCreateSrc.ManagedResources) // Use .class files instead of generated .scala files for views and routes
- Now run
activator eclipse
and afterwards import the project into Eclipse (I use latest Neon.1)
Result
You will get various errors that scala.*
packages/classes can't be resolved.
That's because sbteclipse generates a .classpath
file which tells the IDE to use a bundled Scala container - which actually is intended for ScalaIDE, Eclipse doesn't come with Scala.
Workaround
In build.sbt
set
EclipseKeys.withBundledScalaContainers := false // Don't use scala bundle that comes with ScalaIDE
Now these lines from the "broken" .classpath
file
<classpathentry kind="con" path="org.scala-ide.sdt.launching.SCALA_CONTAINER"/>
become
<classpathentry sourcepath="/home/mkurz/.ivy2/cache/org.scala-lang/scala-library/srcs/scala-library-2.11.8-sources.jar" kind="lib" path="/home/mkurz/.ivy2/cache/org.scala-lang/scala-library/jars/scala-library-2.11.8.jar">
This specific withBundledScalaContainers
setting wasn't necessary in v4.0 and therefore also isn't documented in the Play docs.
For me it seems this line causes the problem.
@benmccann Should we update the Play docs (referenced above) to also include the withBundledScalaContainers := false
setting or is this something which should be fixed in sbteclipse?
Hmm, yeah, this sounds like a bug in sbteclipse where the default of withBundledScalaContainers
is no longer being correctly set. Thanks for the detailed report
5.0.1 released with the fix
That was fast, thanks!