Both Maven and Gradle have to be configured individually to communicate through a proxy.

For configuring Maven, the settings.xml file in the {user.home}/.m2/ directory has to be edited. Create a new settings.xml if it does not exist. Within that file add the following tags to allow Maven to communicate through a proxy:

<host>{IP-address of the proxy}</host>
<port>{port of the proxy}</port>
<nonProxyHosts>{excluded IP adresses}</nonProxyHosts>

To allow communication using the https protocol, use <protocol>https</protocol> or add an additional proxy configuration for https.

To configure Gradle to communicate through a proxy, the file located in the {user.home}/.gradle/ directory is modified. As with Maven, if it file does not exists, create a new one. Within that file, the properties for http and https proxies can be configured using the following expressions:

systemProp.http.proxyHost= {IP-address of the proxy}
systemProp.http.proxyPort= {port of the proxy}
systemProp.http.nonProxyHost= {excluded IP adresses}

systemProp.https.proxyHost= {IP-address of the proxy}
systemProp.https.proxyPort= {port of the proxy}
systemProp.https.nonProxyHost= {excluded IP adresses}

In both Maven and Gradle configurations, the nonProxyHost property marks IP addresses which should be accessed without communicating through the proxy.

Using Maven and Gradle through proxy

Because of my working environment, I have to set up Gradle and Maven to use a proxy server without password authentication. Only setting up the operating system to use a proxy is not sufficient, as I cannot establish network communication using Maven or Gradle. How can I configure the tools to communicate through a proxy?

It might be possible 1) to also make use of a proxy server, configuring it appropriately in your operating system or in your browser. There are also some free public proxy servers, which are rather slow. Another potential solution is 2) to use one of the so-called DNS redirectors. Be also aware of possible resulting breaches of the respective law :)

Providing the network of a school class with internet access

The aim was to provide an internet connection for our class network.


Subscribe to Proxy