Configure proxy in Gradle | Gradle properties | Using Command Line

To configure a proxy in Gradle, you can make use of the Gradle properties file or provide command-line arguments. Here are two common approaches to configuring a proxy in Gradle:

Gradle Properties File:

Step 1: Locate the file in your Gradle project or create one if it doesn’t exist.

Step 2: Open the file and add the following lines:

Note: Replace and 8080 with the appropriate values for your proxy host and port.

Step 3: Save the file.

Gradle will automatically pick up these properties and use them as proxy configurations when executing tasks.

Command-line Arguments

Step 1: Open your terminal or command prompt.

Step 2: Run your Gradle command with the following additional arguments:

gradle <task> -Dhttp.proxyPort=8080 -Dhttps.proxyPort=8080

Note: Replace <task> with the specific Gradle task, you want to execute. Adjust the proxy host and port values ( and 8080) according to your proxy configuration.

Step 3: Execute the command, and Gradle will use the provided proxy settings for the given task.

By following either of these methods, you can configure a proxy in Gradle. Whether you choose to use the file or command-line arguments depends on your preference and the level of configuration flexibility you require for different environments.

In case you are using the maven tool then you can follow the steps to configure the proxy below article:

Configure proxy in Maven

Leave a Comment