SBT 0.13.1离线

时间:2014-04-11 13:49:01

标签: scala sbt ivy

我试图了解离线使用SBT 0.13.1。我的目标是将任何必要的东西带到USB记忆棒上的离线环境中。我认为如果复制了常春藤缓存,那么SBT可以从中提取所需的一切,但事实并非如此。

例如......

我首先要删除.ivy2文件夹,以确定。现在,在线时我使用以下build.sbtproject/plugins.sbt文件来创建我的eclipse项目。来自SBT 0.13.1

build.sbt:

name := "TestProject"

version := "0.0.1"

scalaVersion := "2.10.3"

libraryDependencies ++= Seq(
    "org.apache.commons" % "commons-math3" % "3.2",
    "ch.qos.logback" % "logback-classic" % "1.1.1"
)

项目/ plugins.sbt:

addSbtPlugin("com.typesafe.sbteclipse" % "sbteclipse-plugin" % "2.4.0")

在我离线的同一个计算器上,现在sbt clean eclipse给出了许多未解决的依赖错误。 E.g。

[warn] Host repo1.maven.org not found. url=http://repo1.maven.org/maven2/org/scala-lang/scala-library/2.10.3/scala-library-2.10.3.pom
[info] You probably access the destination server through a proxy server that is not well configured.
[warn]  module not found: org.scala-lang#scala-library;2.10.3
[warn] ==== local: tried
[warn]   /home/user/.ivy2/local/org.scala-lang/scala-library/2.10.3/ivys/ivy.xml
[warn] ==== public: tried
[warn]   http://repo1.maven.org/maven2/org/scala-lang/scala-library/2.10.3/scala-library-2.10.3.pom
[info] Resolving ch.qos.logback#logback-classic;1.1.1 ...
[warn] Host repo1.maven.org not found. url=http://repo1.maven.org/maven2/ch/qos/logback/logback-classic/1.1.1/logback-classic-1.1.1.pom
[info] You probably access the destination server through a proxy server that is not well configured.
[warn]  module not found: ch.qos.logback#logback-classic;1.1.1
[warn] ==== local: tried
[warn]   /home/user/.ivy2/local/ch.qos.logback/logback-classic/1.1.1/ivys/ivy.xml
[warn] ==== public: tried
[warn]   http://repo1.maven.org/maven2/ch/qos/logback/logback-classic/1.1.1/logback-classic-1.1.1.pom
[info] Resolving org.scala-lang#scala-reflect;2.10.3 ...
[warn] Host repo1.maven.org not found. url=http://repo1.maven.org/maven2/org/scala-lang/scala-reflect/2.10.3/scala-reflect-2.10.3.pom
[info] You probably access the destination server through a proxy server that is not well configured.
[warn]  module not found: org.scala-lang#scala-reflect;2.10.3
[warn] ==== local: tried
[warn]   /home/user/.ivy2/local/org.scala-lang/scala-reflect/2.10.3/ivys/ivy.xml
[warn] ==== public: tried
[warn]   http://repo1.maven.org/maven2/org/scala-lang/scala-reflect/2.10.3/scala-reflect-2.10.3.pom
[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  ::          UNRESOLVED DEPENDENCIES         ::
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  :: org.scala-lang#scala-library;2.10.3: not found
[warn]  :: ch.qos.logback#logback-classic;1.1.1: not found
[warn]  :: org.scala-lang#scala-reflect;2.10.3: not found
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::

离线工作时真的无法清理吗?

我注意到SBT正在查看.ivy2/local,但是没有这样的文件夹。只有' .ivy2 / cache'。

更新

建议添加.ivy2 / local不起作用。它提供了许多MalformedURLException

[warn]  :: org.scala-lang#scala-library;2.10.3: ivy2 cache: unable to get resource for org/scala-lang#scala-library;2.10.3: res=/home/user/.ivy2/cache/org/scala-lang/scala-library/2.10.3/scala-library-2.10.3.pom: java.net.MalformedURLException: no protocol: /home/user/.ivy2/cache/org/scala-lang/scala-library/2.10.3/scala-library-2.10.3.pom

它正在寻找目录org / scala-lang等,但缓存中的thr目录的格式为org.scala-lang

更新2

似乎问题是由与logback的一些交互引起的。我已经为我的问题here创建了一个更清晰的版本,我接受了答案,表明这应该是'开箱即用。

2 个答案:

答案 0 :(得分:1)

我不确定这会有效,但我想您需要在Build.scala(或build.sbt)中添加另一个resolver,如下所示:

resolvers += "ivy2 cache" at "/home/user/.ivy2/cache"

如果有效,请告诉我,我也很好奇。

修改

我试了一下,然后sbt会查看你的ivy2缓存,进入你的build.sbt并添加以下内容:

resolvers += Resolver.file("ivy2 cache", file("/path/to/your/ivy2/cache/"))(Resolver.ivyStylePatterns)

现在SBT也应该查看该目录。

答案 1 :(得分:1)

如果您在线构建项目,那么您可以在之后离线。 基本上,您只是想将〜/ .ivy2文件夹(可能是〜/ .sbt文件夹 - 不确定)从之前完成构建和依赖性解析的位置复制到您的环境中。

删除项目中的目标/,然后离线,我可以看到这确实导致资源得到解决。

[info] Resolving org.fusesource.jansi#jansi;1.4 ...
[info] Done updating.
[info] Compiling 4 Scala sources to [...]