Skip to content

Instantly share code, notes, and snippets.

@richdougherty
Created December 11, 2013 22:46
Show Gist options
  • Save richdougherty/7919917 to your computer and use it in GitHub Desktop.
Save richdougherty/7919917 to your computer and use it in GitHub Desktop.
val PlayBaseDirProp = Tags.Tag("PlayBaseDirProp")
concurrentRestrictions in Global += Tags.limit(PlayBaseDirProp, 1)
def withSystemProperty[T](name: String, value: String)(f: => T) = {
println(s"*** Setting property $name = $value")
System.setProperty(name, value)
try {
f
} finally {
println(s"*** Clearing property $name")
System.clearProperty(name)
}
}
def withPlayBaseDirProp[T](taskKey: TaskKey[T]) = {
println(s"*** Running ${taskKey}")
def taggedPropTask = Def.task {
withSystemProperty("play.base.dir", baseDirectory.value.toString) {
taskKey.value
}
} tag(PlayBaseDirProp)
taskKey := taggedPropTask.value
}
lazy val s = playJavaSettings ++ Seq(jacoco.settings:_*) ++ jacocoSettings
val commonDependencies = Seq(
javaCore
)
val common = play.Project(
"common", appVersion, commonDependencies, settings = s, path = file("modules/common")
).settings(
//Keys.fork in Test := false,
javaOptions in Test += s"-Dplay.base.dir=${baseDirectory.value}",
withPlayBaseDirProp(executeTests in jacoco.Config),
withPlayBaseDirProp(jacoco.cover in jacoco.Config),
withPlayBaseDirProp(jacoco.report in jacoco.Config),
withPlayBaseDirProp(jacoco.check in jacoco.Config),
withPlayBaseDirProp(test in jacoco.Config)
)
[common] $ reload
[info] Loading global plugins from /Users/rich/.sbt/0.13/plugins
[info] Loading project definition from /p/play/support/d2674/play-multi-project-jacoco/project
*** Running sbt.Scoped$$anon$2@1d512e77
*** Running sbt.Scoped$$anon$2@3cc195aa
*** Running sbt.Scoped$$anon$2@4948eb0f
*** Running sbt.Scoped$$anon$2@52404b5f
*** Running sbt.Scoped$$anon$2@7b147428
[info] Set current project to common (in build file:/p/play/support/d2674/play-multi-project-jacoco/)
[common] $ jacoco:test
[info] IntegrationTest
[info] + test
[info]
[info]
[info] Total for test IntegrationTest
[info] Finished in 2.404 seconds
[info] 1 tests, 0 failures, 0 errors
[info] ApplicationTest
[error] Test ApplicationTest.workingDirectoryShouldBeConstant failed: java.lang.NullPointerException: The play.base.dir property must be set so that relative paths can be resolved.
[error] at ApplicationTest.relativeToBaseDir(ApplicationTest.java:27)
[error] at ApplicationTest.workingDirectoryShouldBeConstant(ApplicationTest.java:47)
[error] ...
[info] + simpleCheck
[info] x workingDirectoryShouldBeConstant
[info] + renderTemplate
[info]
[info]
[info] Total for test ApplicationTest
[info] Finished in 0.008 seconds
[info] 3 tests, 1 failures, 0 errors
*** Setting property play.base.dir = /p/play/support/d2674/play-multi-project-jacoco/modules/common
*** Clearing property play.base.dir
[error] Failed: Total 4, Failed 1, Errors 0, Passed 3
[error] Failed tests:
[error] ApplicationTest
[error] (common/jacoco:test) sbt.TestsFailedException: Tests unsuccessful
[error] Total time: 3 s, completed 12/12/2013 11:39:09 AM
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment