![](/img/trans.png)
[英]Unable to find the document downloaded from google drive API, where is it?
[英]where to find downloaded library of sbt?
sbt 將下載的 jar 放在哪里? 我試圖讓 sbt 下載所有依賴項並將它們放在 lib/ 目錄下,以便我可以將它們與 ScalaIDE 一起使用,但是在我成功運行sbt compile
之后,我不知道在哪里可以找到這些下載的 .jar
默認情況下,所有新的 SBT 版本( 0.7.x
之后)將下載的 JARS 放入主目錄的.ivy2
目錄中。
如果您使用的是 Linux,這通常是/home/<username>/.ivy2/cache
。
如果您使用的是 Windows,這通常是c:\Users\<username>\.ivy2\cache
。
編輯:
這是我的一個項目中的一個示例,我在其中定義了一個 SBT 任務,它將依賴項復制到目標文件夾中。 您可以將此代碼放入您的project/Build.scala
項目定義文件中。 您的項目定義文件中應該有類似的內容(更多信息請訪問 www.scala-sbt.org):
import sbt._
import Keys._
import Process._
object MyProjectBuild extends Build {
以下代碼通過定義捕獲程序工件及其所有類路徑依賴項的deploy
任務將所有庫復制到deploy/libz
子目錄:
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)
我從http://mvnrepository.com/找到了 sbt 依賴項
例如,您要查找MySQL Java Connector
,您可以在搜索框中搜索,然后選擇您喜歡的版本,然后您將看到sbt
標簽:
libraryDependencies += "mysql" % "mysql-connector-java" % "5.1.34"
如果你想找到下載的 jars,在 windows 中是C:\Users\<userName>\.ivy2\cache
在 linux 中是~/.ivy2/cache
祝你好運
下面的參考對 sbt 很有用。
https://www.scala-sbt.org/1.x/docs/Launcher-Configuration.html
你可以發現 sbt.ivy.home 是參數,默認是 ${user.home}/.ivy2/。
...
[存儲庫] 本地 typesafe-ivy-releases: http ://repo.typesafe.com/typesafe/ivy-releases/,[組織]/[模塊]/[修訂]/[類型]s/artifact.[ext], bootOnly maven-central sonatype-snapshots: https ://oss.sonatype.org/content/repositories/snapshots
【啟動】目錄:${sbt.boot.directory-${sbt.global.base-${user.home}/.sbt}/boot/}
[ivy] ivy-home: ${sbt.ivy.home-${user.home}/.ivy2/}
...
在最近的版本(1.3+)中, sbt
已經切換到 Coursier 而不是 Ivy 來獲取依賴項。
Coursier 緩存因操作系統而異。 根據鏈接的文檔,默認值為:
- 在 Linux 上,~/.cache/coursier/v1
- 在 OS X 上,~/Library/Caches/Coursier/v1.
- 在 Windows 上,%LOCALAPPDATA%\Coursier\Cache\v1
您還可以從 SBT 內部使用show csrCacheDirectory
找到該值。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.