Mike Slinn
Mike Slinn

Reputation: 8407

SBT subproject test classpath mystery

I am currently working with two SBT subprojects: persistence and silhouette, which dependsOn persistence. I am having a problem with the silhouette test classpath.

The persistence tests run fine. That subproject declares some classes in the model.persistence package. The silhouette subproject defines additional classes in the same package. Those additional classes are not resolved by other classes in the silhouette subproject when running tests.

Most of the errors are like:

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 }

I can see the Twirl views and routes in the silhouette subproject are generated. They are not picked up by the silhouette subproject, which is weird.

Here are the SBT subproject definitions:

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 that demonstrates the problem.

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

Upvotes: 1

Views: 95

Answers (1)

Mike Slinn
Mike Slinn

Reputation: 8407

The only thing wrong with the project definition was a missing dependency in the silhouette subproject. The error messages did not make that super clear until I tried to run SBT console on the problem subproject:

$ 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...

Upvotes: 0

Related Questions