Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Eclipse Gradle Plugin: <some pom file> cannot be read or is not a valid ZIP file

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.

like image 781
Konrad Höffner Avatar asked Feb 17 '15 12:02

Konrad Höffner


1 Answers

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()
                            }
                        }
                    }
                }
            }
        }
like image 84
user872858 Avatar answered Oct 01 '22 06:10

user872858