You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by gn...@apache.org on 2026/09/16 13:29:13 UTC
(maven) branch maven-4.0.x updated: Lower-case the OS family before matching it against the family names (#13152) (#13154)
This is an automated email from the ASF dual-hosted git repository.
gnodet pushed a commit to branch maven-4.0.x
in repository https://gitbox.apache.org/repos/asf/maven.git
The following commit(s) were added to refs/heads/maven-4.0.x by this push:
new 1249af4e8f Lower-case the OS family before matching it against the family names (#13152) (#13154)
1249af4e8f is described below
commit 1249af4e8fc4c7489333b419d03da26973655c0d
Author: Guillaume Nodet <gn...@gmail.com>
AuthorDate: Wed Sep 16 15:29:06 2026 +0200
Lower-case the OS family before matching it against the family names (#13152) (#13154)
* Lower-case the OS family before matching it against the family names
The Maven 3 activator lower-cases activation/os/family before handing it
to Os.isFamily (0456c7c62, "Caplital OS name can not activate profile"),
as it does for name and arch. The Maven 4 activator lower-cases name and
arch but passes family through untouched.
Os.isFamily switches on the family string against lower-case constants
such as "winnt", "unix" and "dos"; anything that does not match falls
through to the default branch, which is a plain
actualOsName.contains(family). Families whose name is a substring of the
OS name, like "Mac" on "mac os x", still work by accident, which is why
the existing capital-name test did not catch this. The ones that rely on
the switch do not: <family>WinNT</family> no longer activates on
Windows, and <family>Mac</family> no longer activates on a JDK reporting
os.name=darwin.
Add the toLowerCase call so the family follows the same rule as the
other three fields, and cover the two cases above.
* Add negation test for capitalised OS family
---------
Co-authored-by: Leo Camus <le...@gmail.com>
---
.../model/profile/OperatingSystemProfileActivator.java | 2 +-
.../profile/OperatingSystemProfileActivatorTest.java | 17 +++++++++++++++++
2 files changed, 18 insertions(+), 1 deletion(-)
diff --git a/impl/maven-impl/src/main/java/org/apache/maven/impl/model/profile/OperatingSystemProfileActivator.java b/impl/maven-impl/src/main/java/org/apache/maven/impl/model/profile/OperatingSystemProfileActivator.java
index 57734509bd..8e01dcdf8a 100644
--- a/impl/maven-impl/src/main/java/org/apache/maven/impl/model/profile/OperatingSystemProfileActivator.java
+++ b/impl/maven-impl/src/main/java/org/apache/maven/impl/model/profile/OperatingSystemProfileActivator.java
@@ -146,7 +146,7 @@ private boolean determineNameMatch(String family, String actualName) {
}
private boolean determineFamilyMatch(String family, String actualName) {
- String test = family;
+ String test = family.toLowerCase(Locale.ENGLISH);
boolean reverse = false;
if (test.startsWith("!")) {
diff --git a/impl/maven-impl/src/test/java/org/apache/maven/impl/model/profile/OperatingSystemProfileActivatorTest.java b/impl/maven-impl/src/test/java/org/apache/maven/impl/model/profile/OperatingSystemProfileActivatorTest.java
index 4f228a5f14..fbcfd79e28 100644
--- a/impl/maven-impl/src/test/java/org/apache/maven/impl/model/profile/OperatingSystemProfileActivatorTest.java
+++ b/impl/maven-impl/src/test/java/org/apache/maven/impl/model/profile/OperatingSystemProfileActivatorTest.java
@@ -145,4 +145,21 @@ void testCapitalOsName() {
assertActivation(false, profile, newContext(null, newProperties("windows", "99", "amd64")));
assertActivation(true, profile, newContext(null, newProperties("Mac OS X", "14.5", "aarch64")));
}
+
+ @Test
+ void testCapitalFamily() {
+ Profile winnt = newProfile(ActivationOS.newBuilder().family("WinNT"));
+
+ assertActivation(true, winnt, newContext(null, newProperties("windows 11", "10.0", "amd64")));
+ assertActivation(false, winnt, newContext(null, newProperties("linux", "6.5.0-1014-aws", "amd64")));
+
+ Profile notWinnt = newProfile(ActivationOS.newBuilder().family("!WinNT"));
+
+ assertActivation(false, notWinnt, newContext(null, newProperties("windows 11", "10.0", "amd64")));
+ assertActivation(true, notWinnt, newContext(null, newProperties("linux", "6.5.0-1014-aws", "amd64")));
+
+ Profile mac = newProfile(ActivationOS.newBuilder().family("Mac"));
+
+ assertActivation(true, mac, newContext(null, newProperties("darwin", "24.6.0", "aarch64")));
+ }
}