Skip to content

Commit 553f3d0

Browse files
committed
Fix SemVer version comparison and improve warning
The != operator returns false for strings here; we need x.equals(y).
1 parent 2992176 commit 553f3d0

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

src/it/delete-other-versions-policy/verify.bsh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,4 +47,4 @@ assertTrue("Should not exist: " + newer, !toInstall.exists());
4747

4848
buildLog = readFile(new File(basedir, "build.log"));
4949
assertTrue("Found other version that is incompatible':\n" + buildLog,
50-
buildLog.contains("Found other version that is incompatible"));
50+
buildLog.contains("is incompatible according to SemVer"));

src/main/java/org/scijava/maven/plugin/install/AbstractInstallMojo.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -239,10 +239,12 @@ else if (isBioFormatsArtifact(artifact)) {
239239
else {
240240
final String otherVersion = group.substring(1);
241241
newerVersion = VersionUtils.compare(toInstall, otherVersion) < 0;
242-
if (majorVersion(toInstall) != majorVersion(otherVersion)) {
243-
getLog().warn(
244-
"Found other version that is incompatible according to SemVer: " +
245-
otherVersion);
242+
final String majorVersionToInstall = majorVersion(toInstall);
243+
final String majorVersionOther = majorVersion(otherVersion);
244+
if (!majorVersionToInstall.equals(majorVersionOther)) {
245+
getLog().warn("Version " + otherVersion + " of " + artifact +
246+
" is incompatible according to SemVer: " +
247+
majorVersionToInstall + " != " + majorVersionOther);
246248
}
247249
}
248250
if (newerVersion) break;

0 commit comments

Comments
 (0)