首页 > 解决方案 > 从 shell 运行“sbt show subproject/dependencyClasspathAsJars”

问题描述

在我的多项目构建中,我可以列出我的一个子项目的所有依赖项:

$ sbt
[info] ...
sbt:MyProject> show subproject2/dependencyClasspathAsJars
/path/jar1:/path/jar2:...:/home/.../MyProject/build/subproject1.jar
sbt:MyProject>

但是,我需要在 CI 中运行它,但是......:

$ sbt show subproject2/dependencyClasspathAsJars                                                                          
[info] Loading global plugins from /home/.../plugins
[info] Loading project definition from /home/.../MyProject/project
[info] Loading settings for project MyProject from build.sbt,modules.sbt ...
[info] Set current project to MyProject (in build file:/home/.../MyProject/)
[error] Not a valid command: show (similar: shell)
[error] Expected whitespace character
[error] Not a valid project ID: show
[error] Expected ':'
[error] Not a valid key: show (similar: showTiming, sLog, ps)
[error] show
[error]     ^

要从(shell)命令行获取这个类路径,我应该怎么做?我正在使用 sbt 1.2.8 和 scala 2.10。

标签: scalasbt

解决方案


show dependencyClasspathAsJars需要作为单个参数传递给 sbt 。使用常见的外壳,这有效:

$ sbt "project subproject2" "show dependencyClasspathAsJars"

project subproject2选择您的子项目并show dependencyClasspathAsJars计算子项目上的任务。


推荐阅读