How do I configure sbt to use a proxy?
For example, my build definition needs to connect to GitHub, specifying connection parameters for http.proxy
, http.proxyPort
, user
, and password
.
How would I pass in these settings to sbt?
Is there an easy way to switch between proxy/no-proxy settings for when I work from home?
sbt
respects the usual environment variables for http proxy settings:
export JAVA_OPTS="$JAVA_OPTS -Dhttp.proxyHost=yourserver -Dhttp.proxyPort=8080 -Dhttp.proxyUser=username -Dhttp.proxyPassword=password"
(That's of course, assuming Unix (Linux/OSX etc). On windows you could just set the same environment variable (%JAVA_OPTS%
) as usual in the Windows way.)
Then run sbt
as usual:
sbt
Switching between proxy/no-proxy should be a matter of setting up a little script that you can 'slurp' in whenever you need it.
yourserver
valueyourserver
valuehttps.proxyHost
and https.proxyPort
since a lot of stuff works over httpsshred
or srm
the entire file). If you are on Windows, don't worry about it, your security is already messed up you can't do any more harm.