Home >Java >javaTutorial >How to Configure Gradle Proxy Settings for Web Access?

How to Configure Gradle Proxy Settings for Web Access?

Mary-Kate Olsen
Mary-Kate OlsenOriginal
2024-11-02 23:05:30348browse

How to Configure Gradle Proxy Settings for Web Access?

Gradle Proxy Configuration for Web Access

Gradle integration with Artifactory in Jenkins requires web access via a proxy server. Configuring this proxy connection can be challenging, especially when using a backslash in the proxy username or when multiple proxy servers are present.

To specify proxy settings for Gradle, create a .gradle/gradle.properties file in your home directory and include the following properties:

systemProp.http.proxyHost = hostname
systemProp.http.proxyPort = 8080
systemProp.http.proxyUser = de\username
systemProp.http.proxyPassword = xxx

However, this configuration may lead to HTTP 407 errors. To overcome these issues, use the following refinement based on Daniel's response:

HTTP Only Proxy Configuration:

gradlew -Dhttp.proxyHost=127.0.0.1 -Dhttp.proxyPort=3128 "-Dhttp.nonProxyHosts=*.nonproxyrepos.com|localhost"

HTTPS Only Proxy Configuration:

gradlew -Dhttps.proxyHost=127.0.0.1 -Dhttps.proxyPort=3129 "-Dhttp.nonProxyHosts=*.nonproxyrepos.com|localhost"

Both HTTP and HTTPS Proxy Configuration:

gradlew -Dhttp.proxyHost=127.0.0.1 -Dhttp.proxyPort=3128 -Dhttps.proxyHost=127.0.0.1 -Dhttps.proxyPort=3129 "-Dhttp.nonProxyHosts=*.nonproxyrepos.com|localhost"

Proxy Configuration with User and Password:

gradlew -Dhttp.proxyHost=127.0.0.1 -Dhttp.proxyPort=3128 -Dhttps.proxyHost=127.0.0.1 -Dhttps.proxyPort=3129 -Dhttps.proxyUser=user -Dhttps.proxyPassword=pass -Dhttp.proxyUser=user -Dhttp.proxyPassword=pass "-Dhttp.nonProxyHosts=host1.com|host2.com"

These properties can also be added to the gradle-wrapper.properties file. Alternatively, setting these options in Jenkins' or Artifactory's GUI should also work.

The above is the detailed content of How to Configure Gradle Proxy Settings for Web Access?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn