简体   繁体   English

Mac无法使用Gradle解决依赖关系

[英]Mac unable to resolve dependencies with gradle

I have a simple build.gradle that pulls in a few java dependencies. 我有一个简单的build.gradle,它引入了一些Java依赖项。 On my mac, gradle keeps saying that its unable to resolve dependencies for any jar. 在我的Mac上,gradle一直说它无法解析任何jar的依赖项。 This only started happening yesterday, rebooting doesn't solve this. 这只是昨天才开始发生,重新启动并不能解决问题。 I have tried running the project on linux and things work just as expected. 我尝试在Linux上运行该项目,并且一切正常。 Any idea whats up with my mac thats causing this? 您知道我的mac怎么了吗?

Cause 2: java.lang.InternalError
    [...]
    at javax.xml.parsers.SecuritySupport$4.run(SecuritySupport.java:92)
    at java.security.AccessController.doPrivileged(Native Method)
    at javax.xml.parsers.SecuritySupport.getResourceAsStream(SecuritySupport.java:87)
    at javax.xml.parsers.FactoryFinder.findJarServiceProvider(FactoryFinder.java:288)
    at javax.xml.parsers.FactoryFinder.find(FactoryFinder.java:255)
    at javax.xml.parsers.DocumentBuilderFactory.newInstance(DocumentBuilderFactory.java:121)
    at org.apache.ivy.util.XMLHelper.getDocBuilder(XMLHelper.java:208)
    at org.apache.ivy.util.XMLHelper.parseToDom(XMLHelper.java:193)
    at org.apache.ivy.plugins.parser.m2.PomReader.<init>(PomReader.java:95)
    at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.parser.GradlePomModuleDescriptorParser.parseDescriptor(GradlePomModuleDescriptorParser.java:91)
    [...]
Caused by: java.util.zip.ZipException: error in opening zip file

When I run on linux, things are working fine. 当我在linux上运行时,一切正常。

Here is my build.gradle file: 这是我的build.gradle文件:

buildscript {
  repositories {
    mavenCentral()
  }
}

task wrapper(type: Wrapper) {
  gradleVersion = '1.7'
}

apply plugin: 'scala'

repositories {
  mavenLocal()
  mavenCentral()
}

dependencies {
  compile 'org.scala-lang:scala-library:2.10.3'
  compile('com.twitter:finagle-core_2.10:6.9.0') {
    exclude group: 'junit', module: 'junit'
    exclude group: 'org.mockito', module: 'mockito-all'
    exclude group: 'org.scala-tools.testing', module: 'specs_2.10'
    exclude group: 'org.scalatest', module: 'scalatest_2.10'
  }
  compile('com.twitter:finagle-http_2.10:6.9.0') {
    exclude group: 'junit', module: 'junit'
    exclude group: 'org.mockito', module: 'mockito-all'
    exclude group: 'org.scala-tools.testing', module: 'specs_2.10'
    exclude group: 'org.scalatest', module: 'scalatest_2.10'
  }
  compile 'com.fasterxml.jackson.module:jackson-module-scala_2.10:2.3.0'
}

Using Java 7 and Gradle 1.7 使用Java 7和Gradle 1.7

Try dropping maven and/or gradle cache for the dependencies that make problems or just altogether: 尝试删除Maven和/或Gradle缓存以查找出现问题的依赖项,或者完全删除:

rm -rf ~/.gradle/
rm -rf ~/.m2/repository/

Please note that the later may lead to significant network traffic and build times next time the build is run! 请注意,稍后可能会导致大量的网络流量,并在下次运行构建时增加构建时间!

Turns out my java got corrupted; 原来我的java损坏了; reinstalling java fixed the issue 重新安装java解决了这个问题

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM