【问题标题】:Why PlayFramework only "eclipse" one sub module?为什么PlayFramework只有“eclipse”一个子模块?
【发布时间】:2014-01-09 03:24:35
【问题描述】:

使用 Play Framework 2.1.1-RC1,我将一个项目拆分为多个模块,如下所示:

object ApplicationBuild extends Build {

  val appName         = "Project"
  val appVersion      = "1.0"

  val appDependencies = Seq(
    // Add your project dependencies here,
    javaCore,
    javaJdbc,
    javaEbean,
    "mysql" % "mysql-connector-java" % "5.1.18"
  )

  lazy val common = play.Project(
    appName + "-common", appVersion, appDependencies, path = file("modules/common")
  ).settings(
    publishArtifact in(Compile, packageDoc) := false
  )

  lazy val website = play.Project(
    appName + "-website", appVersion, appDependencies, path = file("modules/website")
  ).dependsOn(common).aggregate(common).settings(
    requireJs += "app.js",

    publishArtifact in(Compile, packageDoc) := false
  )

  lazy val api = play.Project(
    appName + "-api", appVersion, appDependencies, path = file("modules/api")
  ).dependsOn(common).aggregate(common).settings(
    publishArtifact in(Compile, packageDoc) := false
  )

  val main = play.Project(appName, appVersion, appDependencies).settings(
    publishArtifact in(Compile, packageDoc) := false
  ).dependsOn(website, api).aggregate(website, api)
}

所以,当我调用play eclipse时,它应该使所有三个子模块都黯然失色,而是只编译第一个,你知道为什么吗?

这是游戏中的转储:

$ /opt/play/2.1.1-RC1/play eclipse
  [info] Loading project definition from /mnt/data/dev/perso/Project/project
  [info] Set current project to Project (in build file:/mnt/data/dev/perso/Project/)
  [info] About to create Eclipse project files for your project(s).
  [info] Updating {file:/mnt/data/dev/perso/Project/}Project-common...
  [info] Resolving org.hibernate.javax.persistence#hibernate-jpa-2.0-api;1.0.1.Fin                                                                                [info] Done updating.                                                        
  [info] Compiling 27 Java sources to /mnt/data/dev/perso/Project/modules/common/target/scala-2.10/classes...
  [info] Successfully created Eclipse project files for project(s):
  [info] Project-common
$

为什么?有什么原因吗?

如果我运行项目,一切正常,每个模块都正常工作。

我错过了什么?

【问题讨论】:

    标签: playframework playframework-2.1


    【解决方案1】:

    好吧,在来自 PlayFramework 的Google Group discussion 的@Stijn 的大力指示下,我找到了解决方案。

    使用PlayFramework documentation,您有两个选项来构建所有子模块:

    选项 1:

    进入play控制台,然后调用eclipse skip-parents=false

    $ /path/to/playframework/play
    [PlayProject] $ eclipse skip-parents=false
    

    警告! 在播放控制台之外这样做是行不通的:

    $ /path/to/playframework/play eclipse skip-parents=false
    > [error] Not a valid key: skip-parents (similar: ivy-paths)
    > [error] skip-parents=false
    

    选项 2:

    修改 Build.scala :

    import com.typesafe.sbteclipse.core.EclipsePlugin.EclipseKeys
    
    object ApplicationBuild extends Build {
    
      override def settings = super.settings ++ Seq(
          EclipseKeys.skipParents in ThisBuild := false
      )
    
      ...
    
    }
    

    别忘了导入 EclipseKeys!

    希望这会有所帮助!

    【讨论】:

    • 我在使用 .dependsOn(xy).aggregate(xy) 时才拥有这个
    【解决方案2】:

    如果你写的话,在播放控制台之外这样做会起作用:

    play "eclipse skip-parents=false"
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-02-22
      • 2013-03-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多