This is an automated email from the ASF dual-hosted git repository. elharo pushed a commit to branch fix-whitespace-classifier in repository https://gitbox.apache.org/repos/asf/maven-ear-plugin.git
commit 7c314268b88c69503163bac5a0534698d3a706cc Author: Elliotte Rusty Harold <[email protected]> AuthorDate: Thu Jul 16 14:48:54 2026 +0000 fix: trim whitespace-only classifier to prevent spaces in EAR filename (#521) --- .../java/org/apache/maven/plugins/ear/EarMojo.java | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/ear/EarMojo.java b/src/main/java/org/apache/maven/plugins/ear/EarMojo.java index 576a009..40b169a 100644 --- a/src/main/java/org/apache/maven/plugins/ear/EarMojo.java +++ b/src/main/java/org/apache/maven/plugins/ear/EarMojo.java @@ -560,9 +560,12 @@ public class EarMojo extends AbstractEarMojo { * @return the EAR file to generate */ private static File getEarFile(String basedir, String finalName, String classifier) { - if (classifier == null) { + if (classifier != null) { + classifier = classifier.trim(); + } + if (classifier == null || classifier.isEmpty()) { classifier = ""; - } else if (classifier.trim().length() > 0 && !classifier.startsWith("-")) { + } else if (!classifier.startsWith("-")) { classifier = "-" + classifier; } @@ -884,14 +887,21 @@ public class EarMojo extends AbstractEarMojo { } private void removeFromOutdatedResources(Path destination, Collection<String> outdatedResources) { - Path relativeDestFile; + String relativeDestFile; try { - relativeDestFile = getWorkDirectory().toPath().relativize(destination.normalize()); + relativeDestFile = getWorkDirectory() + .toPath() + .relativize(destination.normalize()) + .toString(); } catch (ProviderMismatchException e) { - relativeDestFile = destination.normalize(); + // destination is from a different filesystem provider (e.g. zip filesystem), + // relativize is not possible; strip the root to get a relative path + Path normalized = destination.normalize(); + Path root = normalized.getRoot(); + relativeDestFile = (root != null) ? root.relativize(normalized).toString() : normalized.toString(); } - if (outdatedResources.remove(relativeDestFile.toString())) { + if (outdatedResources.remove(relativeDestFile)) { getLog().debug("Remove from outdatedResources: " + relativeDestFile); } }
