Linux 如何让sbt使用本地存储库中的jar?

Linux 如何让sbt使用本地存储库中的jar?,linux,centos,sbt,Linux,Centos,Sbt,我正试图在我的Linux虚拟机(CentOS)中安装SBT,安全性非常严格 它无法访问 我已经提取了SBT zip文件,并将bin路径添加到环境变量中 正如所料,我无法运行SBT [admin@xxx]$ sbt Getting org.scala-sbt sbt 0.13.12 ... :: problems summary :: :::: WARNINGS module not found: org.scala-sbt#sbt;0.13.12 ==

我正试图在我的Linux虚拟机(CentOS)中安装SBT,安全性非常严格

它无法访问

我已经提取了SBT zip文件,并将bin路径添加到环境变量中

正如所料,我无法运行SBT

[admin@xxx]$ sbt
Getting org.scala-sbt sbt 0.13.12 ...

:: problems summary ::
:::: WARNINGS
            module not found: org.scala-sbt#sbt;0.13.12

    ==== local: tried

      /home/admin/.ivy2/local/org.scala-sbt/sbt/0.13.12/ivys/ivy.xml

      -- artifact org.scala-sbt#sbt;0.13.12!sbt.jar:

      /home/admin/.ivy2/local/org.scala-sbt/sbt/0.13.12/jars/sbt.jar

    ==== Maven Central: tried

      https://repo1.maven.org/maven2/org/scala-sbt/sbt/0.13.12/sbt-0.13.12.pom

      -- artifact org.scala-sbt#sbt;0.13.12!sbt.jar:

      https://repo1.maven.org/maven2/org/scala-sbt/sbt/0.13.12/sbt-0.13.12.jar

    ==== typesafe-ivy-releases: tried

      https://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/sbt/0.13.12/ivys/ivy.xml

    ==== sbt-ivy-snapshots: tried

      https://repo.scala-sbt.org/scalasbt/ivy-snapshots/org.scala-sbt/sbt/0.13.12/ivys/ivy.xml

            ::::::::::::::::::::::::::::::::::::::::::::::

            ::          UNRESOLVED DEPENDENCIES         ::

            ::::::::::::::::::::::::::::::::::::::::::::::

            :: org.scala-sbt#sbt;0.13.12: not found

            ::::::::::::::::::::::::::::::::::::::::::::::


:::: ERRORS
    Server access Error: Connection timed out url=https://repo1.maven.org/maven2/org/scala-sbt/sbt/0.13.12/sbt-0.13.12.pom

    Server access Error: Connection timed out url=https://repo1.maven.org/maven2/org/scala-sbt/sbt/0.13.12/sbt-0.13.12.jar

    Server access Error: Connection timed out url=https://repo.typesafe.com/typesafe/ivy-releases/org.scala-sbt/sbt/0.13.12/ivys/ivy.xml

    Server access Error: Connection timed out url=https://repo.scala-sbt.org/scalasbt/ivy-snapshots/org.scala-sbt/sbt/0.13.12/ivys/ivy.xml


:: USE VERBOSE OR DEBUG MESSAGE LEVEL FOR MORE DETAILS
unresolved dependency: org.scala-sbt#sbt;0.13.12: not found
Error during sbt execution: Error retrieving required libraries
(see /home/admin/.sbt/boot/update.log for complete log)
Error: Could not retrieve sbt 0.13.12
我通过添加存储库文件使其使用我的存储库

存储库

[repositories]
  local
  my-maven-proxy-releases: http://nexuspro.company.com/nexus/service/local/repositories/
[repositories]
local
cache: file://home/admin/.ivy2/cache, [organisation]/[module]/[type]s/[module]-[revision].[type], [organisation]/[module]/ivy-[revision].xml
然后,我使用以下参数运行SBT命令:

sbt -Dsbt.repository.config=/sbt/conf/repositories
现在我的问题是SBT似乎使用默认目录结构,这与我的存储库不同

<my repository>/org/scala-sbt/sbt/0.13.12/sbt-0.13.12.jar
/org/scala sbt/sbt/0.13.12/sbt-0.13.12.jar
所以我现在的问题是如何设置SBT来使用我的jar?也许强迫它使用我的罐子的绝对路径

<my repository>/sbt-0.13.12.jar
/sbt-0.13.12.jar

正确的方法是用公司的私有存储库代理这两个存储库。我想知道最新版本的nexus是否增加了对代理/服务常春藤存储库的支持。如果没有,您将不得不切换到artifactory

另一种方法是使用本地安装的工件代理所需的存储库,并通过ssh隧道将其提供给vm。当我没有管理公司存储库的特权时,我玩了这个把戏

<my repository>/org/scala-sbt/sbt/0.13.12/sbt-0.13.12.jar

如果上述想法不适合你。最后一个机会是在可以访问所需存储库的地方构建项目。然后将~/.ivy目录复制到虚拟机。这就是常春藤存储获取的工件的地方。

这对那些没有互联网连接但需要使用sbt的人来说非常有用

这是基于CruityCrow的第三个选项

首先,您需要在可以访问internet的环境中更新sbt

sbt update
如果需要特定版本的sbt,则需要在调用sbt update之前编辑build.properties

然后将.ivy2\cache复制到目标环境(无internet)

然后将缓存设置为存储库

存储库

[repositories]
  local
  my-maven-proxy-releases: http://nexuspro.company.com/nexus/service/local/repositories/
[repositories]
local
cache: file://home/admin/.ivy2/cache, [organisation]/[module]/[type]s/[module]-[revision].[type], [organisation]/[module]/ivy-[revision].xml
然后使用指向存储库文件的参数调用sbt

sbt -Dsbt.repository.config=/sbt/conf/repositories

嗯,如果我复制~.ivy,那么之后我就不需要调用sbt命令了?您仍然不需要调用sbt来构建您的项目。但是现在sbt将不必通过网络获取依赖关系。举个例子怎么样?我认为上面的一个很好。在没有连接问题的环境中运行sbt更新。然后复制其.ivy2\cache。然后,通过将其添加到存储库文件中,将其用作源(请参见上文)。然后最后运行sbt,但要有一个关于回购协议的参数。但我想我还是遇到了一些颠簸。因此,最好的解决方案是拥有自己的Nexus。