gpt4 book ai didi

java - Eclipse Gradle 插件 : cannot be read or is not a valid ZIP file

转载 作者:搜寻专家 更新时间:2023-11-01 01:42:27 25 4
gpt4 key购买 nike

我使用 gradle init 将 Maven 项目转换为 Gradle,之后 gradle install 在控制台上成功运行。然而,在 Eclipse gradle 导入之后,我收到错误:

所需库的存档:'[...].gradle/caches/modules-2/files-2.1/org.apache.jena/apache-jena-libs/2.12.0/[一些哈希值无法读取项目“myproject”中的 ]/apache-jena-libs-2.12.0.pom 或不是有效的 ZIP 文件

现在让我感到困惑的是,这个文件不是 ZIP(或 JAR)文件,而是一个 .pom 文件。为什么它会尝试以 ZIP 格式打开 POM,我该如何解决这个问题?

我在 Arch Linux 上的 Eclipse 4.4 Luna 上使用 Gradle 2.3 和 Gradle IDE 3.6.3。

最佳答案

我最近遇到了 jboss-ejb3-1.1.5.pom 的类似问题。它看起来像是 Gradle Eclipse 插件中的错误,因为 pom 类型的 Maven 依赖项包含在 .classpath 文件中。我认为它应该包含该 .pom 文件中提到的依赖项。我通过在我的 build.gradle 文件中添加一个 hack 来解决这个问题,以便在 eclipse 插件生成 .classpath 文件时不包含“.pom”文件。

eclipse {
classpath {
downloadSources = false;
// Following block of code is to remove .pom classpath entries in .classpath files
file {
whenMerged { classpath ->
Iterator i = classpath.entries.iterator()
while (i.hasNext()) {
org.gradle.plugins.ide.eclipse.model.ClasspathEntry classpathEntry = i.next()
if(classpathEntry.kind.equals('lib') && classpathEntry.path.endsWith(".pom")) {
println('Removing ' + classpathEntry + ' from classpath entry')
i.remove()
}
}
}
}
}
}

关于java - Eclipse Gradle 插件 : <some pom file> cannot be read or is not a valid ZIP file,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28561064/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com