如何配置playframework-2.1应用程序build.scala文件以生成使用scalanature而不是javanature的eclipse项目?
val mainLang = if (dependencies.contains(javaCore)) JAVA else SCALA这意味着如果我在依赖中有javaCore,我就会得到一个JAVA项目。我试图删除对javaCore的依赖,但我遇到了编译错误。
有什么建议吗?
发布于 2014-02-18 03:32:04
我设法配置了一个播放框架项目,
使用java和scala的
在eclipse
该脚本如下所示
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)
}我还需要向一些模板添加以下导入,因为defaultScalaTemplatesImport与https://github.com/playframework/playframework/blob/b4006e9dbecaca6f8257a209f7d0fdc6e0345b48/framework/src/sbt-plugin/src/main/scala/PlayKeys.scala中的defaultJavaTemplatesImport不同
@import play.mvc.Http.Context.Implicit._
@import scala.collection.JavaConversions._
@import scala.collection.JavaConverters._发布于 2014-02-20 10:58:18
在您的plugins.sbt中添加以下Sbt eclipse插件
addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "2.3.0")
在play控制台中,键入"eclipse“并按回车键。
看看SBTEclipse plugin吧。我看到你已经在使用最新版本的Play了。我建议你试试typesafe中的‘激活器’。
https://stackoverflow.com/questions/21837199
复制相似问题