0
我無法將測試依賴關係打包到我的測試程序集jar中。下面是我的build.sbt
的摘錄:如何在sbt-assembly jar中包含測試依賴關係?
...
name := "project"
scalaVersion := "2.10.6"
assemblyOption in (Compile, assembly) := (assemblyOption in (Compile, assembly)).value.copy(includeScala = false)
fork in Test := true
parallelExecution in IntegrationTest := false
lazy val root = project.in(file(".")).configs(IntegrationTest.extend(Test)).settings(Defaults.itSettings: _ *)
Project.inConfig(Test)(baseAssemblySettings)
test in (Test, assembly) := {}
assemblyOption in (Test, assembly) := (assemblyOption in (Test, assembly)).value.copy(includeScala = false, includeDependency = true)
assemblyJarName in (Test, assembly) := s"${name.value}-test.jar"
fullClasspath in (Test, assembly) := {
val cp = (fullClasspath in Test).value
cp.filter{ file => (file.data.name contains "classes") || (file.data.name contains "test-classes")} ++ (fullClasspath in Runtime).value
}
libraryDependencies ++= Seq(
...
"com.typesafe.play" %% "play-json" % "2.3.10" % "test" excludeAll ExclusionRule(organization = "joda-time"),
...
)
...
當我使用組裝我的sbt test:assembly
脂肪罐子,是產生脂肪罐子project-test.jar
,但沒有被打包在play-json
依賴關係:
$ jar tf /path/to/project-test.jar | grep play
$
然而,如果我從play-json
dep(即"com.typesafe.play" %% "play-json" % "2.3.10" excludeAll ExclusionRule(organization = "joda-time")
)中刪除"test"
配置,我可以看到它包含在內:
$ jar tf /path/to/project-test.jar | grep play
...
play/libs/Json.class
...
$
我是否做錯了什麼和/或錯過了什麼?在這裏,我的目標是包括僅在test:assembly
罐子play-json
庫,而不是assembly
罐子