in src/main/java/org/apache/maven/plugins/jlink/JLinkMojo.java [398:465]
public void execute() throws MojoExecutionException, MojoFailureException {
failIfParametersAreNotInTheirValidValueRanges();
setOutputDirectoryImage();
ifOutputDirectoryExistsDelteIt();
JLinkExecutor jLinkExec = getJlinkExecutor();
Collection<String> modulesToAdd = new ArrayList<>();
if (addModules != null) {
modulesToAdd.addAll(addModules);
}
jLinkExec.addAllModules(modulesToAdd);
Collection<String> pathsOfModules = new ArrayList<>();
if (modulePaths != null) {
pathsOfModules.addAll(modulePaths);
}
for (Entry<String, File> item : getModulePathElements().entrySet()) {
getLog().info(" -> module: " + item.getKey() + " ( "
+ item.getValue().getPath() + " )");
// We use the real module name and not the artifact Id...
modulesToAdd.add(item.getKey());
pathsOfModules.add(item.getValue().getPath());
}
// The jmods directory of the JDK
jLinkExec
.getJmodsFolder(this.sourceJdkModules)
.ifPresent(jmodsFolder -> pathsOfModules.add(jmodsFolder.getAbsolutePath()));
jLinkExec.addAllModulePaths(pathsOfModules);
List<String> jlinkArgs = createJlinkArgs(pathsOfModules, modulesToAdd);
try {
jLinkExec.executeJlink(jlinkArgs);
} catch (IllegalStateException e) {
throw new MojoFailureException("Unable to find jlink command: " + e.getMessage(), e);
}
// Add additional resources
try {
mavenResourcesFiltering.filterResources(new MavenResourcesExecution(
additionalResources,
outputDirectoryImage,
getProject(),
"UTF-8",
Collections.emptyList(),
Collections.emptyList(),
getSession()));
} catch (MavenFilteringException e) {
throw new MojoFailureException("Unable to copy the additional resources: " + e.getMessage(), e);
}
File createZipArchiveFromImage = createZipArchiveFromImage(buildDirectory, outputDirectoryImage);
if (hasClassifier()) {
projectHelper.attachArtifact(getProject(), "jlink", getClassifier(), createZipArchiveFromImage);
} else {
if (projectHasAlreadySetAnArtifact()) {
throw new MojoExecutionException("You have to use a classifier "
+ "to attach supplemental artifacts to the project instead of replacing them.");
}
getProject().getArtifact().setFile(createZipArchiveFromImage);
}
}