SBT子项目测试类路径之谜

时间:2016-07-29 23:14:13

标签: playframework-2.0 sbt

我目前正在使用两个SBT子项目:persistencesilhouettedependsOn persistence。我遇到了silhouette测试类路径的问题。

persistence测试运行正常。该子项目在model.persistence包中声明了一些类。 silhouette子项目在同一个包中定义了其他类。运行测试时,silhouette子项目中的其他类无法解析这些附加类。

大多数错误都是:

Error:(7, 31) object routes is not a member of package controllers.silhouette
import controllers.silhouette.routes.{ ActivateAccountController => ActivateRoutes, SignInController => SignInRoutes }
Error:(18, 19) object silhouette is not a member of package views.html
import views.html.silhouette.{ emails => htmlEmail }

我可以看到生成silhouette子项目中的Twirl视图和路由。它们没有被silhouette子项目选中,这很奇怪。

以下是SBT子项目定义:

lazy val silhouette: Project = project.in(file("modules/silhouette"))
  .configure(webappConfiguration)
  .dependsOn(persistence)
  .aggregate(persistence)
  .settings(
    libraryDependencies ++= silhouetteDependencies,
    javaOptions            += "-Dplay.http.router=silhouette.Routes",
    javaOptions in Runtime += "-Dconfig.file=../silhouette/conf/silhouette.application.conf",
    javaOptions in Test    += "-Dconfig.file=../silhouette/test/resources/test.silhouette.application.conf"
  )
addCommandAlias("testSilhouette", "; project silhouette; test")

lazy val persistence: Project = project.in(file("modules/persistence"))
  .configure(commonConfiguration)
  .settings(
    libraryDependencies ++= persistenceDependencies,
    javaOptions in Runtime += "-Dconfig.file=../model/src/main/resources/persistence.application.conf",
    javaOptions in Test    += "-Dconfig.file=../model/src/test/resources/test.model.application.conf"
  )

Here is a working project证明了这个问题。

$ sbt ";project persistence; test"  # works
$ sbt ";project silhouette; test"   # fails as described

1 个答案:

答案 0 :(得分:0)

项目定义唯一的错误是silhouette子项目中缺少依赖项。在我尝试在问题子项目上运行SBT控制台之前,错误消息并没有超级清晰:

$ sbt
[info] Loading global plugins from /home/mslinn/.sbt/0.13/plugins
[info] Loading project definition from /var/work/blah/project
[info] Set current project to Blah (in build file:/var/work/blah/)
[Blah] $ project silhouette
[info] Set current project to silhouette (in build file:/var/work/blah/)
[silhouette] $ console
... compilation errors appeared here...