在哪里可以找到下载的sbt库?
sbt把下载的jar放在哪里? 我试图让sbt下载所有依赖项并将它们放在lib /目录下,这样我就可以将它们与ScalaIDE一起使用,但是在我成功运行sbt compile
之后我不知道在哪里可以找到这些下载的.jars
默认情况下,所有新的SBT版本(在0.7.x
之后)将下载的.ivy2
放入.ivy2
目录中的.ivy2
目录中。
如果您使用的是Linux,通常是/home/
。
如果您使用的是Windows,通常是c:\Users\
。
编辑:
这是我的一个项目的示例,其中我定义了一个将依赖项复制到目标文件夹的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"
如果你想找到下载的jar,在windows中是C:\Users\
在linux中是~/.ivy2/cache
祝好运
以下参考对于sbt非常有用。
https://www.scala-sbt.org/1.x/docs/Launcher-Configuration.html
你可以找到sbt.ivy.home是参数,默认是$ {user.home} / .vy2 /。
…
[repositories] local typesafe-ivy-releases: http : //repo.typesafe.com/typesafe/ivy-releases/ , [organization] / [module] / [revision] / [type] s / artifact。[ext], bootOnly maven-central sonatype-snapshots: https ://oss.sonatype.org/content/repositories/snapshots
[boot]目录:$ {sbt.boot.directory – $ {sbt.global.base – $ {user.home} / .sbt} / boot /}
[常春藤]常春藤之家:$ {sbt.ivy.home – $ {user.home} /。ivy2 /}
…