< prev index next >
src/jdk.jpackage/share/classes/jdk/jpackage/internal/JLinkBundlerHelper.java
Print this page
@@ -163,12 +163,11 @@
if (mainModule != null) {
int index = mainModule.indexOf("/");
if (index > 0) {
result = mainModule.substring(0, index);
- }
- else {
+ } else {
result = mainModule;
}
}
return result;
@@ -261,28 +260,17 @@
mainJarType = ModFile.ModType.UnnamedJar;
}
// Modules
- // The default for an unnamed jar is ALL_DEFAULT with the
- // non-valid modules removed.
+ // The default for an unnamed jar is ALL_MODULES with invalid removed
if (mainJarType == ModFile.ModType.UnnamedJar) {
- addModules.add(ModuleHelper.ALL_RUNTIME);
+ addModules.add(ModuleHelper.ALL_MODULES);
} else if (mainJarType == ModFile.ModType.Unknown ||
mainJarType == ModFile.ModType.ModularJar) {
String mainModule = getMainModule(params);
addModules.add(mainModule);
-
- // Error if any of the srcfiles are modular jars.
- Set<String> modularJars =
- getResourceFileJarList(params, ModFile.JarType.ModularJar);
-
- if (!modularJars.isEmpty()) {
- throw new Exception(MessageFormat.format(I18N.getString(
- "error.srcfiles.contain.modules"),
- modularJars.toString()));
- }
}
addModules.addAll(getValidModules(
modulePath, addModules, limitModules, false));
Log.verbose(MessageFormat.format(
@@ -311,11 +299,11 @@
Set<String> limitModules =
StandardBundlerParam.LIMIT_MODULES.fetchFrom(params);
boolean stripNativeCommands =
StandardBundlerParam.STRIP_NATIVE_COMMANDS.fetchFrom(params);
Path outputDir = imageBuilder.getRoot();
- addModules.add(ModuleHelper.ALL_RUNTIME);
+ addModules.add(ModuleHelper.ALL_MODULES);
Set<String> redistModules = getValidModules(modulePath,
addModules, limitModules, true);
addModules.addAll(redistModules);
Log.verbose(MessageFormat.format(
@@ -349,49 +337,10 @@
}
return result;
}
- private static Set<String> getResourceFileJarList(
- Map<String, ? super Object> params, ModFile.JarType Query) {
- Set<String> files = new LinkedHashSet<String>();
-
- String srcdir = StandardBundlerParam.SOURCE_DIR.fetchFrom(params);
-
- for (RelativeFileSet appResources :
- StandardBundlerParam.APP_RESOURCES_LIST.fetchFrom(params)) {
- for (String resource : appResources.getIncludedFiles()) {
- if (resource.endsWith(".jar")) {
- String filename = srcdir + File.separator + resource;
-
- switch (Query) {
- case All: {
- files.add(filename);
- break;
- }
- case ModularJar: {
- ModFile mod = new ModFile(new File(filename));
- if (mod.getModType() == ModFile.ModType.ModularJar) {
- files.add(filename);
- }
- break;
- }
- case UnnamedJar: {
- ModFile mod = new ModFile(new File(filename));
- if (mod.getModType() == ModFile.ModType.UnnamedJar) {
- files.add(filename);
- }
- break;
- }
- }
- }
- }
- }
-
- return files;
- }
-
private static Set<String> removeInvalidModules(
List<Path> modulePath, Set<String> modules) {
Set<String> result = new LinkedHashSet<String>();
ModuleManager mm = new ModuleManager(modulePath);
List<ModFile> lmodfiles =
@@ -443,55 +392,37 @@
return result;
}
private static class ModuleHelper {
// The token for "all modules on the module path".
- private static final String ALL_MODULE_PATH = "ALL-MODULE-PATH";
-
- // The token for "all valid runtime modules".
- static final String ALL_RUNTIME = "ALL-RUNTIME";
+ private static final String ALL_MODULES = "ALL-MODULE-PATH";
private final Set<String> modules = new HashSet<>();
- private enum Macros {None, AllModulePath, AllRuntime}
+ private enum Macros {None, All}
ModuleHelper(List<Path> paths, Set<String> roots,
Set<String> limitMods, boolean forJRE) {
- Macros macro = Macros.None;
+ boolean addAll = false;
- for (Iterator<String> iterator = roots.iterator();
- iterator.hasNext();) {
- String module = iterator.next();
-
- switch (module) {
- case ALL_MODULE_PATH:
- iterator.remove();
- macro = Macros.AllModulePath;
- break;
- case ALL_RUNTIME:
- iterator.remove();
- macro = Macros.AllRuntime;
- break;
- default:
+ for (String module : roots) {
+ if (module.equals(ALL_MODULES)) {
+ roots.remove(ALL_MODULES);
+ addAll = true;
+ } else {
this.modules.add(module);
}
}
- switch (macro) {
- case AllModulePath:
- this.modules.addAll(getModuleNamesFromPath(paths));
- break;
- case AllRuntime:
- Set<Module> runtimeModules =
- ModuleLayer.boot().modules();
- for (Module m : runtimeModules) {
- String name = m.getName();
+ if (addAll) {
+ Set<String> allModNames = getModuleNamesFromPath(paths);
+ for (String name : allModNames) {
if (forJRE && isModuleExcludedFromJRE(name)) {
+Log.info("--- skipping: " + name);
continue; // JRE does not include this module
}
this.modules.add(name);
}
- break;
}
}
Set<String> modules() {
return modules;
< prev index next >