This is an automated email from the ASF dual-hosted git repository.

bmarwell pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/maven-jlink-plugin.git

commit 62bd62e494bf9c8ceb156b89910cbe17cabdd4d2
Author: Ndacyayisenga-droid <ndacyayin...@gmail.com>
AuthorDate: Tue Apr 1 22:12:42 2025 +0300

    Skip POM dependencies when assembling jlink classpath
---
 .../org/apache/maven/plugins/jlink/JLinkMojo.java  | 29 +++++++++++++++++-----
 1 file changed, 23 insertions(+), 6 deletions(-)

diff --git a/src/main/java/org/apache/maven/plugins/jlink/JLinkMojo.java 
b/src/main/java/org/apache/maven/plugins/jlink/JLinkMojo.java
index 2275e8e..be2b11a 100644
--- a/src/main/java/org/apache/maven/plugins/jlink/JLinkMojo.java
+++ b/src/main/java/org/apache/maven/plugins/jlink/JLinkMojo.java
@@ -464,20 +464,37 @@ public class JLinkMojo extends AbstractJLinkMojo {
         }
     }
 
+    /**
+     * Gets the compile classpath elements while filtering out artifacts that 
should be skipped.
+     *
+     * @param project The Maven project
+     * @return List of files that should be included in the classpath
+     */
     List<File> getCompileClasspathElements(MavenProject project) {
         List<File> list = new ArrayList<>(project.getArtifacts().size() + 1);
 
-        for (Artifact a : project.getArtifacts()) {
-            boolean skip = "pom".equals(a.getType());
-            getLog().debug("Adding artifact: " + a.getGroupId() + ":" + 
a.getArtifactId() + ":" + a.getVersion()
-                    + (skip ? " (skipping)" : ""));
-            if (!skip) {
-                list.add(a.getFile());
+        for (Artifact artifact : project.getArtifacts()) {
+            boolean shouldSkip = shouldSkip(artifact);
+            getLog().debug("Adding artifact: " + artifact.getGroupId() + ":" + 
artifact.getArtifactId() + ":"
+                    + artifact.getVersion() + (shouldSkip ? " (skipping)" : 
""));
+            if (!shouldSkip) {
+                list.add(artifact.getFile());
             }
         }
         return list;
     }
 
+    /**
+     * Determines if an artifact should be skipped based on its properties.
+     * Currently, skips POM type artifacts, but can be extended for other 
cases.
+     *
+     * @param artifact The artifact to check
+     * @return true if the artifact should be skipped, false otherwise
+     */
+    private boolean shouldSkip(Artifact artifact) {
+        return "pom".equals(artifact.getType());
+    }
+
     private Map<String, File> getModulePathElements() throws 
MojoFailureException {
         // For now only allow named modules. Once we can create a graph with 
ASM we can specify exactly the modules
         // and we can detect if auto modules are used. In that case, 
MavenProject.setFile() should not be used, so

Reply via email to