Skip to content
This repository
Fetching contributors…

Cannot retrieve contributors at this time

file 38 lines (36 sloc) 1.117 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
/* sbt -- Simple Build Tool
* Copyright 2009 Mark Harrah
*/
package xsbt.boot

import Pre._
import java.net.{MalformedURLException, URL}

object CheckProxy
{
def apply()
{
import ProxyProperties._
val httpProxy = System.getenv(HttpProxyEnv)
if(isDefined(httpProxy) && !isPropertyDefined(ProxyHost) && !isPropertyDefined(ProxyPort))
{
try
{
val proxy = new URL(httpProxy)
setProperty(ProxyHost, proxy.getHost)
val port = proxy.getPort
if(port >= 0)
System.setProperty(ProxyPort, port.toString)
copyEnv(HttpProxyUser, ProxyUser)
copyEnv(HttpProxyPassword, ProxyPassword)
}
catch
{
case e: MalformedURLException =>
System.out.println("Warning: could not parse http_proxy setting: " + e.toString)
}
}
}
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))
private def isDefined(s: String) = s != null && isNonEmpty(s)
}
Something went wrong with that request. Please try again.