对于Play 2.3 Scala项目,我有一个非常经典的build.sbt
,其中包含以下libraryDependencies
设置:
libraryDependencies ++= Seq(
"org.scalatestplus" % "play_2.10" % "1.1.0" % "test"
"org.mockito" % "mockito-core" % "1.9.5" % "test"
)
lazy val portal = (project in file(".")).enablePlugins(PlayScala)
PlayScala
插件添加了specs2
依赖关系"污染" classpath并且在IDE中更难以导入。
如何从libraryDependencies
删除依赖项?
答案 0 :(得分:10)
我通过在Build.scala
添加以下内容解决了类似的问题:
def excludeSpecs2(module: ModuleID): ModuleID =
module.excludeAll(ExclusionRule(organization = "org.specs2"))
val main = Project(appName, file("."))
.enablePlugins(play.PlayScala)
.settings(libraryDependencies ~= (_.map(excludeSpecs2)))
答案 1 :(得分:7)
我成功了。感谢Venkat,我知道排除,但由于我没有自己声明依赖,我不知道在哪里使用它。
这很简单:自己重新声明插件添加的依赖:
libraryDependencies ++= Seq(
"org.scalatestplus" % "play_2.10" % "1.1.0" % "test",
"org.mockito" % "mockito-core" % "1.9.5" % "test",
"com.typesafe.play" %% "play-test" % play.core.PlayVersion.current % "test" exclude("org.specs2", "specs2-core_2.10") exclude("org.specs2", "specs2-junit_2.10") exclude("org.specs2", "specs2-mock_2.10") exclude("org.specs2", "specs2-matcher-extra_2.10") exclude("org.specs2", "") exclude("com.novocode", "junit-interface") exclude("com.google.guava", "guava") exclude("com.google.code.findbugs", "jsr305")
)
也许不是很优雅,但它有效。