Skip to content

Commit

Permalink
Add --bind-services to create-runtime-image goal. Fixes moditect#129.
Browse files Browse the repository at this point in the history
  • Loading branch information
jaygazula27 authored and gunnarmorling committed Oct 18, 2020
1 parent d8cfeca commit e60e567
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,12 @@ public class CreateRuntimeImage {
private final boolean noHeaderFiles;
private final boolean noManPages;
private final List<String> excludeResourcesPatterns;
private final boolean bindServices;

public CreateRuntimeImage(Set<Path> modulePath, List<String> modules, String launcherName, String launcherModule,
Path outputDirectory, Integer compression, boolean stripDebug, boolean ignoreSigningInformation, List<String> excludeResourcesPatterns, Log log, boolean noHeaderFiles, boolean noManPages) {
Path outputDirectory, Integer compression, boolean stripDebug,
boolean ignoreSigningInformation, List<String> excludeResourcesPatterns, Log log,
boolean noHeaderFiles, boolean noManPages, boolean bindServices) {
this.modulePath = ( modulePath != null ? modulePath : Collections.emptySet() );
this.modules = getModules( modules );
this.outputDirectory = outputDirectory;
Expand All @@ -58,6 +61,7 @@ public CreateRuntimeImage(Set<Path> modulePath, List<String> modules, String lau
this.log = log;
this.noHeaderFiles = noHeaderFiles;
this.noManPages = noManPages;
this.bindServices = bindServices;
}

private static List<String> getModules(List<String> modules) {
Expand Down Expand Up @@ -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 );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -117,7 +120,8 @@ public void execute() throws MojoExecutionException, MojoFailureException {
getExcludeResourcesPatterns(),
new MojoLog( getLog() ),
noHeaderFiles,
noManPages
noManPages,
bindServices
)
.run();
}
Expand Down

0 comments on commit e60e567

Please sign in to comment.