2

When I'm using SBT to package my app, it may take a long time to get jars from central maven repository or Typesafe repo. And it would be painful for me to identify if it's stuck while downloading. For example,

$ sbt package
[info] Loading project definition from /home/au9ustine/projects/gloin/project
[info] Set current project to gloin (in build file:/home/au9ustine/projects/gloin/)
...
[info] downloading https://repo1.maven.org/maven2/org/scala-lang/scala-compiler/2.10.3/scala-compiler-2.10.3.jar

frееzes for a long time occasionally.

I searched a lot and found that it gets stuck on connection issue. However currently I have no idea how to identify when an issue occurs because sometimes connection works well. So, I need to check the progress of downloading files. Something like wget provides:

$ wget -c http://www.sonatype.org/downloads/nexus-latest-bundle.zip
--2014-12-27 20:00:28--  http://www.sonatype.org/downloads/nexus-latest-bundle.zip
Resolving www.sonatype.org (www.sonatype.org)... 54.85.199.48, 54.165.51.98
Connecting to www.sonatype.org (www.sonatype.org)|54.85.199.48|:80... connected.
...
HTTP request sent, awaiting response... 200 OK
Length: 80393206 (77M) [application/zip]
Saving to: ‘nexus-latest-bundle.zip’

nexus-latest-bundle 100%[=====================>]  76.67M  67.6KB/s   in 17m 6s

2014-12-27 20:17:41 (76.5 KB/s) - ‘nexus-latest-bundle.zip’ saved [80393206/80393206]

Any ideas? Thanks!

dk14
  • 22,206
  • 4
  • 51
  • 88
au9ustine
  • 45
  • 6

1 Answers1

3

Apache Ivy is responsible for that, it's possible to manage it with Ivy, using showprogress attribute of resolver ant-task:

http://ant.apache.org/ivy/history/2.3.0/use/resolve.html

But sbt uses Ivy API directly and showprogress seems to be hardcoded to false. But, there is a tricky way to achieve what you want: you may implement your own MessageLogger, instead of this (see isShowProgress). To "register" it, redefine withIvy from IvySbt and CachedResolutionResolveEngine classes:

def withIvy[T](log: Logger)(f: Ivy => T): T =
       withIvy(new YourLoggerInterface(log))(f)

IvySbt class is final, CachedResolutionResolveEngine is private, so you should hook withIvy call using dynamic proxy (it's pretty much simple). At least similar solution worked for me when i was playing with dependency resolving. But it's not much safe of course.

There is also may be a way to define such property in ivy.xml, ivysettings.xml (How to use SBT with external ivy configuration)

Community
  • 1
  • 1
dk14
  • 22,206
  • 4
  • 51
  • 88