Setup Grails 3 Behind Proxy
Most companies have set up proxy to protect, and speed up their network, but grails
, and gradle
would not download the libraries needed correctly behind the proxy without proper setup.
Proxy Setting for Grails
- Go to the path you install grails.
- Inside, go to the path
bin
. My case would beD:\grails-3.3.6\bin
. - Use a text editor to open the file
grails.bat
. - Find the line start with
set DEFAULT_JVM_OPTS
, and change it to (in one line)set DEFAULT_JVM_OPTS="-XX:+TieredCompilation" "-XX:TieredStopAtLevel=1" "-XX:CICompilerCount=3" "-Dhttp.proxyHost=THE_PROXY_PATH" "-Dhttp.proxyPort=THE_PROXY_PORT" "-Dhttp.proxyUser=YOUR_USERNAME" "-Dhttp.proxyPassword=YOUR_PASSWORD" "-Dhttps.proxyHost=THE_PROXY_PATH" "-Dhttps.proxyPort=THE_PROXY_PORT" "-Dhttps.proxyUser=YOUR_USERNAME" "-Dhttps.proxyPassword=YOUR_PASSWORD"
- Please change the values of
THE_PROXY_PATH
,THE_PROXY_PORT
,YOUR_USERNAME
,YOUR_PASSWORD
according to your own setting. - Depending on the proxy server, some of them might only provide http, or https service.
- Depending on the proxy server, some of them might not require the user name, and password path.
- In either case, your have to omitted the unnecessary parts for the above code.
- Save the file.
Proxy Setting for maven or gradle
- Go to your own user directory. For Windows 10, it would be
C:\Users\YOUR_LOGIN\
- Go inside the directory called
.m2
. - Add a file named
settings.xml
. - Open settings.xml with a text editor.
- Add the following code in such file.
<settings> <proxies> <proxy> <id>http</id> <active>true</active> <protocol>http</protocol> <host>THE_PROXY_PATH<host> <port>THE_PROXY_PORT</port> <username>YOUR_USER_NAME</username> <password>YOUR_PASSWORD</password> </proxy> <proxy> <id>https</id> <active>true</active> <protocol>https</protocol> <host>THE_PROXY_PATH</host> <port>THE_PROXY_PORT</port> <username>YOUR_USER_NAME</username> <password>YOUR_PASSWORD</password> </proxy> </proxies> </settings>
- Depending on the proxy server, some of them might only provide http, or https service.
- Depending on the proxy server, some of them might not require the user name, and password path.
- In either case, your have to omitted the unnecessary parts for the above code.
- Save the file.