如何设置gradle的代理服务器? [英] How to set proxy server for gradle?

查看:933
本文介绍了如何设置gradle的代理服务器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要设置一个代理服务器,以便能够使用我公司网络中的gradle下载项目依赖项.我尝试为shell设置代理,但是它没有用,所以我认为这是由于命令的影响, gradle用于下载这些依赖项,不使用http_proxy环境变量.

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 assume it is because of the commands, gradle using to download these dependencies, does not use http_proxy environment variable.

在下载项目依赖项时,gradle使用哪些命令(如wgetcurl)?如何检查这些命令?我尝试了--info和--debug选项,但只为每个文件说了类似的内容;

Which commands (like wget, curl) does gradle use when downloading project dependencies? How can i check these commands? I tried both --info and --debug options, but it only says for each file something like;

Download https://jcenter.bintray.com/com/android/tools/lint/lint/25.1.0/lint-25.1.0.pom

推荐答案

Gradle拥有类似于maven的自己的依赖项管理系统.我认为 gradle publish插件的某些部分以某种方式得到了maven的支持(未经验证).不管您不必担心那种深度,gradle都可以解决.您的问题是设置代理.您只需要在$projectDir/gradle.properties中设置一些变量,例如:

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

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

这篇关于如何设置gradle的代理服务器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆