How to set proxy server for gradle?

前端 未结 1 1369
慢半拍i
慢半拍i 2021-02-04 11:42

I need to set a proxy server to be able to use gradle from my company\'s network to download project dependencies.I tried setting the proxy for shell, but it didn\'t work, so i

1条回答
  •  情歌与酒
    2021-02-04 12:05

    Gradle has it's own dependency management system similar to maven. I think parts of the gradle publish plugin are backed by maven in some way (not verified). Regardless you shouldn't have to worry about that level of depth, gradle will handle it. Your problem is setting up the proxy. You just need to set some variables in $projectDir/gradle.properties, example:

    #http proxy setup
    systemProp.http.proxyHost=www.somehost.org
    systemProp.http.proxyPort=8080
    systemProp.http.proxyUser=userid
    systemProp.http.proxyPassword=password
    systemProp.http.nonProxyHosts=*.nonproxyrepos.com|localhost
    
    #https proxy setup
    systemProp.https.proxyHost=www.somehost.org
    systemProp.https.proxyPort=8080
    systemProp.https.proxyUser=userid
    systemProp.https.proxyPassword=password
    systemProp.https.nonProxyHosts=*.nonproxyrepos.com|localhost
    

    reference: https://docs.gradle.org/current/userguide/build_environment.html#sec:accessing_the_web_via_a_proxy

    0 讨论(0)
提交回复
热议问题