How to configure sbt so that it captures all the necessary dependencies when working on the network and allows me to work offline?

I am trying to work on my project, being in the zone of lack of Internet connection. To my surprise, sbt is having problems in this situation. Although, I have to have my libraries in the cache (given that I originally started the project on the Internet), sbt cannot solve any dependency.

Sbt cannot get my local maven repository, and it cannot find any other dependency that, in my opinion, it has already loaded (i.e., into the cache).

*

My question is: how to make sure that when I have a connection, sbt selects libs in the ONCE cache, so when I do not have it, it selects all my local repo, including one from maven.

I ask about this because I understand the current situation (i.e. when the internet connection is not available):

  • Sbt has problems loading from maven cache
  • sbt can find most of my addiction in ivy local
  • sbt cannot find a specific dependency which, for certain reasons, is apparently not cached.

For example, there is a libs trace that sbt should already have cached.

[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 

Here are the contents of the cache:

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

extensions-parent guice-assistedinject guice-multibindings

Where in each folder is:

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

the remaining last 2 folders contain additionally:

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

eg.

In the folder with jars of auxiliary injection you have:

Guice-assistedinject-4.0-beta4.jar

The ivy.xml property 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> 

its properties file is as follows:

 #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 
+6
sbt
source share
1 answer

See Caching and configuration .

When offline := true , remote SNAPSHOT will not be updated with permission, even an explicitly requested update. This should effectively support operation without connecting to remote repositories. Perceived examples demonstrating the opposite are evaluated. Obviously, the update must be successfully started before going offline.

This feature may or may not work, but it is designed to solve your scenario. Give it a try, and if that doesn't work, post a problem on Github.

+2
source share

All Articles