访问sbt子项目的managedClasspath

时间:2012-04-23 15:00:29

标签: sbt

我正在将sbt 0.7.x构建脚本转换为sbt 0.11.2。我正在编写一个任务,从子项目中收集各种JAR。在旧版本中,部分任务执行以下操作:

deployedProjects.foreach {
  p: BasicScalaProject =>
    p.managedClasspath(config("compile")) --- p.managedClasspath(config("provided"))
    // etc
}

如何在sbt 0.11中执行等效操作?

已更新以添加:

特别是:

  • 如何编写依赖于设置/任务列表的任务?例如,我如何编写一个依赖于子项目列表中所有managedClasspaths的任务(不将它们全部捆绑到一个元组中)。
  • 是否有特定的范围来获取或未标记为“已提供”的托管jar?

1 个答案:

答案 0 :(得分:0)

在sbt 0.11.x中有任务managedClasspath:

> inspect managed-classpath
[info] Task: scala.collection.Seq[sbt.Attributed[java.io.File]]
[info] Description:
[info]  The classpath consisting of external, managed library dependencies.
[info] Provided by:
[info]  {file:/Users/heiko/tmp/test/}default-f3fb6c/compile:managed-classpath
[info] Dependencies:
[info]  compile:classpath-configuration
[info]  compile:classpath-types
[info]  compile:update
[info] Reverse dependencies:
[info]  compile:external-dependency-classpath
[info] Delegates:
[info]  compile:managed-classpath
[info]  *:managed-classpath
[info]  {.}/compile:managed-classpath
[info]  {.}/*:managed-classpath
[info]  */compile:managed-classpath
[info]  */*:managed-classpath
[info] Related:
[info]  test:managed-classpath
[info]  runtime:managed-classpath

查看代表,您会发现可以将此任务范围扩展到各种配置,例如编译

> show compile:managed-classpath
[info] Updating {file:/Users/heiko/tmp/test/}default-f3fb6c...
[info] Resolving org.scala-lang#scala-library;2.9.1 ...
[info] Done updating.
[info] ArraySeq(Attributed(/Users/heiko/.sbt/boot/scala-2.9.1/lib/scala-library.jar))