I managed to be able to configure a playframework project that is
- using java and scala sources
- generates eclipse project with scala natures
- compiles properly in eclipse
- using playframework-2.1.x
The script is the following
import sbt._
import Keys._
import play.Project._
object ApplicationBuild extends Build {
val appName = "darzaar"
val appVersion = "1.0-SNAPSHOT"
//play.Project.playScalaSettings - is available only in playframework-2.2.x
val appDependencies = Seq(
// added instead of javaCore
"play" %% "play-java" % "2.1.5",
"be.objectify" %% "deadbolt-java" % "2.1-RC2",
"be.objectify" %% "deadbolt-scala" % "2.1-RC2",
// Comment this for local development of the Play Authentication core
"com.feth" %% "play-authenticate" % "0.3.4-SNAPSHOT",
"postgresql" % "postgresql" % "9.1-901-1.jdbc4",
//javaCore, - commented to keep SCALA nature in eclipse
//javaJdbc,
jdbc,
javaEbean
)
import com.typesafe.sbteclipse.core.EclipsePlugin._
val main = play.Project(appName, appVersion, appDependencies)
//.settings(play.Project.playScalaSettings:_*)
.settings(
resolvers += Resolver.url("Objectify Play Repository (release)", url("http://schaloner.github.com/releases/"))(Resolver.ivyStylePatterns),
resolvers += Resolver.url("Objectify Play Repository (snapshot)", url("http://schaloner.github.com/snapshots/"))(Resolver.ivyStylePatterns),
resolvers += Resolver.url("play-easymail (release)", url("http://joscha.github.com/play-easymail/repo/releases/"))(Resolver.ivyStylePatterns),
resolvers += Resolver.url("play-easymail (snapshot)", url("http://joscha.github.com/play-easymail/repo/snapshots/"))(Resolver.ivyStylePatterns),
resolvers += Resolver.url("play-authenticate (release)", url("http://joscha.github.com/play-authenticate/repo/releases/"))(Resolver.ivyStylePatterns),
resolvers += Resolver.url("play-authenticate (snapshot)", url("http://joscha.github.com/play-authenticate/repo/snapshots/"))(Resolver.ivyStylePatterns)
// These keys wheren't used by sbt-eclipse when used in playframework
//,EclipseKeys.projectFlavor := EclipseProjectFlavor.Scala
//,PlayEclipse.mainLang := SCALA
)
// Uncomment this for local development of the Play Authenticate core:
// .dependsOn(playAuthenticate).aggregate(playAuthenticate)
}
I also needed to add to some templates the following imports since defaultScalaTemplatesImport
differ from the defaultJavaTemplatesImport
at https://github.com/playframework/playframework/blob/b4006e9dbecaca6f8257a209f7d0fdc6e0345b48/framework/src/sbt-plugin/src/main/scala/PlayKeys.scala
@import play.mvc.Http.Context.Implicit._
@import scala.collection.JavaConversions._
@import scala.collection.JavaConverters._