Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

A Build Issue when using gradle

Tags:

gradle

I'm trying to build a opensource Java project, lilith, with gradle. But meet this problem when runing gradle from cmd line window:

D:\Opensource\lilith_svn\sulky-master>gradle

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring root project 'sulky-master'.
> Could not resolve all dependencies for configuration ':classpath'.
   > Could not resolve org.apache.maven.wagon:wagon-webdav-jackrabbit:1.0-beta-6
.
     Required by:
         :sulky-master:unspecified
      > Could not GET 'http://repo1.maven.org/maven2/org/apache/maven/wagon/wagon-webdav-jackrabbit/1.0-beta-6/wagon-webdav-jackrabbit-1.0-beta-6.pom'.
         > Connection to http://repo1.maven.org refused
      > Could not resolve com.github.ben-manes:gradle-versions-plugin:0.4.
     Required by:
         :sulky-master:unspecified
      > Could not GET 'http://repo1.maven.org/maven2/com/github/ben-manes/gradle-versions-plugin/0.4/gradle-versions-plugin-0.4.pom'.
         > Connection to http://repo1.maven.org refused

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug
option to get more log output.

BUILD FAILED

Total time: 44.897 secs   

I found I can access the destination file from my web browser. So I'm confused about the error message about the connection failure.

Or does that mean the gradle program does not have the right to access internet? If so, please give some workaround for it.

Thanks, Terry.

like image 257
Terry.Su Avatar asked Oct 09 '13 06:10

Terry.Su


2 Answers

Open gradle.properties and add the following

systemProp.http.proxyHost=127.0.0.1
systemProp.http.proxyPort=3213
systemProp.https.proxyHost=127.0.0.1
systemProp.https.proxyPort=3213

(Your settings might be different. My case was I was sharing a VPN connection by Astrill from another computer. See http://gradle.org/docs/current/userguide/build_environment.html for more information.)

like image 114
Bugs Bunny Avatar answered Oct 21 '22 13:10

Bugs Bunny


To add to what @Bugs Bunny said:

If you have set “GRADLE_USER_HOME” environment variable pointing to C:\Documents and Settings\myAccount.gradle you can put gradle.properties in that .gradle directory. A copy of gradle.properties file can be found at C:\gradle-2.13\samples\userguide\tutorial\properties\gradle.properties. But it doesn't have the proxyHost settings.

I would add the following to gradle.properties:

systemProp.http.proxyHost=proxy_address
systemProp.http.proxyPort=8080
systemProp.http.proxyUser=my_user_name
systemProp.http.proxyPassword=my_secret_password

systemProp.https.proxyHost=proxy_address
systemProp.https.proxyPort=8080
systemProp.https.proxyUser=my_user_name
systemProp.https.proxyPassword=my_secret_password
like image 26
mycowan Avatar answered Oct 21 '22 13:10

mycowan