如何访问所有 sbt Setting[T] 的映射或任何包含所有设置依赖项的容器?
我想将它们全部以及它们的依赖项打印出来。输出应如下所示:
setting(ScopedKey(Scope(Select(ThisBuild),Global,Global,Global),managed-directory))
ScopedKey(Scope(Select(ThisBuild),Global,Global,Global),base-directory)
ScopedKey(Scope(Select(ThisBuild),Global,Global,Global),this-project)
...
下面是我用来执行此操作的 SBT 构建定义。
this-project
并非在所有设置中都找到该密钥。它存储在哪里?
import sbt._
import sbt.Logger
import Keys._
import PlayProject._
object TheBuild extends Build {
lazy val howItWorksProject = Project(
id = "howItWorks",
base = file("./modules/howItWorks")
)
val projDef: ProjectDefinition[_] = howItWorksProject
var count = 0
def printSettingsDependencies(setting: Setting[_], settings: Seq[Setting[_]], indent: String): Unit = {
println("debug printSettingsDependencies start" + (count+=1))
println(setting)
println("debug setting =" + setting)
println("debug setting.dependencies = " + setting.dependencies)
setting.dependencies.foreach {
n =>
println("debug it = " + n)
println("debug finding ...")
val settingOption = settings.find {
it =>
println("\t"+it.key.key.label + "?=" + n.key.label)
it.key.key.label == n.key.label
}
println("debug found = "+settingOption)
println(indent + settingOption)
printSettingsDependencies(settingOption.get, settings, indent + indent)
}
}
}
inspect this-project
输出:
> inspect this-project
[info] Setting: sbt.ResolvedProject = Project(id: howItWorks, base: C:\Users\pawel\workspace\kody\ria-template\modules\howItWorks, aggregate: List(), dependencies: List(), delegates: List(), configurations: List(compile, runtime, test, provided, optional))
[info] Description:
[info] Provides the current project for the referencing scope.
[info] Provided by:
[info] {file:/C:/Users/pawel/workspace/kody/ria-template/}howItWorks/*:this-project
[info] Reverse dependencies:
[info] *:ivy-configurations
[info] *:base-directory
[info] *:name
[info] Delegates:
[info] *:this-project
[info] {.}/*:this-project
[info] */*:this-project
inspect base-directory
输出:
> inspect base-directory
[info] Setting: java.io.File = C:\Users\pawel\workspace\kody\ria-template\modules\howItWorks
[info] Description:
[info] The base directory. Depending on the scope, this is the base directory for the build, project, configuration, or task.
[info] Provided by:
[info] {file:/C:/Users/pawel/workspace/kody/ria-template/}howItWorks/*:base-directory
[info] Dependencies:
[info] *:this-project
[info] Reverse dependencies:
[info] *:ivy-paths
[info] *:target
[info] *:unmanaged-base
[info] *:runner
[info] *:source-directory
[info] Delegates:
[info] *:base-directory
[info] {.}/*:base-directory
[info] */*:base-directory
[info] Related:
[info] {.}/*:base-directory
show sbt-version
> show sbt-version
[info] 0.11.3