/** * Obtain a copy of this {@link JavaModules} option * with the specified modules in the {@code --add-exports} * option. * * @param exports the module export statement to list * in the {@code --add-exports} JVM option * * @return a copy of this {@link JavaModules} option * with the specified modules in the * {@code --add-exports} option. */ public JavaModules exporting(String... exports) { return new JavaModules(true, this.modules, toSet(this.exports, exports), this.patches, this.reading, this.opens, this.classPath); }
/** * Obtain a copy of this {@link JavaModules} option * with the specified modules exported to * {@code com.oracle.bedrock.runtime} in the * {@code --add-exports} option. * * @param modules the modules to export to Bedrock in the * {@code --add-exports} JVM option * * @return a copy of this {@link JavaModules} option * with the specified modules exported to * {@code com.oracle.bedrock.runtime} in the * {@code --add-exports} option */ public JavaModules exportingToBedrock(String... modules) { return exportingTo("com.oracle.bedrock.runtime", modules); }
/** * Obtain a copy of this {@link JavaModules} option * with the specified modules in the {@code --add-opens} * option. * * @param module the module name to open * @param _package the name of the package within the provided * <code>module</code> * @param targetModule the name of the module the code within * the specified <code>module</code> and * <code>package</code> should be opened to * * @return a copy of this {@link JavaModules} option * with the specified modules/packages exported opened via * the {@code --add-opens} option */ public JavaModules opens(String module, String _package, String targetModule) { if (module == null || _package == null || targetModule == null) { return this; } Set<String> opens = new LinkedHashSet<>(this.opens); opens.add(module + '/' + _package + '=' + targetModule); return new JavaModules(true, this.modules, this.exports, this.patches, this.reading, opens, this.classPath); }
boolean useModules = modular.isEnabled(); diagnosticsTable.addRow("Module Path", modulePathTable.toString()); ClassPath path = modular.getClassPath();
/** * Obtain a copy of this {@link JavaModules} option * with the specified modules in the {@code --add-opens} * option. * * @param module the module name to open * @param _package the name of the package within the provided * <code>module</code> * @param targetModule the name of the module the code within * the specified <code>module</code> and * <code>package</code> should be opened to * * @return a copy of this {@link JavaModules} option * with the specified modules/packages exported opened via * the {@code --add-opens} option */ public JavaModules opens(String module, String _package, String targetModule) { if (module == null || _package == null || targetModule == null) { return this; } Set<String> opens = new LinkedHashSet<>(this.opens); opens.add(module + '/' + _package + '=' + targetModule); return new JavaModules(true, this.modules, this.exports, this.patches, this.reading, opens, this.classPath); }
boolean useModules = modular.isEnabled(); diagnosticsTable.addRow("Module Path", modulePathTable.toString()); ClassPath path = modular.getClassPath();
/** * Obtain a copy of this {@link JavaModules} option * with the specified patch module statements in * the {@code --patch-module} JVM option. * * @param patches the patch module statements to list * in the {@code --patch-module} JVM option * * @return a copy of this {@link JavaModules} option * with the specified module patch statements in * the {@code --patch-module} JVM option. */ public JavaModules patching(String... patches) { if (patches.length == 0) { return this; } return new JavaModules(true, this.modules, this.exports, toSet(this.patches, patches), this.reading, this.opens, this.classPath); }
/** * Set the {@link ClassPath} to use as well as a module path. * * @param classPath the {@link ClassPath} to use as well as a module path * * @return a copy of this {@link JavaModules} option * with the specified classpath. */ public JavaModules withClassPath(ClassPath classPath) { if (classPath == null || classPath.isEmpty()) { return this; } return new JavaModules(true, this.modules, this.exports, this.patches, this.reading, this.opens, classPath); }
/** * Obtain a copy of this {@link JavaModules} option * with the specified modules exported to * {@code com.oracle.bedrock.runtime} in the * {@code --add-exports} option. * * @param modules the modules to export to Bedrock in the * {@code --add-exports} JVM option * * @return a copy of this {@link JavaModules} option * with the specified modules exported to * {@code com.oracle.bedrock.runtime} in the * {@code --add-exports} option */ public JavaModules exportingToBedrock(String... modules) { return exportingTo("com.oracle.bedrock.runtime", modules); }
/** * Obtain a copy of this {@link JavaModules} option * with the specified modules in the {@code --add-exports} * option. * * @param exports the module export statement to list * in the {@code --add-exports} JVM option * * @return a copy of this {@link JavaModules} option * with the specified modules in the * {@code --add-exports} option. */ public JavaModules exporting(String... exports) { return new JavaModules(true, this.modules, toSet(this.exports, exports), this.patches, this.reading, this.opens, this.classPath); }
/** * Obtain a copy of this {@link JavaModules} option * with the specified modules in the {@code --add-exports} * option. * * @param toModule the name of the module to export to * @param modules the modules to list in the * {@code --add-exports} JVM option * * @return a copy of this {@link JavaModules} option * with the specified modules in the * {@code --add-exports} option */ public JavaModules exportingTo(String toModule, String... modules) { if (modules.length == 0) { return this; } Set<String> exports = new LinkedHashSet<>(this.exports); Arrays.stream(modules) .map(m -> m + "/" + m + "=" + toModule) .forEach(exports::add); return new JavaModules(true, this.modules, exports, this.patches, this.reading, this.opens, this.classPath); }
/** * Obtain a copy of this {@link JavaModules} option * with the specified patch module statements in * the {@code --patch-module} JVM option. * * @param patches the patch module statements to list * in the {@code --patch-module} JVM option * * @return a copy of this {@link JavaModules} option * with the specified module patch statements in * the {@code --patch-module} JVM option. */ public JavaModules patching(String... patches) { if (patches.length == 0) { return this; } return new JavaModules(true, this.modules, this.exports, toSet(this.patches, patches), this.reading, this.opens, this.classPath); }
/** * Set the {@link ClassPath} to use as well as a module path. * * @param classPath the {@link ClassPath} to use as well as a module path * * @return a copy of this {@link JavaModules} option * with the specified classpath. */ public JavaModules withClassPath(ClassPath classPath) { if (classPath == null || classPath.isEmpty()) { return this; } return new JavaModules(true, this.modules, this.exports, this.patches, this.reading, this.opens, classPath); }
/** * Obtain a copy of this {@link JavaModules} option * with the specified reads module statements in * the {@code --add-reads} JVM option. * * @param reads the reads module statements to list * in the {@code --add-reads} JVM option * * @return a copy of this {@link JavaModules} option * with the specified reads module statements in * the {@code --add-reads} JVM option. */ public JavaModules reading(String... reads) { if (reads.length == 0) { return this; } return new JavaModules(true, this.modules, this.exports, this.patches, toSet(this.reading, reads), this.opens, this.classPath); }
/** * Obtain a copy of this {@link JavaModules} option * with the specified modules in the {@code --add-exports} * option. * * @param toModule the name of the module to export to * @param modules the modules to list in the * {@code --add-exports} JVM option * * @return a copy of this {@link JavaModules} option * with the specified modules in the * {@code --add-exports} option */ public JavaModules exportingTo(String toModule, String... modules) { if (modules.length == 0) { return this; } Set<String> exports = new LinkedHashSet<>(this.exports); Arrays.stream(modules) .map(m -> m + "/" + m + "=" + toModule) .forEach(exports::add); return new JavaModules(true, this.modules, exports, this.patches, this.reading, this.opens, this.classPath); }
/** * Obtain a copy of this {@link JavaModules} option * with the specified modules in the {@code --add-modules} * option. * * @param modules the modules to list in the {@code --add-modules} * JVM option * * @return a copy of this {@link JavaModules} option * with the specified modules in the * {@code --add-modules} option. */ public JavaModules adding(String... modules) { if (modules.length == 0) { return this; } return new JavaModules(true, toSet(this.modules, modules), this.exports, this.patches, this.reading, this.opens, this.classPath); }
@Override public JavaModules compose(JavaModules other) { Set<String> setAdd = new LinkedHashSet<>(this.modules); Set<String> setExport = new LinkedHashSet<>(this.exports); Set<String> setPatch = new LinkedHashSet<>(this.patches); Set<String> setReads = new LinkedHashSet<>(this.reading); Set<String> setOpens = new LinkedHashSet<>(this.opens); setAdd.addAll(other.modules); setExport.addAll(other.exports); setPatch.addAll(other.patches); setReads.addAll(other.reading); setOpens.addAll(other.opens); boolean isEnabled = this.enabled && other.enabled; ClassPath classPath = new ClassPath(this.classPath, other.classPath); return new JavaModules(isEnabled, setAdd, setExport, setPatch, setReads, setOpens, classPath); }
/** * Obtain a copy of this {@link JavaModules} option * with the specified reads module statements in * the {@code --add-reads} JVM option. * * @param reads the reads module statements to list * in the {@code --add-reads} JVM option * * @return a copy of this {@link JavaModules} option * with the specified reads module statements in * the {@code --add-reads} JVM option. */ public JavaModules reading(String... reads) { if (reads.length == 0) { return this; } return new JavaModules(true, this.modules, this.exports, this.patches, toSet(this.reading, reads), this.opens, this.classPath); }
/** * Obtains a {@link JavaModules} option that enables * running an application as a post Java 9 modular process. * * @return a {@link JavaModules} option to enable * a modular JVM process */ public static JavaModules enabled() { return new JavaModules(true, Collections.emptySet(), Collections.emptySet(), Collections.emptySet(), Collections.emptySet(), Collections.emptySet(), new ClassPath()); }
/** * Obtain a copy of this {@link JavaModules} option * with the specified modules in the {@code --add-modules} * option. * * @param modules the modules to list in the {@code --add-modules} * JVM option * * @return a copy of this {@link JavaModules} option * with the specified modules in the * {@code --add-modules} option. */ public JavaModules adding(String... modules) { if (modules.length == 0) { return this; } return new JavaModules(true, toSet(this.modules, modules), this.exports, this.patches, this.reading, this.opens, this.classPath); }