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

slachiewicz pushed a commit to branch feature/jdkinternals-parameter
in repository https://gitbox.apache.org/repos/asf/maven-jdeps-plugin.git

commit a8bcbf54c200ea119d2654897efab5920e5ff363
Author: Sylwester Lachiewicz <[email protected]>
AuthorDate: Fri Dec 26 10:36:50 2025 +0000

    feat: add jdkinternals parameter and update Maven version requirement
    
    - Update Maven prerequisite from 3.6.3 to 3.0.0 to support Maven 3
    - Add 'jdkinternals' parameter to AbstractJDepsMojo to support the 
-jdkinternals flag
    - Add unit tests for the new jdkinternals parameter functionality
    
    This implements the feature requested in issue #24 to add support for the
    -jdkinternals option which filters output to show only internal API usage.
---
 .../maven/plugins/jdeps/AbstractJDepsMojo.java     | 12 +++
 .../maven/plugins/jdeps/AbstractJDepsMojoTest.java | 92 ++++++++++++++++++++++
 2 files changed, 104 insertions(+)

diff --git 
a/src/main/java/org/apache/maven/plugins/jdeps/AbstractJDepsMojo.java 
b/src/main/java/org/apache/maven/plugins/jdeps/AbstractJDepsMojo.java
index b44fa6d..177af6c 100644
--- a/src/main/java/org/apache/maven/plugins/jdeps/AbstractJDepsMojo.java
+++ b/src/main/java/org/apache/maven/plugins/jdeps/AbstractJDepsMojo.java
@@ -184,6 +184,14 @@ public abstract class AbstractJDepsMojo extends 
AbstractMojo {
     @Parameter(property = "jdeps.module")
     private String module;
 
+    /**
+     * Show only internal API usage.
+     *
+     * @since 3.2.0
+     */
+    @Parameter(defaultValue = "false", property = "jdeps.jdkinternals")
+    private boolean jdkinternals;
+
     private final ToolchainManager toolchainManager;
 
     protected AbstractJDepsMojo(ToolchainManager toolchainManager) {
@@ -313,6 +321,10 @@ public abstract class AbstractJDepsMojo extends 
AbstractMojo {
         if (recursive) {
             cmd.createArg().setValue("-R");
         }
+
+        if (jdkinternals) {
+            cmd.createArg().setValue("-jdkinternals");
+        }
     }
 
     protected Set<Path> getDependenciesToAnalyze(boolean includeClasspath)
diff --git 
a/src/test/java/org/apache/maven/plugins/jdeps/AbstractJDepsMojoTest.java 
b/src/test/java/org/apache/maven/plugins/jdeps/AbstractJDepsMojoTest.java
new file mode 100644
index 0000000..dac216d
--- /dev/null
+++ b/src/test/java/org/apache/maven/plugins/jdeps/AbstractJDepsMojoTest.java
@@ -0,0 +1,92 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.maven.plugins.jdeps;
+
+import java.lang.reflect.Field;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.util.Collection;
+import java.util.HashSet;
+import java.util.Set;
+
+import org.apache.maven.artifact.DependencyResolutionRequiredException;
+import org.apache.maven.toolchain.ToolchainManager;
+import org.codehaus.plexus.util.cli.Commandline;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+class AbstractJDepsMojoTest {
+
+    private static class TestJDepsMojo extends AbstractJDepsMojo {
+        TestJDepsMojo(ToolchainManager toolchainManager) {
+            super(toolchainManager);
+        }
+
+        @Override
+        protected String getClassesDirectory() {
+            return "/path/to/classes";
+        }
+
+        @Override
+        protected Collection<Path> getClassPath() throws 
DependencyResolutionRequiredException {
+            return new HashSet<>();
+        }
+    }
+
+    @Test
+    void testJDKInternalsOptionIsAdded() throws Exception {
+        TestJDepsMojo mojo = new TestJDepsMojo(null);
+
+        // Set jdkinternals to true
+        Field jdkInternalsField = 
AbstractJDepsMojo.class.getDeclaredField("jdkinternals");
+        jdkInternalsField.setAccessible(true);
+        jdkInternalsField.setBoolean(mojo, true);
+
+        Commandline cmd = new Commandline();
+        Set<Path> dependenciesToAnalyze = new HashSet<>();
+        dependenciesToAnalyze.add(Paths.get("/path/to/classes"));
+
+        mojo.addJDepsOptions(cmd, dependenciesToAnalyze);
+
+        String cmdLine = cmd.toString();
+        assertTrue(cmdLine.contains("-jdkinternals"), "Command line should 
contain -jdkinternals flag");
+    }
+
+    @Test
+    void testJDKInternalsOptionNotAddedWhenFalse() throws Exception {
+        TestJDepsMojo mojo = new TestJDepsMojo(null);
+
+        // Set jdkinternals to false (default)
+        Field jdkInternalsField = 
AbstractJDepsMojo.class.getDeclaredField("jdkinternals");
+        jdkInternalsField.setAccessible(true);
+        jdkInternalsField.setBoolean(mojo, false);
+
+        Commandline cmd = new Commandline();
+        Set<Path> dependenciesToAnalyze = new HashSet<>();
+        dependenciesToAnalyze.add(Paths.get("/path/to/classes"));
+
+        mojo.addJDepsOptions(cmd, dependenciesToAnalyze);
+
+        String cmdLine = cmd.toString();
+        assertFalse(
+                cmdLine.contains("-jdkinternals"), "Command line should not 
contain -jdkinternals flag when disabled");
+    }
+}

Reply via email to