Gradlew 在代理后面

发布于 2024-12-28 04:29:35 字数 337 浏览 1 评论 0原文

我有一个来自 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(18

默嘫て 2025-01-04 04:29:35

您所要做的就是创建一个名为 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 to USER_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

热风软妹 2025-01-04 04:29:35

如果您需要在代理后面进行 https 访问,请考虑为 systemProp.https 定义相同的属性集。

systemProp.https.proxyHost=www.somehost.org
systemProp.https.proxyPort=8080

请参阅 无法在 VPN 后面使用 crashlytics 构建 Android 应用程序和代理以获取更多信息。

If you need https access behind a proxy, please consider defining also the same set of properties for systemProp.https.

systemProp.https.proxyHost=www.somehost.org
systemProp.https.proxyPort=8080

See Can't build Android app using crashlytics behind VPN and proxy for more information.

莳間冲淡了誓言ζ 2025-01-04 04:29:35

如果您要通过代理下载包装器,请在您的 gradle.properties 文件和 gradle/wrapper/gradle-wrapper.properties 文件中添加以下内容

如果您想设置全局这些属性,然后将其添加到 USER_HOME/.gradle/gradle.properties 文件中

## Proxy setup
systemProp.proxySet=true
systemProp.http.keepAlive=true
systemProp.http.proxyHost=host
systemProp.http.proxyPort=port
systemProp.http.proxyUser=username
systemProp.http.proxyPassword=password
systemProp.http.nonProxyHosts=local.net|some.host.com

systemProp.https.keepAlive=true
systemProp.https.proxyHost=host
systemProp.https.proxyPort=port
systemProp.https.proxyUser=username
systemProp.https.proxyPassword=password
systemProp.https.nonProxyHosts=local.net|some.host.com
## end of proxy setup

Add the below in your gradle.properties file and in your gradle/wrapper/gradle-wrapper.properties file if you are downloading the wrapper over a proxy

If you want to set these properties globally then add it in USER_HOME/.gradle/gradle.properties file

## Proxy setup
systemProp.proxySet=true
systemProp.http.keepAlive=true
systemProp.http.proxyHost=host
systemProp.http.proxyPort=port
systemProp.http.proxyUser=username
systemProp.http.proxyPassword=password
systemProp.http.nonProxyHosts=local.net|some.host.com

systemProp.https.keepAlive=true
systemProp.https.proxyHost=host
systemProp.https.proxyPort=port
systemProp.https.proxyUser=username
systemProp.https.proxyPassword=password
systemProp.https.nonProxyHosts=local.net|some.host.com
## end of proxy setup
风月客 2025-01-04 04:29:35

在提示行中使用它:

gradle -Dhttp.proxyHost=***  -Dhttp.proxyPort=*** -Dhttp.proxyUser=**** -Dhttp.proxyPassword=****

在这里工作!

Use this in prompt line:

gradle -Dhttp.proxyHost=***  -Dhttp.proxyPort=*** -Dhttp.proxyUser=**** -Dhttp.proxyPassword=****

Works here!

一梦浮鱼 2025-01-04 04:29:35

在设置 https 代理之前,我无法使代理属性正常工作:

systemProp.https.proxyHost=www.somehost.org
systemProp.https.proxyPort=8080

但是我必须使用 http 属性作为用户名和密码:

systemProp.http.proxyUser=userid
systemProp.http.proxyPassword=password

I could not get the proxy property to work until I set the https proxy:

systemProp.https.proxyHost=www.somehost.org
systemProp.https.proxyPort=8080

However I had to use the http property for user name and password:

systemProp.http.proxyUser=userid
systemProp.http.proxyPassword=password
待天淡蓝洁白时 2025-01-04 04:29:35

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.

眼中杀气 2025-01-04 04:29:35

JDK更新之后,我无法使用gradlew 再次位于代理后面。
最后我发现 JDK 默认禁用了 HTTPS 隧道的基本身份验证。
所以除了代理设置之外,我还必须为 gradle.properties 添加此属性,

systemProp.jdk.http.auth.tunneling.disabledSchemes=""

我希望这对遇到同样问题的人有帮助

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

systemProp.jdk.http.auth.tunneling.disabledSchemes=""

I hope it would be helpful for someone who struggle same problem

衣神在巴黎 2025-01-04 04:29:35

我遇到了同样的问题,我做的第一件事就是创建 gradle.properties。我没有这样的文件,所以我应该使用以下内容创建它:

systemProp.http.proxyHost=proxy
systemProp.http.proxyPort=port
systemProp.http.nonProxyHosts=domainname|localhost
systemProp.https.proxyHost=proxy
systemProp.https.proxyPort=port
systemProp.https.nonProxyHosts=domainname|localhost

当我添加它们时,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:

systemProp.http.proxyHost=proxy
systemProp.http.proxyPort=port
systemProp.http.nonProxyHosts=domainname|localhost
systemProp.https.proxyHost=proxy
systemProp.https.proxyPort=port
systemProp.https.nonProxyHosts=domainname|localhost

When I added them gradlew command works properly behind corporate proxy. I hope that it can be useful.

不醒的梦 2025-01-04 04:29:35

为了添加更多细微差别,对于我的情况,当我在 USER_HOME/.gradle 和项目根目录中都有多个 gradle.properties 文件时,我遇到了authenticationrequired 407 错误,日志如下:

CONNECT 被代理拒绝:HTTP/1.1 407 需要身份验证

这导致我的 USER_HOME/.gradle 下的 gradle.properties 文件中的 systemProp.https.proxyPasswordsystemProp.http.proxyPasswordblank ,而项目根目录下的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 and systemProp.http.proxyPasswordblank 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.

走野 2025-01-04 04:29:35

我发现从 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

坐在坟头思考人生 2025-01-04 04:29:35

一开始这对我不起作用。
就我而言,我创建了我认为是 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

只为守护你 2025-01-04 04:29:35

我在使用 Cordova 项目时遇到了相同的代理问题。

为了解决这个问题,我在 Cordova 项目的 android 文件夹下创建了一个新的 gradle.properties 文件 (hello/platforms/android) ,并添加了您问题中的代码

systemProp.http.proxyHost=proxy.yourproxysite.com
systemProp.http.proxyPort=8080
systemProp.http.proxyUser=yourusername
systemProp.http.proxyPassword=password

I have the same proxy issue while working with Cordova project.

To fix the issue, I have created a new gradle.properties file under the android folder of my Cordova project (hello/platforms/android), and added the code from your question

systemProp.http.proxyHost=proxy.yourproxysite.com
systemProp.http.proxyPort=8080
systemProp.http.proxyUser=yourusername
systemProp.http.proxyPassword=password
喵星人汪星人 2025-01-04 04:29:35

设置 SSL 代理对我有用。

systemProp.http.proxyHost=proxy.yourproxysite.com
systemProp.http.proxyPort=8080
systemProp.https.proxyHost=proxy.yourproxysite.com
systemProp.https.proxyPort=8080

Setting SSl proxy worked for me.

systemProp.http.proxyHost=proxy.yourproxysite.com
systemProp.http.proxyPort=8080
systemProp.https.proxyHost=proxy.yourproxysite.com
systemProp.https.proxyPort=8080
策马西风 2025-01-04 04:29:35

摘自下面链接主题的答案。它显示了如何做
这更具程序性。希望对您有帮助

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())
        }
    }
}

查看此帖子了解更多信息

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

能否归途做我良人 2025-01-04 04:29:35

经过多次努力解决这个问题并将我的头撞到墙上后,因为我的系统上没有任何东西正在使用代理:事实证明,我的 ** 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 for proxyHost in the log output to make sure of this. It may be your emulator.

同尘 2025-01-04 04:29:35

当您的 gradle 存档镜像在防火墙后面(例如我的......)时,以下内容适用:

出于某种原因,我需要这些行中的两行

gradle.properties:

systemProp.http.nonProxyHosts=*.localserver.co
systemProp.https.nonProxyHosts=*.localserver.co

即使如此我的下载行以 https 开头,如下所示:

gradle-wrapper.properties:

distributionUrl=https\://s.localserver.co/gradle-7.0.1-bin.zip

它无法以任何其他方式工作...除非它有效如果我使用 导出 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:

systemProp.http.nonProxyHosts=*.localserver.co
systemProp.https.nonProxyHosts=*.localserver.co

EVEN though my download line started with https, such as below:

gradle-wrapper.properties:

distributionUrl=https\://s.localserver.co/gradle-7.0.1-bin.zip

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.

如果没结果 2025-01-04 04:29:35
gradlew.bat clean build -Dhttps.proxyHost=pushit-proxy.com -Dhttps.proxyPort=8080 -Dhttps.proxyUser=koacervate -Dhttps.proxyPassword=myShitP@$w0rd
gradlew.bat clean build -Dhttps.proxyHost=pushit-proxy.com -Dhttps.proxyPort=8080 -Dhttps.proxyUser=koacervate -Dhttps.proxyPassword=myShitP@$w0rd
戏舞 2025-01-04 04:29:35
systemProp.http.proxyUser=userId
systemProp.http.proxyPassword=password

与 https 相同......

systemProp.http.proxyUser=userId
systemProp.http.proxyPassword=password

same with https......

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文