2014-02-17 61 views
0

如何配置playframework-2.1应用程序build.scala文件来生成一个带有scalanature而不是javanature的eclipse项目?在Eclipse中玩2.1应用程序作为scala项目(而不是java项目)

我发现这个代码(https://github.com/playframework/playframework/blob/2.1.x/framework/src/sbt-plugin/src/main/scala/play/Project.scala

val mainLang = if (dependencies.contains(javaCore)) JAVA else SCALA 

这表明,如果我在相关性具有的javacore我会得到一个Java项目。 我试图删除javaCore上的依赖关系,但我有编译错误。

有什么建议吗?

回答

0

我好不容易才能够配置一个playframework项目中使用Java和Scala源

  • 产生Scala的性质Eclipse项目
  • 使用playframework - 2.1正常编译在Eclipse
    • .x

    脚本如下

    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) 
    
    } 
    

    我还需要添加一些模板以下进口自defaultScalaTemplatesImporthttps://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._ 
    
  • 0

    defaultJavaTemplatesImport不同添加以下SBT eclipse插件在plugins.sbt

    addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "2.3.0")

    从播放控制台输入“eclipse”并按回车。

    看看SBTEclipse plugin。我看到你已经在使用最新版本的Play。我可以建议你尝试从类型安全的'激活'。

    相关问题