You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by sl...@apache.org on 2026/10/13 22:18:23 UTC

(maven-mvnd) 01/01: Keep only the target platform's jline native library in the native client

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

slachiewicz pushed a commit to branch agent/jline-native-target-only-1x
in repository https://gitbox.apache.org/repos/asf/maven-mvnd.git

commit dd28243f0d88b5c07f06fe3d0c8ecb58abfddcab
Author: Sylwester Lachiewicz <sl...@apache.org>
AuthorDate: Wed Oct 14 00:18:17 2026 +0200

    Keep only the target platform's jline native library in the native client
---
 client/pom.xml | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)

diff --git a/client/pom.xml b/client/pom.xml
index 735b97fa..658d60b9 100644
--- a/client/pom.xml
+++ b/client/pom.xml
@@ -286,6 +286,7 @@
                 <buildArg>-H:-ParseRuntimeOptions</buildArg>
                 <buildArg>-H:+AddAllCharsets</buildArg>
                 <buildArg>-H:+ReportExceptionStackTraces</buildArg>
+                <buildArg>-H:ExcludeResources=${jline.native.excludes}</buildArg>
                 <buildArg>-ea</buildArg>
               </buildArgs>
             </configuration>
@@ -298,6 +299,32 @@
               </execution>
             </executions>
           </plugin>
+          <plugin>
+            <groupId>org.codehaus.gmavenplus</groupId>
+            <artifactId>gmavenplus-plugin</artifactId>
+            <executions>
+              <execution>
+                <id>set-jline-native-excludes</id>
+                <goals>
+                  <goal>execute</goal>
+                </goals>
+                <phase>generate-resources</phase>
+                <configuration>
+                  <scripts>
+                    <script>// jline-native registers its JNI library for every platform; keep only the target's.
+                      // Directory names follow org.jline.nativ.OSInfo.
+                      String os = ['linux': 'Linux', 'darwin': 'Mac', 'windows': 'Windows'][project.properties['os.detected.name']]
+                      String arch = project.properties['os.detected.arch']
+                      arch = ['amd64': 'x86_64', 'aarch64': 'arm64'].getOrDefault(arch, arch)
+                      // (?!) matches nothing, so an unknown platform keeps every library
+                      project.properties['jline.native.excludes'] = os == null
+                      ? '(?!)'
+                      : 'org/jline/nativ/(?!' + os + '/' + arch + '/)[^/]+/.*'</script>
+                  </scripts>
+                </configuration>
+              </execution>
+            </executions>
+          </plugin>
           <plugin>
             <groupId>org.codehaus.mojo</groupId>
             <artifactId>exec-maven-plugin</artifactId>