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

[tycho-4.0.x] Add a new warnCommon mode similar to failCommon #3436

Merged
merged 1 commit into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ public enum BaselineMode {
*/
warn,

/**
* Warn about discrepancies between build and baseline artifacts but do not fail the build.
* Attached artifacts only present in the build do not result in a warning.
*/
warnCommon,

/**
* Fail the build if there are discrepancies between artifacts present both in build and
* baseline. Attached artifacts only present in the build do not result in build failure.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,9 @@ public Map<String, IP2Artifact> validateAndReplace(MavenProject project, Compari
classifier.getValue().writeDetails(new File(logdir, classifier.getKey()));
}
}
if (baselineMode == fail || (baselineMode == failCommon && !isMissingOnlyDelta(delta))) {
if (shouldFail(baselineMode, delta)) {
throw new MojoExecutionException(delta.getDetailedMessage());
} else {
} else if (shouldWarn(baselineMode, delta)) {
log.warn(project.toString() + ": " + delta.getDetailedMessage());
}
}
Expand Down Expand Up @@ -198,7 +198,18 @@ public Map<String, IP2Artifact> validateAndReplace(MavenProject project, Compari
return result;
}

private boolean isMissingOnlyDelta(ArtifactDelta delta) {
private static boolean shouldFail(BaselineMode baselineMode, CompoundArtifactDelta delta) {
return baselineMode == fail || (baselineMode == failCommon && !isMissingOnlyDelta(delta));
}

private static boolean shouldWarn(BaselineMode baselineMode, CompoundArtifactDelta delta) {
if (baselineMode == BaselineMode.warnCommon) {
return !isMissingOnlyDelta(delta);
}
return true;
}

private static boolean isMissingOnlyDelta(ArtifactDelta delta) {
if (delta instanceof MissingArtifactDelta) {
return true;
}
Expand Down