eclipse-m2e / m2e-core

Eclipse Public License 2.0
110 stars 112 forks source link

Fail to load a target platform referencing a JAR-less Maven module #1567

Open sboucard opened 1 year ago

sboucard commented 1 year ago

Steps to reproduce:

  1. Use Eclipse 2023-06 (the bug is not present with a previous version)
  2. Create a target platform (*.target) and edit it with the Target Editor
  3. Add the following Maven module and save ` org.eclipse.lyo.oslc4j.core oslc4j-core 4.1.0

    `

This makes the target platform to show this message:

Problems occurred getting the plug-ins in this container org.eclipse.lyo.oslc4j.core:oslc4j-core:jar:4.1.0 is not a bundle and cannot be automatically bundled as such (Can't collect dependencies!)

The stack trace is the following: org.eclipse.core.runtime.CoreException: Can't collect dependencies! at org.eclipse.m2e.pde.target.MavenTargetBundle.lambda$2(MavenTargetBundle.java:164) at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.executeBare(MavenExecutionContext.java:394) at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:275) at org.eclipse.m2e.core.internal.embedder.MavenExecutionContext.execute(MavenExecutionContext.java:214) at org.eclipse.m2e.pde.target.MavenTargetBundle.getWrappedArtifact(MavenTargetBundle.java:137) at org.eclipse.m2e.pde.target.MavenTargetBundle.<init>(MavenTargetBundle.java:102) at org.eclipse.m2e.pde.target.MavenTargetLocation.addBundleForArtifact(MavenTargetLocation.java:356) at org.eclipse.m2e.pde.target.MavenTargetLocation.resolveDependency(MavenTargetLocation.java:265) at org.eclipse.m2e.pde.target.MavenTargetLocation.resolveArtifacts(MavenTargetLocation.java:170) at org.eclipse.m2e.pde.target.MavenTargetLocation.resolveBundles(MavenTargetLocation.java:157) at org.eclipse.pde.internal.core.target.AbstractBundleContainer.resolve(AbstractBundleContainer.java:97) at org.eclipse.pde.internal.core.target.TargetDefinition.resolve(TargetDefinition.java:429) at org.eclipse.pde.internal.ui.editor.targetdefinition.TargetEditor$TargetChangedListener$1.run(TargetEditor.java:651) at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63) Caused by: java.util.zip.ZipException: The JAR/ZIP file (D:\Users\sboucard\.m2\repository\org\apache\jena\apache-jena-libs\3.16.0\apache-jena-libs-3.16.0.pom) seems corrupted, error: zip END header not found at aQute.bnd.osgi.Jar.buildFromZip(Jar.java:312) at aQute.bnd.osgi.Jar.<init>(Jar.java:139) at aQute.bnd.osgi.Jar.<init>(Jar.java:237) at org.eclipse.m2e.pde.target.shared.MavenBundleWrapper.getWrappedNode(MavenBundleWrapper.java:166) at org.eclipse.m2e.pde.target.shared.MavenBundleWrapper.getWrappedNode(MavenBundleWrapper.java:178) at org.eclipse.m2e.pde.target.shared.MavenBundleWrapper.getWrappedArtifact(MavenBundleWrapper.java:137) at org.eclipse.m2e.pde.target.MavenTargetBundle.lambda$2(MavenTargetBundle.java:141) ... 13 more Caused by: java.util.zip.ZipException: zip END header not found at java.base/java.util.zip.ZipFile$Source.findEND(ZipFile.java:1469) at java.base/java.util.zip.ZipFile$Source.initCEN(ZipFile.java:1477) at java.base/java.util.zip.ZipFile$Source.<init>(ZipFile.java:1315) at java.base/java.util.zip.ZipFile$Source.get(ZipFile.java:1277) at java.base/java.util.zip.ZipFile$CleanableResource.<init>(ZipFile.java:709) at java.base/java.util.zip.ZipFile.<init>(ZipFile.java:243) at java.base/java.util.zip.ZipFile.<init>(ZipFile.java:172) at java.base/java.util.zip.ZipFile.<init>(ZipFile.java:186) at aQute.bnd.osgi.Jar.buildFromZip(Jar.java:301) ... 19 more

The oslc4j-core 4.1.0 module depends on apache-jena-libs 3.16.0, which does not define any JAR file. M2E seems to try parsing apache-jena-libs-3.16.0.pom as a JAR file, and fails doing so.

laeubi commented 1 year ago

@sboucard can you please check with the oslc4j-core 4.1.0 project why they have a compile dependency on a pom?

Nerveless this should be quite easy to fix (I think it is similar to

can you please provide a PR to add your mentioned reproducer as a test-case here: https://github.com/eclipse-m2e/m2e-core/blob/master/org.eclipse.m2e.pde.target.tests/src/org/eclipse/m2e/pde/target/tests/OSGiMetadataGenerationTest.java

sboucard commented 1 year ago

The apache-jena-libs module is there to easily get transitive dependencies to the numerous modules that compose Apache Jena. As such, it does not deliver code but will help retrieving a lot of JAR files. I can understand oslc4j-core to have a compile dependency on apache-jena-libs, as it indeed requires all those JAR files to compile. But I'm not a Maven expert, there might be better ways to express this.