如何获取SBT中已解析的ModuleID的文件系统上的完整类路径? [英] How to get full class path on file system for resolved ModuleID in SBT?
问题描述
如何将人工制品从libraryDependencies传递到dependencyClasspath中已解析的类路径?
How to corellate artifact from libraryDependencies to its resolved classpath in dependencyClasspath?
UPD
澄清问题:如何在文件系统上获取完整的类路径以获取已解析的ModuleID?
Clarify question: How to get full class path on file system for resolved ModuleID?
示例:
我有ModuleID: org.eclipse.jetty% jetty-servlets%V.jetty
I have ModuleID: "org.eclipse.jetty" % "jetty-servlets" % V.jetty
我想知道该类路径是: C:\Users\user\.ivy2\cache\org.eclipse.jetty\jetty-servlets\jars\jetty- servlets-8.1.8.v20121106.jar
And I want to knpw that classpath is: C:\Users\user\.ivy2\cache\org.eclipse.jetty\jetty-servlets\jars\jetty-servlets-8.1.8.v20121106.jar
推荐答案
您可以将任务添加到 build.sbt
,然后用 printDependencyClasspath
You can add a task to your build.sbt
and then call it with printDependencyClasspath
val printDependencyClasspath = taskKey[Unit]("Prints location of the dependencies")
printDependencyClasspath := {
val cp = (dependencyClasspath in Compile).value
cp.foreach(f => println(s"${f.metadata.get(moduleID.key)} => ${f.data}"))
}
这篇关于如何获取SBT中已解析的ModuleID的文件系统上的完整类路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!