how to get internal project dependency jar path in SBT

99封情书 提交于 2020-01-14 19:06:25

问题


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
}

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


回答1:


If you set the exportJars property:

exportJars := true

then

exportedProducts in Compile

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


来源:https://stackoverflow.com/questions/12728809/how-to-get-internal-project-dependency-jar-path-in-sbt

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!