siom79 / japicmp

Comparison of two versions of a jar archive
https://siom79.github.io/japicmp
Apache License 2.0
712 stars 107 forks source link

japicmp-maven-plugin does no longer work with OSGI Bundles #280

Closed rhierlmeier closed 2 years ago

rhierlmeier commented 3 years ago

Since the fix of issue #278 (since version 0.15.1) the japicmp-maven-plugin can no longer be used for OSGI bundles. I get the following exception:

[ERROR] Failed to retrieve comparison artifact: Failure to find 0000-999:STD_Web:bundle:2.2.2 in http://.../nexus/content/groups/public/ was cached in the local repository, resolution will not be reattempted until the update interval of DENexus has elapsed or updates are forced
org.eclipse.aether.resolution.ArtifactResolutionException: Failure to find 0000-999:STD_Web:bundle:2.2.2 in http://.../nexus/content/groups/public/ was cached in the local repository, resolution will not be reattempted until the update interval of DENexus has elapsed or updates are forced
    at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolve (DefaultArtifactResolver.java:422)
    at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifacts (DefaultArtifactResolver.java:224)
    at org.eclipse.aether.internal.impl.DefaultArtifactResolver.resolveArtifact (DefaultArtifactResolver.java:201)
    at org.eclipse.aether.internal.impl.DefaultRepositorySystem.resolveArtifact (DefaultRepositorySystem.java:260)
    at japicmp.maven.JApiCmpMojo.getComparisonArtifact (JApiCmpMojo.java:264)
    at japicmp.maven.JApiCmpMojo.populateArchivesListsFromParameters (JApiCmpMojo.java:320)
    at japicmp.maven.JApiCmpMojo.getOptions (JApiCmpMojo.java:440)
    at japicmp.maven.JApiCmpMojo.executeWithParameters (JApiCmpMojo.java:139)
    at japicmp.maven.JApiCmpMojo.execute (JApiCmpMojo.java:124)
    at org.apache.maven.plugin.DefaultBuildPluginManager.executeMojo (DefaultBuildPluginManager.java:134)

The Maven project has packaging bundle:

<project ...>
    <artifactId>STD_Web</artifactId>
    <packaging>bundle</packaging>
rhierlmeier commented 3 years ago

The problem has been introduced with commit a7d600b1bf187a1e79ab30c6487dfa5b1d4f61ef. The change in line 252 is not correct.

siom79 commented 3 years ago

I can reproduce the issue but changing line 252 of the commit does not solve the problem.

Interestingly the resolveVersionRange() call finds the bundle artifact version, but the subsequent resolveArtifact() call does not find it. But removing the extension from the resolveArtifact() call causes maven to not even find simple jar artifacts.

On the master branch I have added some small changes that map the bundle packaging to jar. I am not sure if this is correct, but in my case it resolved the issue. To be sure, I have asked a this question on stackoverflow.

rhierlmeier commented 3 years ago

I think you have to use MavenProject.getArtifact().getType() instead of MavenProject.getPackaging(). In addition you have to pass classier of to the constructor call.

miKerscher commented 3 years ago

The handling of the bundle artitacts was still not working. I made additional adjustments in PR #292. It is working with this fix on my projects.

miKerscher commented 3 years ago

Added two test bundles to PR #292.

siom79 commented 2 years ago

Fixed: 0.15.5