This is an automated email from the ASF dual-hosted git repository. slachiewicz pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/maven-jmod-plugin.git
commit fb44e100e0cdd43f58b680999afedf3e18a8c6d0 Author: Sylwester Lachiewicz <[email protected]> AuthorDate: Sun Jun 14 21:50:59 2026 +0200 Enhance JModCreateMojo to handle .jmod files in classpath and stabilize class/module-path entries --- .../apache/maven/plugins/jmod/JModCreateMojo.java | 27 ++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/src/main/java/org/apache/maven/plugins/jmod/JModCreateMojo.java b/src/main/java/org/apache/maven/plugins/jmod/JModCreateMojo.java index 11f39b8..2d426b1 100644 --- a/src/main/java/org/apache/maven/plugins/jmod/JModCreateMojo.java +++ b/src/main/java/org/apache/maven/plugins/jmod/JModCreateMojo.java @@ -25,6 +25,7 @@ import java.io.IOException; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; +import java.util.LinkedHashSet; import java.util.List; import java.util.Map; @@ -453,8 +454,13 @@ public class JModCreateMojo extends AbstractJModMojo { } for (File file : resolvePathsResult.getClasspathElements()) { - getLog().debug("classpathElements: File: " + file.getPath()); - classpathElements.add(file.getPath()); + if (isJmodFile(file)) { + // jmod create does not accept .jmod artifacts on --class-path. + addModulePathElement(file); + } else { + getLog().debug("classpathElements: File: " + file.getPath()); + classpathElements.add(file.getPath()); + } } for (File file : resolvePathsResult.getModulepathElements().keySet()) { @@ -476,6 +482,23 @@ public class JModCreateMojo extends AbstractJModMojo { classpathElements.add(file.getPath()); } } + + // Keep class/module-path entries stable and unique while preserving order. + classpathElements = new ArrayList<>(new LinkedHashSet<>(classpathElements)); + modulepathElements = new ArrayList<>(new LinkedHashSet<>(modulepathElements)); + } + + private boolean isJmodFile(File file) { + return file.isFile() && file.getName().endsWith(".jmod"); + } + + private void addModulePathElement(File file) { + getLog().debug("modulepathElements (from classpath jmod): File: " + file.getPath()); + if (file.isDirectory()) { + modulepathElements.add(file.getPath()); + } else { + modulepathElements.add(file.getParent()); + } } private Commandline createJModCreateCommandLine(File resultingJModFile) {
