如何在 SBT 中获取内部项目依赖 jar 路径 [英] how to get internal project dependency jar path in SBT

查看:47
本文介绍了如何在 SBT 中获取内部项目依赖 jar 路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在 SBT 中实现自定义部署任务,我需要将所有必需的 jar 复制到部署文件夹.我能够使用 update TaskKey 获取所有外部依赖项的路径.不幸的是 updateReport 不包含内部依赖项.这是我的简单配置

I am implementing custom deploy Task in SBT and I need to copy all required jars to deployment folder. I am able to get paths to all external dependencies using update TaskKey. Unfortunately updateReport does not include internal dependencies. Here is my simple configuration

val deploy = TaskKey[Unit]("deploy","deploy")

lazy val projectA = Project(id=project-a,
settings=Project.defaultSettings)

lazy val projectB = Project(id=project-b,
settings=Project.defaultSettings) dependsOn(projectA)

lazy val projectC = Project(id=project-c,
settings=Project.defaultSettings, ++ Seq(deployTask)) dependsOn(projectB)

val deployTask = deploy <<= (update) map {(updateReport) =>
val externalDependency = updateReport.allFiles //paths to all external dependencies are available here
//project-a.jar and project-b.jar are not here
}

所以,问题是如何获取内部项目依赖项的绝对路径,即 project-a.jar、project-b.jar

So, the question is how can I obtain absolute path to internal project dependencies i.e. project-a.jar, project-b.jar

推荐答案

如果你设置了 exportJars 属性:

If you set the exportJars property:

exportJars := true

然后

exportedProducts in Compile

应该给你一个项目的 jar 文件的路径:

Should give you the path to the jar file for a project:

> show export-jars
[info] true
> show exported-products
[info] List(Attributed(/Users/luke/Work/myproject/server/target/scala-2.9.2/server_2.9.2-0.3-SNAPSHOT.jar))
[success] Total time: 0 s, completed Oct 5, 2012 11:29:51 PM

这篇关于如何在 SBT 中获取内部项目依赖 jar 路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆