单一依赖的jar复制到通过build.sbt一个文件夹 [英] Copy a single dependency jar into a folder via build.sbt
问题描述
在阶段
的任务,我想 SBT
抢在 NewRelic的从常青藤回购罐子并将其复制到一个文件夹。理想情况下,罐子被配置以同样的方式依赖关系,但不一定在 libraryDependencies
SEQ
本身(因为它不是构建或运行时依赖)。
During the stage
task, I'd like sbt
to grab the newrelic jar from the ivy repos and copy it into a folder. Ideally, the jar is configured the same way dependencies are, but not necessarily within the libraryDependencies
Seq
itself (as it's not a build or runtime dependency).
推荐答案
您可以宣布一个新的配置舞台
。你可以 libraryDependencies
设置为在配置所需的值。后来你的段
任务可以读取,更新,报告和文件复制到所需的目录。
You could declare a new configuration Stage
. You could set libraryDependencies
to the desired value in that configuration. Later your stage
task could read update report and copy the files to the desired directory.
val stage = taskKey[Unit]("Stage task")
val Stage = config("stage")
val root = project.in(file(".")).configs(Stage).settings( inConfig(Stage)(Classpaths.ivyBaseSettings): _* )
libraryDependencies in Stage := Seq("com.newrelic.agent.java" % "newrelic-api" % "3.7.0")
stage := {
(update in Stage).value.allFiles.foreach { f =>
IO.copyFile(f, baseDirectory.value / f.getName)
}
}
您可以检出在我的GitHub库工作的例子一>
You can checkout a working example in my github repository
这篇关于单一依赖的jar复制到通过build.sbt一个文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!