< prev index next >

src/jdk.incubator.jpackage/share/classes/jdk/incubator/jpackage/internal/DeployParams.java

Print this page

        

*** 21,31 **** * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ ! package jdk.jpackage.internal; import java.io.File; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.InvalidPathException; --- 21,31 ---- * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ ! package jdk.incubator.jpackage.internal; import java.io.File; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.InvalidPathException;
*** 50,196 **** */ public class DeployParams { final List<RelativeFileSet> resources = new ArrayList<>(); ! String id; ! String vendor; ! String email; ! String description; ! String licenseType; ! String copyright; ! String version; ! Boolean systemWide; ! Boolean serviceHint; ! Boolean signBundle; ! Boolean installdirChooser; ! ! String applicationClass; ! ! List<Param> params; ! List<String> arguments; //unnamed arguments ! ! // Java 9 modules support ! String addModules = null; ! String limitModules = null; ! String modulePath = null; ! String module = null; ! String debugPort = null; File outdir = null; - String appId = null; - - // list of jvm args - // (in theory string can contain spaces and need to be escaped - List<String> jvmargs = new LinkedList<>(); - // raw arguments to the bundler Map<String, ? super Object> bundlerArguments = new LinkedHashMap<>(); - void setLicenseType(String licenseType) { - this.licenseType = licenseType; - } - - void setCopyright(String copyright) { - this.copyright = copyright; - } - - void setVersion(String version) { - this.version = version; - } - - void setSystemWide(Boolean systemWide) { - this.systemWide = systemWide; - } - - void setInstalldirChooser(Boolean installdirChooser) { - this.installdirChooser = installdirChooser; - } - - void setSignBundle(Boolean signBundle) { - this.signBundle = signBundle; - } - - void addJvmArg(String v) { - jvmargs.add(v); - } - - void setArguments(List<String> args) { - this.arguments = args; - } - - List<String> getArguments() { - return this.arguments; - } - - void addArgument(String arg) { - this.arguments.add(arg); - } - - void addAddModule(String value) { - if (addModules == null) { - addModules = value; - } - else { - addModules += "," + value; - } - } - - void addLimitModule(String value) { - if (limitModules == null) { - limitModules = value; - } - else { - limitModules += "," + value; - } - } - - String getModulePath() { - return this.modulePath; - } - - void setModulePath(String value) { - this.modulePath = value; - } - - void setModule(String value) { - this.module = value; - } - - void setDebug(String value) { - this.debugPort = value; - } - - void setDescription(String description) { - this.description = description; - } - - public void setAppId(String id) { - appId = id; - } - - void setParams(List<Param> params) { - this.params = params; - } - - void setVendor(String vendor) { - this.vendor = vendor; - } - - void setEmail(String email) { - this.email = email; - } - - void setApplicationClass(String applicationClass) { - this.applicationClass = applicationClass; - } - - File getOutput() { - return outdir; - } - public void setOutput(File output) { outdir = output; } static class Template { --- 50,66 ---- */ public class DeployParams { final List<RelativeFileSet> resources = new ArrayList<>(); ! String targetFormat = null; // means default type for this platform File outdir = null; // raw arguments to the bundler Map<String, ? super Object> bundlerArguments = new LinkedHashMap<>(); public void setOutput(File output) { outdir = output; } static class Template {
*** 240,269 **** } resources.add(new RelativeFileSet( baseDir, new LinkedHashSet<>(expandFileset(file)))); } ! void setClasspath() { ! String classpath = ""; for (RelativeFileSet resource : resources) { for (String file : resource.getIncludedFiles()) { if (file.endsWith(".jar")) { classpath += file + File.pathSeparator; } } } addBundleArgument( StandardBundlerParam.CLASSPATH.getID(), classpath); } - private static File createFile(final File baseDir, final String path) { - final File testFile = new File(path); - return testFile.isAbsolute() ? - testFile : new File(baseDir == null ? - null : baseDir.getAbsolutePath(), path); - } - static void validateName(String s, boolean forApp) throws PackagerException { String exceptionKey = forApp ? "ERR_InvalidAppName" : "ERR_InvalidSLName"; --- 110,140 ---- } resources.add(new RelativeFileSet( baseDir, new LinkedHashSet<>(expandFileset(file)))); } ! void setClasspath(String mainJarPath) { ! String classpath; ! // we want main jar first on the classpath ! if (mainJarPath != null) { ! classpath = mainJarPath + File.pathSeparator; ! } else { ! classpath = ""; ! } for (RelativeFileSet resource : resources) { for (String file : resource.getIncludedFiles()) { if (file.endsWith(".jar")) { + if (!file.equals(mainJarPath)) { classpath += file + File.pathSeparator; } } } + } addBundleArgument( StandardBundlerParam.CLASSPATH.getID(), classpath); } static void validateName(String s, boolean forApp) throws PackagerException { String exceptionKey = forApp ? "ERR_InvalidAppName" : "ERR_InvalidSLName";
*** 306,319 **** } } } public void validate() throws PackagerException { - if (outdir == null) { - throw new PackagerException("ERR_MissingArgument", "--output"); - } - boolean hasModule = (bundlerArguments.get( Arguments.CLIOptions.MODULE.getId()) != null); boolean hasAppImage = (bundlerArguments.get( Arguments.CLIOptions.PREDEFINED_APP_IMAGE.getId()) != null); boolean hasClass = (bundlerArguments.get( --- 177,186 ----
*** 324,337 **** Arguments.CLIOptions.PREDEFINED_RUNTIME_IMAGE.getId()) != null); boolean hasInput = (bundlerArguments.get( Arguments.CLIOptions.INPUT.getId()) != null); boolean hasModulePath = (bundlerArguments.get( Arguments.CLIOptions.MODULE_PATH.getId()) != null); ! boolean runtimeInstaller = (BundlerType.INSTALLER == getBundleType()) && !hasAppImage && !hasModule && !hasMain && hasRuntimeImage; ! if (getBundleType() == BundlerType.IMAGE) { // Module application requires --runtime-image or --module-path if (hasModule) { if (!hasModulePath && !hasRuntimeImage) { throw new PackagerException("ERR_MissingArgument", "--runtime-image or --module-path"); --- 191,204 ---- Arguments.CLIOptions.PREDEFINED_RUNTIME_IMAGE.getId()) != null); boolean hasInput = (bundlerArguments.get( Arguments.CLIOptions.INPUT.getId()) != null); boolean hasModulePath = (bundlerArguments.get( Arguments.CLIOptions.MODULE_PATH.getId()) != null); ! boolean runtimeInstaller = !isTargetAppImage() && !hasAppImage && !hasModule && !hasMain && hasRuntimeImage; ! if (isTargetAppImage()) { // Module application requires --runtime-image or --module-path if (hasModule) { if (!hasModulePath && !hasRuntimeImage) { throw new PackagerException("ERR_MissingArgument", "--runtime-image or --module-path");
*** 340,350 **** if (!hasInput) { throw new PackagerException( "ERR_MissingArgument", "--input"); } } ! } else if (getBundleType() == BundlerType.INSTALLER) { if (!runtimeInstaller) { if (hasModule) { if (!hasModulePath && !hasRuntimeImage && !hasAppImage) { throw new PackagerException("ERR_MissingArgument", "--runtime-image, --module-path or --app-image"); --- 207,217 ---- if (!hasInput) { throw new PackagerException( "ERR_MissingArgument", "--input"); } } ! } else { if (!runtimeInstaller) { if (hasModule) { if (!hasModulePath && !hasRuntimeImage && !hasAppImage) { throw new PackagerException("ERR_MissingArgument", "--runtime-image, --module-path or --app-image");
*** 382,392 **** if (!appImageDir.exists() || appImageDir.list().length == 0) { throw new PackagerException("ERR_AppImageNotExist", appImage); } } ! // Validate temp-root String root = (String)bundlerArguments.get( Arguments.CLIOptions.TEMP_ROOT.getId()); if (root != null) { String [] contents = (new File(root)).list(); --- 249,259 ---- if (!appImageDir.exists() || appImageDir.list().length == 0) { throw new PackagerException("ERR_AppImageNotExist", appImage); } } ! // Validate temp dir String root = (String)bundlerArguments.get( Arguments.CLIOptions.TEMP_ROOT.getId()); if (root != null) { String [] contents = (new File(root)).list();
*** 404,458 **** throw new PackagerException("ERR_LicenseFileNotExit"); } } } - boolean validateForBundle() { - boolean result = false; - - // Success - if (((applicationClass != null && !applicationClass.isEmpty()) || - (module != null && !module.isEmpty()))) { - result = true; - } - - return result; - } - - BundlerType bundleType = BundlerType.NONE; - String targetFormat = null; //means any - - void setBundleType(BundlerType type) { - bundleType = type; - } - - BundlerType getBundleType() { - return bundleType; - } - void setTargetFormat(String t) { targetFormat = t; } String getTargetFormat() { return targetFormat; } ! private String getArch() { ! String arch = System.getProperty("os.arch").toLowerCase(); ! ! if ("x86".equals(arch) || "i386".equals(arch) || "i486".equals(arch) ! || "i586".equals(arch) || "i686".equals(arch)) { ! arch = "x86"; ! } else if ("x86_64".equals(arch) || "amd64".equals("arch")) { ! arch = "x86_64"; ! } ! ! return arch; } ! static final Set<String> multi_args = new TreeSet<>(Arrays.asList( StandardBundlerParam.JAVA_OPTIONS.getID(), StandardBundlerParam.ARGUMENTS.getID(), StandardBundlerParam.MODULE_PATH.getID(), StandardBundlerParam.ADD_MODULES.getID(), StandardBundlerParam.LIMIT_MODULES.getID(), --- 271,293 ---- throw new PackagerException("ERR_LicenseFileNotExit"); } } } void setTargetFormat(String t) { targetFormat = t; } String getTargetFormat() { return targetFormat; } ! boolean isTargetAppImage() { ! return ("app-image".equals(targetFormat)); } ! private static final Set<String> multi_args = new TreeSet<>(Arrays.asList( StandardBundlerParam.JAVA_OPTIONS.getID(), StandardBundlerParam.ARGUMENTS.getID(), StandardBundlerParam.MODULE_PATH.getID(), StandardBundlerParam.ADD_MODULES.getID(), StandardBundlerParam.LIMIT_MODULES.getID(),
*** 488,540 **** } BundleParams getBundleParams() { BundleParams bundleParams = new BundleParams(); ! // construct app resources relative to output folder! bundleParams.setAppResourcesList(resources); - bundleParams.setApplicationClass(applicationClass); - bundleParams.setAppVersion(version); - bundleParams.setType(bundleType); - bundleParams.setBundleFormat(targetFormat); - bundleParams.setVendor(vendor); - bundleParams.setEmail(email); - bundleParams.setInstalldirChooser(installdirChooser); - bundleParams.setCopyright(copyright); - bundleParams.setDescription(description); - - bundleParams.setJvmargs(jvmargs); - bundleParams.setArguments(arguments); - - if (addModules != null && !addModules.isEmpty()) { - bundleParams.setAddModules(addModules); - } - - if (limitModules != null && !limitModules.isEmpty()) { - bundleParams.setLimitModules(limitModules); - } - - if (modulePath != null && !modulePath.isEmpty()) { - bundleParams.setModulePath(modulePath); - } - - if (module != null && !module.isEmpty()) { - bundleParams.setMainModule(module); - } - - if (debugPort != null && !debugPort.isEmpty()) { - bundleParams.setDebug(debugPort); - } - - Map<String, String> paramsMap = new TreeMap<>(); - if (params != null) { - for (Param p : params) { - paramsMap.put(p.name, p.value); - } - } - Map<String, String> unescapedHtmlParams = new TreeMap<>(); Map<String, String> escapedHtmlParams = new TreeMap<>(); // check for collisions TreeSet<String> keys = new TreeSet<>(bundlerArguments.keySet()); --- 323,335 ---- } BundleParams getBundleParams() { BundleParams bundleParams = new BundleParams(); ! // construct app resources relative to destination folder! bundleParams.setAppResourcesList(resources); Map<String, String> unescapedHtmlParams = new TreeMap<>(); Map<String, String> escapedHtmlParams = new TreeMap<>(); // check for collisions TreeSet<String> keys = new TreeSet<>(bundlerArguments.keySet());
*** 548,579 **** bundleParams.addAllBundleParams(bundlerArguments); return bundleParams; } - Map<String, ? super Object> getBundlerArguments() { - return this.bundlerArguments; - } - - void putUnlessNull(String param, Object value) { - if (value != null) { - bundlerArguments.put(param, value); - } - } - - void putUnlessNullOrEmpty(String param, Map<?, ?> value) { - if (value != null && !value.isEmpty()) { - bundlerArguments.put(param, value); - } - } - - void putUnlessNullOrEmpty(String param, Collection<?> value) { - if (value != null && !value.isEmpty()) { - bundlerArguments.put(param, value); - } - } - @Override public String toString() { return "DeployParams {" + "output: " + outdir + " resources: {" + resources + "}}"; } --- 343,352 ----
< prev index next >