Issue: org.xtext.builder tries to read pom.xml on dirtyClasspathEntry as Jar

I am migrating from Maven to Gradle. My Gradle dependencies were initially created by calling ‘gradle init’ > and choosing to generate a Gradle build from my legacy Maven build. ‘gradle init’ thus generated dependencies including dependency pom artifacts:

dependencies {
    [..]
    api 'com.rockwell.delivery.ps:all-pharmasuite-dsx-digest:11.1.0.HF5.1-SNAPSHOT'

This artifact is in fact a pom file. There is no jar by this GAV.
:question: Question: Are dependency poms valid as Gradle dependencies?

In any case, org.xtext.builder does not handle this dependency correctly.
I am using org.xtext.builder 4.0.0 to process our DSL. Calling generateXtext failes with:

* What went wrong:
Execution failed for task 'generateXtext'.
> java.util.zip.ZipException: zip END header not found

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task 'generateXtext'.
[..]
Caused by: java.util.zip.ZipException: zip END header not found
        at org.eclipse.xtext.mwe.PathTraverser.traverseArchive(PathTraverser.java:58)

Debugging into org.xtext.builder I find org.xtext.gradle.builder.XtextGradleBuilder.indexChangedClasspathEntries() is calling PathTraverser().findAllResourceUris(dirtyClasspathEntry.path) with the path to my dependencyManagement pom.xml.

:bangbang: TODO: PathTraverser.traverseArchive(PathTraverser.java:58) - the code that tries to open this path as ZipFile - would greatly profit from error handling that logs a descriptive error message. :wink:

Question: Are dependency poms valid as Gradle dependencies?

Depends on what you mean by “dependency pom”.
If you mean having a pom as dependency, sure, just does most probably not make any sense.
If you mean a BOM that defines versions for other artifacts, then you need to use platform(...).

Calling generateXtext failes with:

Sounds like a bug in that plugin to me.
While it is not too common to have non-archive files there, it is perfectly valid and the plugin should cope with it imho, so I’d suggest you open a bug with that project.
As a work-around, just remove it if it is not necessary anyway.

1 Like