Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #288: ignoreNonResolvableArtifacts not honored #290

Merged
merged 1 commit into from
Oct 6, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 12 additions & 6 deletions japicmp-maven-plugin/src/main/java/japicmp/maven/JApiCmpMojo.java
Original file line number Diff line number Diff line change
Expand Up @@ -224,20 +224,26 @@ 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);
processArtifacResult(artifactVersion, artifactResult, pluginParameters, configurationVersion);
processArtifactResult(artifactVersion, artifactResult, pluginParameters, configurationVersion);
return artifactResult.getArtifact();
} else {
throw new MojoFailureException("Could not find previous version for artifact: " + artifactVersionRange.getGroupId() + ":"
+ artifactVersionRange.getArtifactId());
if (ignoreMissingOldVersion(pluginParameters, configurationVersion)) {
getLog().warn("Ignoring missing old artifact version: " +
artifactVersionRange.getGroupId() + ":" + artifactVersionRange.getArtifactId());
return null;
} else {
throw new MojoFailureException("Could not find previous version for artifact: " + artifactVersionRange.getGroupId() + ":"
+ artifactVersionRange.getArtifactId());
}
}
} catch (final VersionRangeResolutionException | ArtifactResolutionException e) {
getLog().error("Failed to retrieve comparison artifact: " + e.getMessage(), e);
throw new MojoFailureException(e.getMessage(), e);
}
}

private void processArtifacResult(DefaultArtifact artifactVersion, ArtifactResult artifactResult,
PluginParameters pluginParameters, ConfigurationVersion configurationVersion) throws MojoFailureException {
private void processArtifactResult(DefaultArtifact artifactVersion, ArtifactResult artifactResult,
PluginParameters pluginParameters, ConfigurationVersion configurationVersion) throws MojoFailureException {
if (artifactResult.getExceptions() != null && !artifactResult.getExceptions().isEmpty()) {
List<Exception> exceptions = artifactResult.getExceptions();
for (Exception exception : exceptions) {
Expand Down Expand Up @@ -295,7 +301,7 @@ private void populateArchivesListsFromParameters(PluginParameters pluginParamete
if (pluginParameters.getOldVersionParam() == null && pluginParameters.getOldVersionsParam() == null) {
try {
Artifact comparisonArtifact = getComparisonArtifact(mavenParameters, pluginParameters, ConfigurationVersion.OLD);
if (comparisonArtifact.getVersion() != null) {
if (comparisonArtifact != null && comparisonArtifact.getVersion() != null) {
Set<Artifact> artifacts = resolveArtifact(comparisonArtifact, mavenParameters, pluginParameters, ConfigurationVersion.OLD);
for (Artifact artifact : artifacts) {
File file = artifact.getFile();
Expand Down