< prev index next >

src/jdk.jpackage/share/classes/jdk/jpackage/internal/JLinkBundlerHelper.java

Print this page

        

*** 163,174 **** if (mainModule != null) { int index = mainModule.indexOf("/"); if (index > 0) { result = mainModule.substring(0, index); ! } ! else { result = mainModule; } } return result; --- 163,173 ---- if (mainModule != null) { int index = mainModule.indexOf("/"); if (index > 0) { result = mainModule.substring(0, index); ! } else { result = mainModule; } } return result;
*** 261,288 **** mainJarType = ModFile.ModType.UnnamedJar; } // Modules ! // The default for an unnamed jar is ALL_DEFAULT with the ! // non-valid modules removed. if (mainJarType == ModFile.ModType.UnnamedJar) { ! addModules.add(ModuleHelper.ALL_RUNTIME); } 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( --- 260,276 ---- mainJarType = ModFile.ModType.UnnamedJar; } // Modules ! // The default for an unnamed jar is ALL_MODULES with invalid removed if (mainJarType == ModFile.ModType.UnnamedJar) { ! addModules.add(ModuleHelper.ALL_MODULES); } else if (mainJarType == ModFile.ModType.Unknown || mainJarType == ModFile.ModType.ModularJar) { String mainModule = getMainModule(params); addModules.add(mainModule); } addModules.addAll(getValidModules( modulePath, addModules, limitModules, false)); Log.verbose(MessageFormat.format(
*** 311,321 **** 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); Set<String> redistModules = getValidModules(modulePath, addModules, limitModules, true); addModules.addAll(redistModules); Log.verbose(MessageFormat.format( --- 299,309 ---- Set<String> limitModules = StandardBundlerParam.LIMIT_MODULES.fetchFrom(params); boolean stripNativeCommands = StandardBundlerParam.STRIP_NATIVE_COMMANDS.fetchFrom(params); Path outputDir = imageBuilder.getRoot(); ! addModules.add(ModuleHelper.ALL_MODULES); Set<String> redistModules = getValidModules(modulePath, addModules, limitModules, true); addModules.addAll(redistModules); Log.verbose(MessageFormat.format(
*** 349,397 **** } 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 = --- 337,346 ----
*** 443,497 **** 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 final Set<String> modules = new HashSet<>(); ! private enum Macros {None, AllModulePath, AllRuntime} ModuleHelper(List<Path> paths, Set<String> roots, Set<String> limitMods, boolean forJRE) { ! Macros macro = Macros.None; ! 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: 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 (forJRE && isModuleExcludedFromJRE(name)) { continue; // JRE does not include this module } this.modules.add(name); } - break; } } Set<String> modules() { return modules; --- 392,428 ---- return result; } private static class ModuleHelper { // The token for "all modules on the module path". ! private static final String ALL_MODULES = "ALL-MODULE-PATH"; private final Set<String> modules = new HashSet<>(); ! private enum Macros {None, All} ModuleHelper(List<Path> paths, Set<String> roots, Set<String> limitMods, boolean forJRE) { ! boolean addAll = false; ! for (String module : roots) { ! if (module.equals(ALL_MODULES)) { ! roots.remove(ALL_MODULES); ! addAll = true; ! } else { this.modules.add(module); } } ! 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); } } } Set<String> modules() { return modules;
< prev index next >