单一依赖的jar复制到通过build.sbt一个文件夹 [英] Copy a single dependency jar into a folder via build.sbt

查看:221
本文介绍了单一依赖的jar复制到通过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屋!

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