From 3449d3ad5ce2149281b8394bb0cabc1c7a7807d5 Mon Sep 17 00:00:00 2001 From: Jesse Glick Date: Wed, 26 Jul 2023 17:18:04 -0400 Subject: [PATCH] [JENKINS-52665] Treat `*-SNAPSHOT` mismatches as nonfatal in `hpi:validate-hpi` --- .../jenkinsci/maven/plugins/hpi/ValidateHpiMojo.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/jenkinsci/maven/plugins/hpi/ValidateHpiMojo.java b/src/main/java/org/jenkinsci/maven/plugins/hpi/ValidateHpiMojo.java index b593db32f4..a0dbc84d87 100644 --- a/src/main/java/org/jenkinsci/maven/plugins/hpi/ValidateHpiMojo.java +++ b/src/main/java/org/jenkinsci/maven/plugins/hpi/ValidateHpiMojo.java @@ -5,6 +5,7 @@ import java.io.IOException; import java.util.jar.Attributes; import java.util.jar.JarFile; +import org.apache.maven.artifact.ArtifactUtils; import org.apache.maven.plugin.MojoExecutionException; import org.apache.maven.plugin.MojoFailureException; import org.apache.maven.plugins.annotations.LifecyclePhase; @@ -41,8 +42,14 @@ public void execute() throws MojoExecutionException, MojoFailureException { } } if (coreVersion.compareTo(maxCoreVersion) < 0) { - throw new MojoExecutionException( - "Dependency " + maxCoreVersionArtifact + " requires Jenkins " + maxCoreVersion + " or higher."); + String error = + "Dependency " + maxCoreVersionArtifact + " requires Jenkins " + maxCoreVersion + " or higher."; + if (ArtifactUtils.isSnapshot(coreVersion.toString()) + || ArtifactUtils.isSnapshot(maxCoreVersion.toString())) { + getLog().warn(error); + } else { + throw new MojoExecutionException(error); + } } }