Gradlew behind a proxy

后端 未结 16 1509
一个人的身影
一个人的身影 2020-12-04 12:26

I have a sample from Gaelyk (called Bloogie) and it is using gradlew.

I am behind a proxy.

I\'ve read gradle docs and found this:

gradle.properties

16条回答
  •  情歌与酒
    2020-12-04 12:31

    An excerpted answer from the linked thread below. It shows how to do this more programtically. Hope it helps

    task setHttpProxyFromEnv {
        def map = ['HTTP_PROXY': 'http', 'HTTPS_PROXY': 'https']
        for (e in System.getenv()) {
            def key = e.key.toUpperCase()
            if (key in map) {
                def base = map[key]
                //Get proxyHost,port, username, and password from http system properties 
                // in the format http://username:password@proxyhost:proxyport
                def (val1,val2) = e.value.tokenize( '@' )
                def (val3,val4) = val1.tokenize( '//' )
                def(userName, password) = val4.tokenize(':')
                def url = e.value.toURL()
                //println " - systemProp.${base}.proxy=${url.host}:${url.port}"
                System.setProperty("${base}.proxyHost", url.host.toString())
                System.setProperty("${base}.proxyPort", url.port.toString())
                System.setProperty("${base}.proxyUser", userName.toString())
                System.setProperty("${base}.proxyPassword", password.toString())
            }
        }
    }
    

    See this thread for more

提交回复
热议问题