我希望在每个配置的基础上使用不同的libraryDependencies编译和测试我的项目
即
如果我运行partial:compile
任务,应该有一组依赖项
如果仅运行compile
或test
,则另一套..
我尝试在下面的简化列表中使用inConfig
,但它似乎没有做到这一点,因为来自fullDeptsSettings
的依赖关系仍然存在。可以在inspect partial:libraryDependencies
import sbt.Keys._
import sbt.{Build, Defaults, _}
object DummyBuild extends Build {
lazy val PartialConfig = config("partial") extend Compile
val fullDepts = Seq (
"my" % "customLib" % "1.0",
"my" % "anotherLib" % "1.0"
)
val partialDepts = Seq("my" % "anotherLib" % "1.0")
private val defaultSettings = Defaults.coreDefaultSettings
private val partialDeptsSettings = libraryDependencies ++= partialDepts
private val fullDeptsSettings = libraryDependencies += fullDepts
lazy val api = Project("dummy", file("."))
.configs(PartialConfig)
.settings(defaultSettings: _*)
.settings(fullDeptsSettings)
.settings(inConfig(PartialConfig)(partialDeptsSettings):_*)
}