如何设置 sbt 以便它在线时获取所有必要的依赖项,然后让我离线工作? [英] How to set up sbt so it grabs all necessary dependencies when online and let me work offline then?

查看:45
本文介绍了如何设置 sbt 以便它在线时获取所有必要的依赖项,然后让我离线工作?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试在没有互联网连接的区域处理我的项目.令我惊讶的是,sbt 在这种情况下遇到了麻烦.虽然,我应该将我的库放在缓存中(假设我最初是在线启动项目的),但 sbt 无法解决某些依赖性.

I try to work on my project while in an no internet connection zone. To my surprise, sbt is having trouble in that situation. Although, i'm supposed to have my libraries in the cache (given that i initially started the project online), sbt can't resolve some dependency.

Sbt 无法获取我的本地 Maven 存储库,他也无法找到我认为他已经下载的其他依赖项(即在缓存中).

*

我的问题是:如何确保当我有连接时,sbt获取缓存中的库一次,以便当我没有它时,它获取我所有的本地存储库,包括 maven 的存储库.

My question is: how to ensure that when i have the connection, sbt fetches the libs in the cache ONCE, so that when i don't have it, it fetches all my local repo including the one of maven.

我问这个是因为我对当前情况的理解(即没有互联网连接时):

I'm asking this because to my understanding of the current situation (i.e. when no internet connection is available):

  1. sbt 从 Maven 缓存下载时遇到问题
  2. sbt 可以在 ivy local 中找到我的大部分依赖
  3. sbt 找不到某些特定的依赖项,因为某些原因,显然没有缓存.

例如,这里是 sbt 应该已经缓存的库的踪迹.

For instance here is a trace of libs that sbt was supposed to have cached already.

[warn]   file:///Users/maatary/.m2/repository/com/google/inject/extensions/guice-assistedinject/4.0-beta4/guice-assistedinject-4.0-beta4.pom
[info] Resolving com.google.inject.extensions#guice-multibindings;4.0-beta4 ...
**[warn] Host repo1.maven.org not found.** url=http://repo1.maven.org/maven2/com/google/inject/extensions/guice-multibindings/4.0-beta4/guice-multibindings-4.0-beta4.pom
**[info] You probably access the destination server through a proxy server that is not well configured.**
[warn]  module not found: com.google.inject.extensions#guice-multibindings;4.0-beta4
**[warn] ==== local: tried
[warn]   /Users/maatary/.ivy2/local/com.google.inject.extensions/guice-multibindings/4.0-beta4/ivys/ivy.xml**
[warn] ==== public: tried
[warn]   http://repo1.maven.org/maven2/com/google/inject/extensions/guice-multibindings/4.0-beta4/guice-multibindings-4.0-beta4.pom
[warn] ==== Local Maven Repository: tried
[warn]   file:///Users/maatary/.m2/repository/com/google/inject/extensions/guice-multibindings/4.0-beta4/guice-multibindings-4.0-beta4.pom
[info] Resolving jline#jline;2.12 ...                                          
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  ::          UNRESOLVED DEPENDENCIES         ::
[warn]  ::::::::::::::::::::::::::::::::::::::::::::::
[warn]  :: com.google.inject.extensions#guice-assistedinject;4.0-beta4: not found
[warn]  :: com.google.inject.extensions#guice-multibindings;4.0-beta4: not found

这是缓存内容:

/Users/maatary/.ivy2/cache/com.google.inject.extensions

extensions-parent guice-辅助注入 guice-multibindings

您在每个文件夹中的位置:

Where in each folder you have:

ivy-4.0-beta4.xml ivydata-4.0-beta4.propertiesivy-4.0-beta4.xml.original

ivy-4.0-beta4.xml ivydata-4.0-beta4.properties ivy-4.0-beta4.xml.original

其他最后两个文件夹还包含:

the others last 2 folders contains in addition:

一个 jars、src 和 docs 文件夹.在罐子里,你找到了取来的罐子.

a jars, src and docs folder. In the jars you find the jar fetched.

例如

在辅助注入的 jars 文件夹中,您有:

In the jars folder of assisted inject you have:

guice-assistantinject-4.0-beta4.jar

它的ivy.xml如下:

Its ivy.xml is as follows:

<?xml version="1.0" encoding="UTF-8"?>
<ivy-module version="2.0" xmlns:m="http://ant.apache.org/ivy/maven">
        <info organisation="com.google.inject.extensions"
                module="guice-assistedinject"
                revision="4.0-beta4"
                status="release"
                publication="20140320225220"
        >
                <description homepage="" />
                <m:properties__guice.with.no_aop>true</m:properties__guice.with.no_aop>
                <m:properties__gpg.skip>true</m:properties__gpg.skip>
                <m:properties__project.build.sourceEncoding>UTF-8</m:properties__project.build.sourceEncoding>
                <m:properties__guice.api.version>1.4</m:properties__guice.api.version>
                <e:sbtTransformHash>7174be3135c2a95a21c158fb6beb5a9621b5b898</e:sbtTransformHash>
                <m:properties__guice.with.jarjar>true</m:properties__guice.with.jarjar>
                <m:maven.plugins>null__maven-gpg-plugin__1.4|null__maven-gpg-plugin__1.4|null__maven-remote-resources-plugin__null|org.codehaus.mojo__animal-sniffer-maven-plugin__null|org.apache.felix__maven-bundle-plugin__null|null__mav\
en-source-plugin__null|null__maven-javadoc-plugin__null|null__maven-gpg-plugin__1.4|null__maven-gpg-plugin__1.4|null__maven-remote-resources-plugin__null|org.codehaus.mojo__animal-sniffer-maven-plugin__null|org.apache.felix__maven-bundle\
-plugin__null|null__maven-source-plugin__null|null__maven-javadoc-plugin__null</m:maven.plugins>
        </info>
        <configurations>
                <conf name="default" visibility="public" description="runtime dependencies and master artifact can be used with this conf" extends="runtime,master"/>
                <conf name="master" visibility="public" description="contains only the artifact published by this module itself, with no transitive dependencies"/>
                <conf name="compile" visibility="public" description="this is the default scope, used if none is specified. Compile dependencies are available in all classpaths."/>
                <conf name="provided" visibility="public" description="this is much like compile, but indicates you expect the JDK or a container to provide it. It is only available on the compilation classpath, and is not transitive."/>
                <conf name="runtime" visibility="public" description="this scope indicates that the dependency is not required for compilation, but is for execution. It is in the runtime and test classpaths, but not the compile classpath\
." extends="compile"/>
                <conf name="test" visibility="private" description="this scope indicates that the dependency is not required for normal use of the application, and is only available for the test compilation and execution phases." extends\
="runtime"/>
                <conf name="system" visibility="public" description="this scope is similar to provided except that you have to provide the JAR which contains it explicitly. The artifact is always available and is not looked up in a repos\
itory."/>
                <conf name="sources" visibility="public" description="this configuration contains the source artifact of this module, if any."/>
                <conf name="javadoc" visibility="public" description="this configuration contains the javadoc artifact of this module, if any."/>
                <conf name="optional" visibility="public" description="contains all optional dependencies"/>
        </configurations>
        <publications>
                <artifact name="guice-assistedinject" type="jar" ext="jar" conf="master"/>
        </publications>
        <dependencies>
                <dependency org="com.google.inject" name="guice" rev="4.0-beta4" force="true" conf="compile->compile(*),master(*);runtime->runtime(*);test->runtime(*),master(*)">
                        <artifact name="guice" type="jar" ext="jar" conf="compile,runtime"/>
                        <artifact name="guice" type="jar" ext="jar" conf="test" m:classifier="tests"/>
                </dependency>
                <dependency org="cglib" name="cglib" rev="3.1" force="true" conf="test->runtime(*),master(*)">
                        <exclude org="asm" module="asm" name="*" type="*" ext="*" matcher="exact"/>
                </dependency>
                <dependency org="org.ow2.asm" name="asm" rev="5.0" force="true" conf="test->runtime(*),master(*)"/>
                <dependency org="junit" name="junit" rev="4.11" force="true" conf="test->runtime(*),master(*)"/>
        </dependencies>
</ivy-module>

其属性文件如下:

#ivy cached data file for com.google.inject.extensions#guice-assistedinject;4.0-beta4                                                                                                                                                         
#Sun Aug 17 20:44:39 CEST 2014                                                                                                                                                                                                                
artifact\:guice-assistedinject\#src\#jar\#1257084071.is-local=false
artifact\:ivy\#ivy\#xml\#-1879642188.exists=true
artifact\:guice-assistedinject\#src\#jar\#1257084071.exists=true
artifact\:ivy\#ivy\#xml\#-1879642188.location=http\://repo1.maven.org/maven2/com/google/inject/extensions/guice-assistedinject/4.0-beta4/guice-assistedinject-4.0-beta4.pom                                                                   
artifact\:guice-assistedinject\#pom.original\#pom\#1062568006.is-local=false
artifact\:guice-assistedinject\#jar\#jar\#-589994656.is-local=false
artifact\:guice-assistedinject\#pom.original\#pom\#1062568006.location=http\://repo1.maven.org/maven2/com/google/inject/extensions/guice-assistedinject/4.0-beta4/guice-assistedinject-4.0-beta4.pom                                          
artifact\:guice-assistedinject\#jar\#jar\#-589994656.location=http\://repo1.maven.org/maven2/com/google/inject/extensions/guice-assistedinject/4.0-beta4/guice-assistedinject-4.0-beta4.jar                                                   
artifact\:guice-assistedinject\#doc\#jar\#-1786980107.location=http\://repo1.maven.org/maven2/com/google/inject/extensions/guice-assistedinject/4.0-beta4/guice-assistedinject-4.0-beta4-javadoc.jar                                          
artifact\:guice-assistedinject\#pom.original\#pom\#1062568006.exists=true
artifact\:guice-assistedinject\#doc\#jar\#-1786980107.exists=true
artifact\:ivy\#ivy\#xml\#-1879642188.is-local=false
artifact\:guice-assistedinject\#doc\#jar\#-1786980107.is-local=false
artifact\:guice-assistedinject\#src\#jar\#1257084071.location=http\://repo1.maven.org/maven2/com/google/inject/extensions/guice-assistedinject/4.0-beta4/guice-assistedinject-4.0-beta4-sources.jar                                           
artifact\:guice-assistedinject\#jar\#jar\#-589994656.exists=true

推荐答案

参见 缓存和配置.

offline := true 时,远程快照将不会通过分辨率更新,即使是明确请求的更新.这应该有效地支持在没有连接到远程存储库的情况下工作.可重复的例子证明否则表示赞赏.显然,更新必须在离线之前成功运行.

When offline := true, remote SNAPSHOTs will not be updated by a resolution, even an explicitly requested update. This should effectively support working without a connection to remote repositories. Reproducible examples demonstrating otherwise are appreciated. Obviously, update must have successfully run before going offline.

此功能可能适合您,也可能不适合,但它旨在解决您的情况.尝试一下,如果它不起作用,请在 Github 上提交问题.

This feature may or may not work for you, but it's intended to address your scenario. Try it and if it doesn't work, please file an issue on Github.

这篇关于如何设置 sbt 以便它在线时获取所有必要的依赖项,然后让我离线工作?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆