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.
Gotchas
- Don’t include “http://” in the
yourserver
value - Don’t include the port in the
yourserver
value - You probably also want to include
https.proxyHost
andhttps.proxyPort
since a lot of stuff works over https - If your proxy requires authentication, don’t even bother trying unless it just uses Basic Authentication as SBT doesn’t support anything else. Also always beware clear texting credentials into environment variables! Be sure to remove the commands from your .bash_history using a text editing method that won’t create trace files (technically you should
shred
orsrm
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.