Use sbt completely offline

4,170 views
Skip to first unread message

dowobeha

unread,
May 29, 2012, 1:18:29 PM5/29/12
to simple-b...@googlegroups.com
I would like to use a tool that uses sbt for compiling. I have access to an internet connection where I can download individual files, but the machines that I will be running on are on a standalone network, with no internet access. I can transfer downloaded files to the offline machines, but (for various somewhat complicated reasons) I cannot run sbt on the machine with the internet connection.

Is it possible to run sbt on a machine with no internet connection?

I know nothing about maven or ivy.

I have access to another developer's build logs, so I was able to see a list of jars that sbt attempts to download. These are all jars that sbt is downloading for its own use - all of the jars required by the project that I'm attempting to compile are provided in the project's lib subdir.

The types of solutions that I'm (ideally) looking for are:

* Just run sbt with flag --no-internet-connection

* Download these files (a.jar, b.jar, c.jar), put them in some/subdir, and then run sbt with flag --dependencies-here=some/subdir

I've searched through this mailing list's archives, as well as the documentation for xsbt, and it appears that others have had this same problem. Unfortunately the only solutions I found all appeared to involve setting up local maven or ivy repositories, which seems like a huge requirement.

Any help would be greatly appreciated.

Thanks,
Lane

Josh Suereth

unread,
May 30, 2012, 3:57:16 PM5/30/12
to simple-b...@googlegroups.com
Right now offline mode is only so-so IIRC.  I've had issues making it work.   But I believe the incantation is `offline := true` or `offline in Global := true`.

I've done some work on resolvers though, and I think with 0.12 we'll have a good answer for you.  IN the future, you'll be able to configure the boot resolvers in an external config file and force all SBT builds to use that set.  



--
You received this message because you are subscribed to the Google Groups "simple-build-tool" group.
To view this discussion on the web visit https://groups.google.com/d/msg/simple-build-tool/-/BR14rMobyFcJ.
To post to this group, send email to simple-b...@googlegroups.com.
To unsubscribe from this group, send email to simple-build-t...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/simple-build-tool?hl=en.

Lane Schwartz

unread,
May 30, 2012, 4:24:49 PM5/30/12
to simple-b...@googlegroups.com
Josh,

Thanks for responding. I'll see if I can make any progress by adding
either of those lines to my build.sbt.

I briefly tried just now adding the latter, and when I compile sbt
still attempts to connect to repo.typesafe.com, repo1.maven.org, and
oss.sonatype.org. It dies complaining about module not found
"org.scala-lang#scala-library;2.9.2

I have all of the required jars downloaded manually. Presumably I need
to tell sbt about those somehow. Do I also need to manually download
any of the ivy.xml or *.pom files? I do not have a local ivy repo nor
a local maven repo.

Thanks,
Lane

Josh Suereth

unread,
May 30, 2012, 5:26:15 PM5/30/12
to simple-b...@googlegroups.com
You need a local ivy repo/cache to be able to go offline.  I recommend running sbt and copying the .ivy2 directory to whatever offline machines you need.

--
You received this message because you are subscribed to the Google Groups "simple-build-tool" group.

Robin Green

unread,
Jul 20, 2012, 6:55:34 AM7/20/12
to simple-b...@googlegroups.com
Oh no, not again! This doesn't work either, at least on sbt 0.11.2!

What I've tried is copying up the ivy directory - containing just the cached jars sbt needs for bootstrapping - to a server without internet access, and running:

java -Dsbt.ivy.home=$PWD/ivy -jar sbt-launch.jar

EVERY answer I've read about how to use sbt with a corporate maven repository, hasn't completely worked. This is a really, really flaky side of sbt. Something must be done about it!!!

(I appreciate that this was probably a speculative answer, and I'm not criticising you personally, Josh.)
To post to this group, send email to simple-build-tool@googlegroups.com.
To unsubscribe from this group, send email to simple-build-tool+unsubscribe@googlegroups.com.

Josh Suereth

unread,
Jul 20, 2012, 10:40:38 AM7/20/12
to simple-b...@googlegroups.com
Using sbt 0.11.2?  Ok, here's what you want:

java -Dsbt.boot.properties=/path/to/my/hacked/boot/repos/boot.properties


Then in your hacked file:

[scala]
  version: ${{scala.version}}

[app]
  org: ${{org}}
  name: sbt
  version: read(sbt.version)[${{sbt.version}}]
  class: ${sbt.main.class-sbt.xMain}
  components: xsbti,extra
  cross-versioned: true

[repositories]
  local
  company-proxy: <url>
  company-proxy-ivy: <url>, [organization]/[module]/(scala_[scalaVersion]/)(sbt_[sbtVersion]/)[revision]/[type]s/[artifact](-[classifier]).[ext]

[boot]
 directory: ${sbt.boot.directory-${sbt.global.base-${user.home}/.sbt}/boot/}

[ivy]
  ivy-home: ${sbt.ivy.home-${user.home}/.ivy2/}
  checksums: ${sbt.checksums-sha1,md5}



THEN!  You need to rewire your builds to only use these repos.  Something akin to:

 fullResolvers <<= (projectResolver,fullResolvers,bootResolvers) map {
  (proj,old, boot) =>
    boot map (proj +: _) getOrElse old
 }

In ~/.sbt/usebootresolvers.sbt

That *should* make it so sbt 0.11.2 uses your local company proxy for all resolution.  Note: Your local company proxy better be able to handle resolving ivy repos.

If you want to just run locally, then alter the boot.properties [repositories] secton so it only has "local".


Hope that helps!  (note: in SBT  0.12, it's now just two flags to SBT to fix this rather than the elaborate setup).

- Josh

To view this discussion on the web visit https://groups.google.com/d/msg/simple-build-tool/-/2OC2sFq9_x8J.

To post to this group, send email to simple-b...@googlegroups.com.
To unsubscribe from this group, send email to simple-build-t...@googlegroups.com.

Josh Suereth

unread,
Aug 10, 2012, 9:52:02 AM8/10/12
to simple-b...@googlegroups.com
If you make a ~/.sbt/repositories file (asusming you launch with an official script) or ~/.sbt/<version>/repositories (assuming you launch with sbt-extras), then you should be able to run sbt with -Dsbt.override.build.repos=true.

On Sbt 0.12.0 this enforces only repositories listed in ~/.sbt/repositories are used.  Make sure you include "local" in that list if you want ot publish-local and have other projects make use of the artifacts.

On Thu, Aug 9, 2012 at 4:38 PM, sjclimb <sj.cl...@gmail.com> wrote:
Josh,

You mention "(note: in SBT  0.12, it's now just two flags to SBT to fix this rather than the elaborate setup)."  Could you please elaborate on which two options fix this setup?  Although I've attempted the above suggestions (using sbt 0.11.3), sbt still seems to be attempting to contact the external typesafe repos.

Thanks,
David
To post to this group, send email to simple-b...@googlegroups.com.
To unsubscribe from this group, send email to simple-build-t...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/simple-build-tool?hl=en.

--
You received this message because you are subscribed to the Google Groups "simple-build-tool" group.
To view this discussion on the web visit https://groups.google.com/d/msg/simple-build-tool/-/2OC2sFq9_x8J.

To post to this group, send email to simple-b...@googlegroups.com.
To unsubscribe from this group, send email to simple-build-t...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/simple-build-tool?hl=en.

--
You received this message because you are subscribed to the Google Groups "simple-build-tool" group.
To view this discussion on the web visit https://groups.google.com/d/msg/simple-build-tool/-/i3KouvTfLc4J.
Reply all
Reply to author
Forward
0 new messages