【问题标题】:Accessing managedClasspath of sbt subprojects访问 sbt 子项目的 managedClasspath
【发布时间】:2012-04-24 21:25:19
【问题描述】:

我正在将 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?

【问题讨论】:

    标签: sbt


    【解决方案1】:

    在 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))
    

    【讨论】:

    • 谢谢,但我仍然不确定如何实现我所追求的目标——我已将问题更新为更准确。
    猜你喜欢
    • 2013-01-21
    • 1970-01-01
    • 1970-01-01
    • 2017-10-17
    • 1970-01-01
    • 2016-06-03
    • 2017-02-28
    • 2019-07-28
    • 2018-03-13
    相关资源
    最近更新 更多