在Win7上将gradle从1.12升级到2.4后,在gradle项目中无法再解析依赖关系。
实际上,在同一个终端(windows中的bash终端)中,这成功了:
$ /c/Program\ Files\ \(x86\)/gradle-1.12/bin/gradle dependencies
:dependencies
------------------------------------------------------------
Root project - MyProject
------------------------------------------------------------
archives - Configuration for archive artifacts.
No dependencies
compile - Compile classpath for source set 'main'.
Download http://repo1.maven.org/maven2/com/sun/mail/mailapi/1.5.4/mailapi-1.5.4.pom
Download http://repo1.maven.org/maven2/com/sun/mail/all/1.5.4/all-1.5.4.pom
Download http://repo1.maven.org/maven2/net/java/jvnet-parent/1/jvnet-parent-1.pom
Download http://repo1.maven.org/maven2/com/sun/mail/smtp/1.5.4/smtp-1.5.4.pom
Download http://repo1.maven.org/maven2/com/sun/mail/parent-distrib/1.5.4/parent-distrib-1.5.4.pom
Download http://repo1.maven.org/maven2/com/sun/mail/dsn/1.5.4/dsn-1.5.4.pom
Download http://repo1.maven.org/maven2/com/google/code/gson/gson/2.3/gson-2.3.pom
Download http://repo1.maven.org/maven2/org/sonatype/oss/oss-parent/9/oss-parent-9.pom
Download http://repo1.maven.org/maven2/org/apache/logging/log4j/log4j-core/2.3/log4j-core-2.3.pom
Download http://repo1.maven.org/maven2/org/apache/logging/log4j/log4j/2.3/log4j-2.3.pom
Download http://repo1.maven.org/maven2/org/apache/apache/9/apache-9.pom
Download http://repo1.maven.org/maven2/javax/activation/activation/1.1/activation-1.1.pom
Download http://repo1.maven.org/maven2/com/sun/mail/javax.mail/1.5.4/javax.mail-1.5.4.pom
Download http://repo1.maven.org/maven2/org/apache/logging/log4j/log4j-api/2.3/log4j-api-2.3.pom
+--- :Support:
+--- com.sun.mail:mailapi:1.5.4
| \--- javax.activation:activation:1.1
+--- com.sun.mail:smtp:1.5.4
| \--- javax.activation:activation:1.1
+--- com.sun.mail:dsn:1.5.4
| +--- com.sun.mail:javax.mail:1.5.4
| | \--- javax.activation:activation:1.1
| \--- javax.activation:activation:1.1
+--- com.google.code.gson:gson:2.3
\--- org.apache.logging.log4j:log4j-core:2.3
\--- org.apache.logging.log4j:log4j-api:2.3
...
虽然失败了:
$ /c/Program\ Files\ \(x86\)/gradle-2.4/bin/gradle dependencies
:dependencies
------------------------------------------------------------
Root project - MyProject
------------------------------------------------------------
archives - Configuration for archive artifacts.
No dependencies
compile - Compile classpath for source set 'main'.
+--- :Support:
+--- com.sun.mail:mailapi:1.5.4 FAILED
+--- com.sun.mail:smtp:1.5.4 FAILED
+--- com.sun.mail:dsn:1.5.4 FAILED
+--- com.google.code.gson:gson:2.3 FAILED
\--- org.apache.logging.log4j:log4j-core:2.3 FAILED
...
我已经尝试过这个:
- 从3.1.1升级到3.3.3的maven升级
- 更新了PATH以访问新的gradle-2.4和maven-3.3.3
- 重新打开Windows会话
- 杀死了gradle守护进程
- 删除〜/ .gradle /缓存
- 删除〜/ .gradle并使用相同的gradle.properties
重新创建一个空的
- 删除了〜/ .m2 / repository
- 检查了本地cntlm代理配置(gradle-1.12可以很好地访问它)
- 尝试使用参数“-Dhttp_proxyHost=127.0.0.1 -Dhttp_proxyPort=3128 -Dhttps_proxyHost=127.0.0.1 -Dhttps_proxyPort=3129
”
感谢您的任何建议。
gradle.build的内容:
apply plugin: 'java'
apply plugin: 'maven'
group = 'my.project'
version = '0.0.1-SNAPSHOT'
description = "MyProject"
sourceCompatibility = 1.7
targetCompatibility = 1.7
//
// dependencies
//
repositories {
mavenCentral()
flatDir { dirs 'ext' }
}
dependencies {
compile name : 'Support'
compile group: 'com.sun.mail' , name: 'mailapi' , version:'1.5.4'
compile group: 'com.sun.mail' , name: 'smtp' , version:'1.5.4'
compile group: 'com.sun.mail' , name: 'dsn' , version:'1.5.4'
compile group: 'com.google.code.gson' , name: 'gson' , version:'2.3'
compile group: 'org.apache.logging.log4j', name: 'log4j-core', version:'2.3'
testCompile group: 'org.easymock' , name: 'easymock' , version:'3.3'
testCompile group: 'junit' , name: 'junit' , version:'4.12'
}
答案 0 :(得分:1)
在Gradle 2.1中,他们switched mavenCentral()
从HTTP到HTTPS。也许您的代理在使用HTTPS时遇到了一些问题(或者gradle在使用HTTPS时遇到代理问题)。您可以使用以下代码切换回HTTP(永久或仅测试此假设),该代码取自上述发行说明:
repositories {
// note: this replaces mavenCentral()
maven { url = 'http://repo1.maven.org/maven2/' }
}
另请参阅gradle用户指南中有关代理配置的“Accessing the web via a proxy”。