Gradlew 在代理后面
我有一个来自 Gaelyk(称为 Bloogie)的样本,它使用的是 gradlew。
我在代理后面。
我读过 gradle 文档并发现了这个:
gradle.properties
systemProp.http.proxyHost=www.somehost.org
systemProp.http.proxyPort=8080
systemProp.http.proxyUser=userid
systemProp.http.proxyPassword=password
但我不知道如何将此信息放入包装器 gradlew 中。有什么想法吗?
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
systemProp.http.proxyHost=www.somehost.org
systemProp.http.proxyPort=8080
systemProp.http.proxyUser=userid
systemProp.http.proxyPassword=password
But I have no clue how to put this info into the wrapper gradlew. Any idea?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(18)
您所要做的就是创建一个名为 gradle.properties 的文件(包含上面提到的属性)并将其放置在 gradle 用户主目录下(默认为 USER_HOME/.gradle< /code>) 或在您的项目目录中。
如果在用户主目录或项目目录中找到,Gradle(也是包装器!!!)会自动获取 gradle.properties 文件。
有关更多信息,请阅读 Gradle 用户指南,尤其是第 12.3 节:通过代理访问网络
All you have to do is to create a file called
gradle.properties
(with the properties you mentioned above) and place it under your gradle user home directory (which defaults toUSER_HOME/.gradle
) OR in your project directory.Gradle (the wrapper too!!!) automatically picks up
gradle.properties
files if found in the user home directory or project directories.For more info, read the Gradle user guide, especially at section 12.3: Accessing the web via a proxy
如果您需要在代理后面进行 https 访问,请考虑为 systemProp.https 定义相同的属性集。
请参阅 无法在 VPN 后面使用 crashlytics 构建 Android 应用程序和代理以获取更多信息。
If you need https access behind a proxy, please consider defining also the same set of properties for systemProp.https.
See Can't build Android app using crashlytics behind VPN and proxy for more information.
如果您要通过代理下载包装器,请在您的
gradle.properties
文件和gradle/wrapper/gradle-wrapper.properties
文件中添加以下内容如果您想设置全局这些属性,然后将其添加到 USER_HOME/.gradle/gradle.properties 文件中
Add the below in your
gradle.properties
file and in yourgradle/wrapper/gradle-wrapper.properties
file if you are downloading the wrapper over a proxyIf you want to set these properties globally then add it in
USER_HOME/.gradle/gradle.properties file
在提示行中使用它:
在这里工作!
Use this in prompt line:
Works here!
在设置 https 代理之前,我无法使代理属性正常工作:
但是我必须使用 http 属性作为用户名和密码:
I could not get the proxy property to work until I set the https proxy:
However I had to use the http property for user name and password:
Gradle Wrapper 的这个问题已在 Gradle 1.0-milestone-8 中得到修复。试一试。
This problem with the Gradle Wrapper has been fixed with Gradle 1.0-milestone-8. Give it a shot.
在此 JDK更新之后,我无法使用gradlew 再次位于代理后面。
最后我发现 JDK 默认禁用了 HTTPS 隧道的基本身份验证。
所以除了代理设置之外,我还必须为 gradle.properties 添加此属性,
我希望这对遇到同样问题的人有帮助
after of this JDK update, I couldn't use gradlew behind a proxy again.
and finally I found a JDK has disabled Basic authentication for HTTPS tunneling by default.
so I have to add this property for gradle.properties in addition to proxy settings
I hope it would be helpful for someone who struggle same problem
我遇到了同样的问题,我做的第一件事就是创建 gradle.properties。我没有这样的文件,所以我应该使用以下内容创建它:
当我添加它们时,gradlew 命令在公司代理后面可以正常工作。我希望它有用。
I had same problem and first thing I did was to create gradle.properties. I had not such as file so I should create it with following content:
When I added them gradlew command works properly behind corporate proxy. I hope that it can be useful.
为了添加更多细微差别,对于我的情况,当我在 USER_HOME/.gradle 和项目根目录中都有多个 gradle.properties 文件时,我遇到了authenticationrequired 407 错误,日志如下:
CONNECT 被代理拒绝:HTTP/1.1 407 需要身份验证
这导致我的 USER_HOME/.gradle 下的 gradle.properties 文件中的
systemProp.https.proxyPassword
和systemProp.http.proxyPassword
blank ,而项目根目录下的gradle.properties文件保留了密码信息。不确定确切的原因,但是当我删除项目根目录中的一个 gradle.properties 并将该文件保留在 USER_HOME/.gradle 中时,我的情况就解决了。
To add more nuances, for my case, when I have multiple gradle.properties files in both USER_HOME/.gradle and the project root, I encountered the authenticationrequired 407 error, with the bellow log:
CONNECT refused by proxy: HTTP/1.1 407 authenticationrequired
This caused my
systemProp.https.proxyPassword
andsystemProp.http.proxyPassword
blank in the gradle.properties file under USER_HOME/.gradle, while the gradle.properties file under the project root remained password info.Not sure the exact reason, But when I remove one gradle.properties in the project root and keep the file in the USER_HOME/.gradle, my case is resolved.
我发现从 gradle.properties 读取属性可能不正确。如果行包含尾部空格,gradle 无法找到代理。检查您的代理文件并剪切行尾的空格。可以帮忙
I was found that reading of properties from gradle.properties can be incorrect. In case line contains trail white space, gradle cannot find proxy. check your proxy file and cut whitespace at the end of line. Can be help
一开始这对我不起作用。
就我而言,我创建了我认为是 USER_HOME/.gradle/gradle.properties 文件,但最终得到了 gradle.properties.txt 文件。
在终端窗口中,ls 命令将显示 .gradle 文件夹中的完整文件名。
然后 mv gradle.properties.txt gradle.properties
This was not working for me at first.
In my case, I had created what I thought was a USER_HOME/.gradle/gradle.properties file but ended up with a gradle.properties.txt file.
From the terminal window an ls command will show the full file names in the .gradle folder.
Then mv gradle.properties.txt gradle.properties
我在使用 Cordova 项目时遇到了相同的代理问题。
为了解决这个问题,我在 Cordova 项目的
android
文件夹下创建了一个新的gradle.properties
文件 (hello/platforms/android
) ,并添加了您问题中的代码I have the same proxy issue while working with Cordova project.
To fix the issue, I have created a new
gradle.properties
file under theandroid
folder of my Cordova project (hello/platforms/android
), and added the code from your question设置 SSL 代理对我有用。
Setting SSl proxy worked for me.
查看此帖子了解更多信息
See this thread for more
经过多次努力解决这个问题并将我的头撞到墙上后,因为我的系统上没有任何东西正在使用代理:事实证明,我的 ** Android 模拟器实例 ** 本身正在秘密/默默地设置一个通过 Android 模拟器为我代理 >设置>代理并在几周前使用它时应用了这些设置,以便解决 Expo 的问题。
如果有人遇到此问题,请确保通过以下方式进行 100% 检查,看看是否确实没有使用自定义代理设置:
./gradlew installDebug --info --debug --stacktrace
并搜索 < code>proxyHost 在日志输出中以确保这一点。它可能是你的模拟器。After lots of struggling with this and banging my head against a wall, because nothing on my system was using a proxy: it turned out that my ** Android Emulator instance ** itself was secretly/silently setting a proxy for me via Android Emulator > Settings > Proxy and had applied these settings when playing around with it weeks earlier in order to troubleshoot an issue with Expo.
If anyone is having this issue, make sure you check 100% to see if indeed no custom proxy settings are being used via:
./gradlew installDebug --info --debug --stacktrace
and searching forproxyHost
in the log output to make sure of this. It may be your emulator.当您的 gradle 存档镜像在防火墙后面(例如我的......)时,以下内容适用:
出于某种原因,我需要这些行中的两行:
gradle.properties:
即使如此我的下载行以
https
开头,如下所示:gradle-wrapper.properties:
它无法以任何其他方式工作...除非它有效如果我使用
导出 JAVA_OPTS=-Dhttp.nonProxyHosts=localserver.co|etc
。即使我的环境变量
no_proxy
已正确设置,但如果没有上述属性中的两个值,它就无法工作。The following applies when your gradle archive is mirrored behind the firewall (like mine..):
For some reason, I needed both of these lines:
gradle.properties:
EVEN though my download line started with
https
, such as below:gradle-wrapper.properties:
It wasn't working in ANY other way... except only it worked if I used
export JAVA_OPTS=-Dhttp.nonProxyHosts=localserver.co|etc
.Even though my environment variable
no_proxy
was already correctly set, it wasn't working without the two values in the above properties.与 https 相同......
same with https......