diff --git a/launch/src/main/scala/xsbt/boot/BootConfiguration.scala b/launch/src/main/scala/xsbt/boot/BootConfiguration.scala index 5170b61fa..288aadc83 100644 --- a/launch/src/main/scala/xsbt/boot/BootConfiguration.scala +++ b/launch/src/main/scala/xsbt/boot/BootConfiguration.scala @@ -91,14 +91,28 @@ private object BootConfiguration None } } +private final class ProxyProperties( + val envURL: String, + val envUser: String, + val envPassword: String, + val sysHost: String, + val sysPort: String, + val sysUser: String, + val sysPassword: String +) private object ProxyProperties { - val HttpProxyEnv = "http_proxy" - val HttpProxyUser = "http_proxy_user" - val HttpProxyPassword = "http_proxy_pass" + val http = apply("http") + val https = apply("https") + val ftp = apply("ftp") - val ProxyHost = "http.proxyHost" - val ProxyPort = "http.proxyPort" - val ProxyUser = "http.proxyUser" - val ProxyPassword = "http.proxyPassword" + def apply(pre: String) = new ProxyProperties( + pre+"_proxy", + pre+"_proxy_user", + pre+"_proxy_pass", + pre+".proxyHost", + pre+".proxyPort", + pre+".proxyUser", + pre+".proxyPassword" + ) } \ No newline at end of file diff --git a/launch/src/main/scala/xsbt/boot/CheckProxy.scala b/launch/src/main/scala/xsbt/boot/CheckProxy.scala index a00c3b06c..a45a90b1e 100644 --- a/launch/src/main/scala/xsbt/boot/CheckProxy.scala +++ b/launch/src/main/scala/xsbt/boot/CheckProxy.scala @@ -11,18 +11,25 @@ object CheckProxy def apply() { import ProxyProperties._ - val httpProxy = System.getenv(HttpProxyEnv) - if(isDefined(httpProxy) && !isPropertyDefined(ProxyHost) && !isPropertyDefined(ProxyPort)) + for( pp <- Seq(http, https, ftp)) + setFromEnv(pp) + } + + private[this] def setFromEnv(conf: ProxyProperties) + { + import conf._ + val proxyURL = System.getenv(envURL) + if(isDefined(proxyURL) && !isPropertyDefined(sysHost) && !isPropertyDefined(sysPort)) { try { - val proxy = new URL(httpProxy) - setProperty(ProxyHost, proxy.getHost) + val proxy = new URL(proxyURL) + setProperty(sysHost, proxy.getHost) val port = proxy.getPort if(port >= 0) - System.setProperty(ProxyPort, port.toString) - copyEnv(HttpProxyUser, ProxyUser) - copyEnv(HttpProxyPassword, ProxyPassword) + System.setProperty(sysPort, port.toString) + copyEnv(envUser, sysUser) + copyEnv(envPassword, sysPassword) } catch { @@ -31,6 +38,7 @@ object CheckProxy } } } + private def copyEnv(envKey: String, sysKey: String) { setProperty(sysKey, System.getenv(envKey)) } private def setProperty(key: String, value: String) { if(value != null) System.setProperty(key, value) } private def isPropertyDefined(k: String) = isDefined(System.getProperty(k)) diff --git a/src/sphinx/Detailed-Topics/Setup-Notes.rst b/src/sphinx/Detailed-Topics/Setup-Notes.rst index f2b4320dc..ca7fd3ec0 100644 --- a/src/sphinx/Detailed-Topics/Setup-Notes.rst +++ b/src/sphinx/Detailed-Topics/Setup-Notes.rst @@ -52,22 +52,27 @@ following uses the pre-0.11 style of putting the boot directory in java -Dsbt.boot.directory=project/boot/ -HTTP Proxy ----------- +HTTP/HTTPS/FTP Proxy +-------------------- -On Unix, sbt will pick up any HTTP proxy settings from the standard -`http_proxy` environment variable. If you are behind a proxy requiring -authentication, your `sbt` script must also pass flags to set the -`http.proxyUser` and `http.proxyPassword` properties: +On Unix, sbt will pick up any HTTP, HTTPS, or FTP proxy settings from the standard +`http_proxy`, `https_proxy`, and `ftp_proxy` environment variables. If you are behind +a proxy requiring authentication, your `sbt` script must also pass flags to set the +`http.proxyUser` and `http.proxyPassword` properties for HTTP, +`ftp.proxyUser` and `ftp.proxyPassword` properties for FTP, +or `https.proxyUser` and `https.proxyPassword` properties for HTTPS. + +For example, .. code-block:: console java -Dhttp.proxyUser=username -Dhttp.proxyPassword=mypassword On Windows, your script should set properties for proxy host, port, and -if applicable, username and password: +if applicable, username and password. For example, for HTTP: .. code-block:: console java -Dhttp.proxyHost=myproxy -Dhttp.proxyPort=8080 -Dhttp.proxyUser=username -Dhttp.proxyPassword=mypassword +Replace `http` with `https` or `ftp` in the above command line to configure HTTPS or FTP.