I converted a Maven project to Gradle using gradle init
after which gradle install
successfully runs on the console. After an Eclipse gradle import, however, I get the error:
Archive for required library: '[...].gradle/caches/modules-2/files-2.1/org.apache.jena/apache-jena-libs/2.12.0/[some hash value]/apache-jena-libs-2.12.0.pom' in project 'myproject' cannot be read or is not a valid ZIP file
.
Now what baffles me is that this file is not a ZIP (or JAR) file but a .pom file. Why does it try to open a POM as a ZIP and how can I fix this?
I use Gradle 2.3 with the Gradle IDE 3.6.3 on Eclipse 4.4 Luna on Arch Linux.
I've had a similar issue recently for jboss-ejb3-1.1.5.pom. It looks like a bug in Gradle Eclipse plugin because maven dependencies of type pom are included in the .classpath file. I think it should instead include dependencies mentioned within that .pom file. I get around this issue by adding a hack in my build.gradle file to not to include '.pom' files when eclipse plugin generates .classpath file.
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()
}
}
}
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With