diff --git a/japicmp-maven-plugin/src/main/java/japicmp/maven/JApiCmpMojo.java b/japicmp-maven-plugin/src/main/java/japicmp/maven/JApiCmpMojo.java index c7b3de42d..ae525bd58 100644 --- a/japicmp-maven-plugin/src/main/java/japicmp/maven/JApiCmpMojo.java +++ b/japicmp-maven-plugin/src/main/java/japicmp/maven/JApiCmpMojo.java @@ -206,7 +206,8 @@ private enum ConfigurationVersion { OLD, NEW } - private Artifact getComparisonArtifact(final MavenParameters mavenParameters, final PluginParameters pluginParameters) throws MojoFailureException, MojoExecutionException { + private Artifact getComparisonArtifact(final MavenParameters mavenParameters, final PluginParameters pluginParameters, + final ConfigurationVersion configurationVersion) throws MojoFailureException, MojoExecutionException { MavenProject mavenProject = mavenParameters.getMavenProject(); DefaultArtifact artifactVersionRange = new DefaultArtifact(mavenProject.getGroupId(), mavenProject.getArtifactId(), mavenProject.getPackaging(), mavenParameters.getVersionRangeWithProjectVersion()); VersionRangeRequest versionRangeRequest = new VersionRangeRequest(artifactVersionRange, mavenParameters.getRemoteRepos(), null); @@ -223,9 +224,7 @@ private Artifact getComparisonArtifact(final MavenParameters mavenParameters, fi versions.get(versions.size()-1).toString()); ArtifactRequest artifactRequest = new ArtifactRequest(artifactVersion, mavenParameters.getRemoteRepos(), null); ArtifactResult artifactResult = mavenParameters.getRepoSystem().resolveArtifact(mavenParameters.getRepoSession(), artifactRequest); - if (artifactResult.isMissing() || (artifactResult.getExceptions() != null && !artifactResult.getExceptions().isEmpty())){ - throw new MojoFailureException("Could not resolve artifact: " + artifactVersion); - } + processArtifacResult(artifactVersion, artifactResult, pluginParameters, configurationVersion); return artifactResult.getArtifact(); } else { throw new MojoFailureException("Could not find previous version for artifact: " + artifactVersionRange.getGroupId() + ":" @@ -237,6 +236,23 @@ private Artifact getComparisonArtifact(final MavenParameters mavenParameters, fi } } + private void processArtifacResult(DefaultArtifact artifactVersion, ArtifactResult artifactResult, + PluginParameters pluginParameters, ConfigurationVersion configurationVersion) throws MojoFailureException { + if (artifactResult.getExceptions() != null && !artifactResult.getExceptions().isEmpty()) { + List exceptions = artifactResult.getExceptions(); + for (Exception exception : exceptions) { + getLog().debug(exception.getMessage(), exception); + } + } + if (artifactResult.isMissing()){ + if (ignoreMissingArtifact(pluginParameters, configurationVersion)) { + getLog().warn("Ignoring missing artifact: " + artifactResult.getArtifact()); + } else { + throw new MojoFailureException("Could not resolve artifact: " + artifactVersion); + } + } + } + private void filterVersionPattern(List availableVersions, PluginParameters pluginParameters) throws MojoFailureException { if (pluginParameters.getParameterParam() != null && pluginParameters.getParameterParam().getOldVersionPattern() != null) { String versionPattern = pluginParameters.getParameterParam().getOldVersionPattern(); @@ -278,7 +294,7 @@ private void populateArchivesListsFromParameters(PluginParameters pluginParamete } if (pluginParameters.getOldVersionParam() == null && pluginParameters.getOldVersionsParam() == null) { try { - Artifact comparisonArtifact = getComparisonArtifact(mavenParameters, pluginParameters); + Artifact comparisonArtifact = getComparisonArtifact(mavenParameters, pluginParameters, ConfigurationVersion.OLD); if (comparisonArtifact.getVersion() != null) { Set artifacts = resolveArtifact(comparisonArtifact, mavenParameters, pluginParameters, ConfigurationVersion.OLD); for (Artifact artifact : artifacts) { @@ -887,20 +903,15 @@ private Set resolveArtifact(Artifact artifact, MavenParameters mavenPa if (resolutionResult != null) { if (resolutionResult.getExceptions() != null && !resolutionResult.getExceptions().isEmpty()) { List exceptions = resolutionResult.getExceptions(); - String message = "Could not resolve " + artifact; - if (ignoreMissingArtifact(pluginParameters, configurationVersion)) { - getLog().warn(message); - } else { - throw new MojoFailureException(message, exceptions.get(0)); + for (Exception exception : exceptions) { + getLog().debug(exception.getMessage(), exception); } - return new HashSet<>(); } if (resolutionResult.isMissing()) { - String msg = "Could not resolve artifact " + request.getArtifact(); if (ignoreMissingArtifact(pluginParameters, configurationVersion)) { - getLog().warn(msg); + getLog().warn("Ignoring missing artifact " + request.getArtifact()); } else { - throw new MojoFailureException(msg); + throw new MojoFailureException("Could not resolve artifact " + request.getArtifact()); } return new HashSet<>(); }