使用gradle时的构建问题

时间:2013-10-09 06:24:45

标签: gradle

我正在尝试用gradle构建一个开源Java项目,lilith。但是从cmd行窗口运行gradle时遇到此问题:

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   

我发现我可以从网络浏览器访问目标文件。所以我对关于连接失败的错误消息感到困惑。

或者这是否意味着gradle程序无权访问互联网?如果是这样,请给它一些解决方法。

谢谢, 特里。

2 个答案:

答案 0 :(得分:12)

打开gradle.properties并添加以下内容

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

(您的设置可能有所不同。我的情况是我在另一台计算机上与Astrill共享VPN连接。有关详细信息,请参阅http://gradle.org/docs/current/userguide/build_environment.html。)

答案 1 :(得分:2)

添加@Bugs Bunny说的话:

如果已将“GRADLE_USER_HOME”环境变量设置为指向C:\ Documents and Settings \ myAccount.gradle,则可以将gradle.properties放在该.gradle目录中。可以在以下位置找到gradle.properties文件的副本 C:\ gradle这个-2.13 \样品\ userguide \教程\特性\ gradle.properties。但它没有proxyHost设置。

我会将以下内容添加到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