From e60e567bb650bd8cebc85ba79959975383275055 Mon Sep 17 00:00:00 2001 From: Jay Gazula Date: Sun, 18 Oct 2020 15:14:41 -0400 Subject: [PATCH] Add --bind-services to create-runtime-image goal. Fixes #129. --- README.md | 1 + .../java/org/moditect/commands/CreateRuntimeImage.java | 10 +++++++++- .../mavenplugin/image/CreateRuntimeImageMojo.java | 6 +++++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 5754a5a..ba2afc6 100644 --- a/README.md +++ b/README.md @@ -386,6 +386,7 @@ in the runtime image. The signature-related files of the signed modular JARs are to the runtime image. * `noManPages`: No man pages will be added * `noHeaderFiles`: No native header files will be added +* `bindServices`: Link service provider modules and their dependencies Once the image has been created, it can be executed by running: diff --git a/core/src/main/java/org/moditect/commands/CreateRuntimeImage.java b/core/src/main/java/org/moditect/commands/CreateRuntimeImage.java index 8d3d5b1..7b0361a 100644 --- a/core/src/main/java/org/moditect/commands/CreateRuntimeImage.java +++ b/core/src/main/java/org/moditect/commands/CreateRuntimeImage.java @@ -44,9 +44,12 @@ public class CreateRuntimeImage { private final boolean noHeaderFiles; private final boolean noManPages; private final List excludeResourcesPatterns; + private final boolean bindServices; public CreateRuntimeImage(Set modulePath, List modules, String launcherName, String launcherModule, - Path outputDirectory, Integer compression, boolean stripDebug, boolean ignoreSigningInformation, List excludeResourcesPatterns, Log log, boolean noHeaderFiles, boolean noManPages) { + Path outputDirectory, Integer compression, boolean stripDebug, + boolean ignoreSigningInformation, List excludeResourcesPatterns, Log log, + boolean noHeaderFiles, boolean noManPages, boolean bindServices) { this.modulePath = ( modulePath != null ? modulePath : Collections.emptySet() ); this.modules = getModules( modules ); this.outputDirectory = outputDirectory; @@ -58,6 +61,7 @@ public CreateRuntimeImage(Set modulePath, List modules, String lau this.log = log; this.noHeaderFiles = noHeaderFiles; this.noManPages = noManPages; + this.bindServices = bindServices; } private static List getModules(List modules) { @@ -121,6 +125,10 @@ private void runJlink() throws AssertionError { command.add( "--no-man-pages" ); } + if ( bindServices ) { + command.add( "--bind-services" ); + } + log.debug( "Running jlink: " + String.join( " ", command ) ); ProcessExecutor.run( "jlink", command, log ); diff --git a/maven-plugin/src/main/java/org/moditect/mavenplugin/image/CreateRuntimeImageMojo.java b/maven-plugin/src/main/java/org/moditect/mavenplugin/image/CreateRuntimeImageMojo.java index 13d6117..a50e43d 100644 --- a/maven-plugin/src/main/java/org/moditect/mavenplugin/image/CreateRuntimeImageMojo.java +++ b/maven-plugin/src/main/java/org/moditect/mavenplugin/image/CreateRuntimeImageMojo.java @@ -95,6 +95,9 @@ public class CreateRuntimeImageMojo extends AbstractMojo { @Parameter(defaultValue = "false") private boolean noManPages; + @Parameter(defaultValue = "false") + private boolean bindServices; + @Override public void execute() throws MojoExecutionException, MojoFailureException { Path jmodsDir = getJModsDir(); @@ -117,7 +120,8 @@ public void execute() throws MojoExecutionException, MojoFailureException { getExcludeResourcesPatterns(), new MojoLog( getLog() ), noHeaderFiles, - noManPages + noManPages, + bindServices ) .run(); }