where to find downloaded library of sbt?(在哪里可以找到下载的 sbt 库?)
问题描述
sbt把下载的jar放在哪里?我试图让 sbt 下载所有依赖项并将它们放在 lib/目录下,以便我可以将它们与 ScalaIDE 一起使用,但是在我成功运行 sbt compile
之后,我不知道在哪里可以找到这些下载的.jars
Where does sbt put the downloaded jar? I'm trying to ask sbt to download all dependencies and put them under lib/ directory so I can use them with the ScalaIDE, however after I ran sbt compile
successfully I don't know where to find these downloaded .jars
推荐答案
所有新的 SBT 版本(0.7.x
之后)默认将下载的 JARS 放入 .ivy2
主目录中的目录.
All new SBT versions (after 0.7.x
) by default put the downloaded JARS into the .ivy2
directory in your home directory.
如果您使用的是 Linux,这通常是 /home/
.
If you are using Linux, this is usually /home/<username>/.ivy2/cache
.
如果您使用的是 Windows,这通常是 c:Users<username>.ivy2cache
.
If you are using Windows, this is usually c:Users<username>.ivy2cache
.
这是我的一个项目中的一个示例,我在其中定义了一个将依赖项复制到目标文件夹中的 SBT 任务.您可以将此代码放入您的 project/Build.scala
项目定义文件中.您的项目定义文件中应该有类似的内容(更多信息请访问 www.scala-sbt.org):
Here's an example from one of my projects,
in which I define an SBT task that copies the dependencies into the target folder.
You can place this code into your project/Build.scala
project definition file.
You should have something like this in your project definition file (more info at www.scala-sbt.org):
import sbt._
import Keys._
import Process._
object MyProjectBuild extends Build {
以下代码将所有库复制到 deploy/libz
子目录,通过定义一个 deploy
任务来捕获您的程序工件及其所有类路径依赖项:
The following code copies all your libraries to a deploy/libz
subdirectory,
by defining a deploy
task that captures your program artifact and all its classpath dependencies:
val deployKey = TaskKey[Unit](
"deploy",
"Deploys the project in the `deploy` subdirectory."
)
val deployTask = deployKey <<= (artifactPath in (Compile, packageBin), dependencyClasspath in Compile) map {
(artifact, classpath) =>
val deploydir = new File("deploy")
val libzdir = new File("deploy%slib".format(File.separator))
// clean old subdirectory
deploydir.delete()
// create subdirectory structure
deploydir.mkdir()
libzdir.mkdir()
// copy deps and artifacts
val fullcp = classpath.map(_.data) :+ artifact
def lastName(file: File) = if (file.isFile) file.getName else file.getParentFile.getParentFile.getParentFile.getName
for (file <- fullcp) {
println("Copying: " + file + "; lastName: " + lastName(file))
if (file.isFile) IO.copyFile(file, (libzdir / lastName(file)).asFile);
else IO.copyDirectory(file, (libzdir / lastName(file)))
}
} dependsOn (packageBin in Compile)
这篇关于在哪里可以找到下载的 sbt 库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:在哪里可以找到下载的 sbt 库?
基础教程推荐
- 首次使用 Hadoop,MapReduce Job 不运行 Reduce Phase 2022-01-01
- 在螺旋中写一个字符串 2022-01-01
- 如何使用 Eclipse 检查调试符号状态? 2022-01-01
- 如何强制对超级方法进行多态调用? 2022-01-01
- Spring Boot Freemarker从2.2.0升级失败 2022-01-01
- 由于对所需库 rt.jar 的限制,对类的访问限制? 2022-01-01
- 如何在不安装整个 WTP 包的情况下将 Tomcat 8 添加到 Eclipse Kepler 2022-01-01
- 如何使用 Stream 在集合中拆分奇数和偶数以及两者的总和 2022-01-01
- Java 中保存最后 N 个元素的大小受限队列 2022-01-01
- 如何对 HashSet 进行排序? 2022-01-01