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

Spurious failure due to too strict error checking for artifact resolution #284

Closed wardev closed 3 years ago

wardev commented 3 years ago

Hi,

First, thanks for making japicmp!

I have a pom with multiple repositories. One, of the repositories is inaccessible. The old version artifact is available from a repository further down the list. Maven's normal dependency resolution logic is fine with that, but japicmp is breaking the build. I think the problem is that the check at [1] is to strict. It checks if any errors occurred. In this case some errors occurred but the artifact was still resolved successfully. I think that line should just check if the artifact was resolved successfully. I've included below the debug output from maven which shows a successful download of the the old version artifact, and then japicmp breaking the build because it couldn't download the old version artifact.

Regards, Evan

[1] https://github.com/siom79/japicmp/blob/f0f845243b09b1f197f44514adf9a83f7581315f/japicmp-maven-plugin/src/main/java/japicmp/maven/JApiCmpMojo.java#L226

[DEBUG] Could not find metadata myGroup:myArtifact/maven-metadata.xml in central (https://repo.maven.apache.org/maven2)
[debug] Parameter <oldVersionPattern> not configured, i.e. no version filtered.
[DEBUG] Using transporter WagonTransporter with priority -1.0 for https://myRepo/offline
[DEBUG] Using connector BasicRepositoryConnector with priority 0.0 for https://myRepo/offline with username=user, password=***
Downloading from myRepo.offline: https://myRepo/offline/myGroup/myArtifact/11.2/myArtifact-11.2.jar
[DEBUG] Writing tracking file /home/user/.m2/repository/myGroup/myArtifact/11.2/myArtifact-11.2.jar.lastUpdated
[DEBUG] Using transporter WagonTransporter with priority -1.0 for https://other-repo/online
[DEBUG] Using connector BasicRepositoryConnector with priority 0.0 for https://other-repo/online
Downloading from other-repo: https://other-repo/online/myGroup/myArtifact/11.2/myArtifact-11.2.jar
Downloaded from other-repo: https://other-repo/online/myGroup/myArtifact/11.2/myArtifact-11.2.jar (364 kB at 375 kB/s)
[DEBUG] Writing tracking file /home/user/.m2/repository/myGroup/myArtifact/11.2/_remote.repositories
[DEBUG] Writing tracking file /home/user/.m2/repository/myGroup/myArtifact/11.2/myArtifact-11.2.jar.lastUpdated
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  01:34 min
[INFO] Finished at: 2021-03-05T14:17:38-05:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-site-plugin:3.9.1:site (default-site) on project myArtifact: Error generating japicmp-maven-plugin:0.15.2:cmp-report report: Failed to generate report: Could not resolve artifact: myGroup:myArtifact:jar:11.2 -> [Help 1]
siom79 commented 3 years ago

Thanks for reporting this issue. Yes, you are right. The javadoc for the getExceptions() method says:

Gets the exceptions that occurred while resolving the artifact. Note that this list can be non-empty even if the artifact was successfully resolved, e.g. when one of the contacted remote repositories didn't contain the artifact but a later repository eventually contained it.

I will only log exception and not break the build

siom79 commented 3 years ago

Fixed: 0.15.3

wardev commented 3 years ago

That worked! Thanks for the quick release!