< prev index next >
src/jdk.incubator.jpackage/share/classes/jdk/incubator/jpackage/internal/DeployParams.java
Print this page
@@ -21,11 +21,11 @@
* 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;
+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,147 +50,17 @@
*/
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;
+ String targetFormat = null; // means default type for this platform
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 {
@@ -240,30 +110,31 @@
}
resources.add(new RelativeFileSet(
baseDir, new LinkedHashSet<>(expandFileset(file))));
}
- void setClasspath() {
- String classpath = "";
+ 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);
}
- 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";
@@ -306,14 +177,10 @@
}
}
}
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(
@@ -324,14 +191,14 @@
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()) &&
+ boolean runtimeInstaller = !isTargetAppImage() &&
!hasAppImage && !hasModule && !hasMain && hasRuntimeImage;
- if (getBundleType() == BundlerType.IMAGE) {
+ 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,11 +207,11 @@
if (!hasInput) {
throw new PackagerException(
"ERR_MissingArgument", "--input");
}
}
- } else if (getBundleType() == BundlerType.INSTALLER) {
+ } else {
if (!runtimeInstaller) {
if (hasModule) {
if (!hasModulePath && !hasRuntimeImage && !hasAppImage) {
throw new PackagerException("ERR_MissingArgument",
"--runtime-image, --module-path or --app-image");
@@ -382,11 +249,11 @@
if (!appImageDir.exists() || appImageDir.list().length == 0) {
throw new PackagerException("ERR_AppImageNotExist", appImage);
}
}
- // Validate temp-root
+ // Validate temp dir
String root = (String)bundlerArguments.get(
Arguments.CLIOptions.TEMP_ROOT.getId());
if (root != null) {
String [] contents = (new File(root)).list();
@@ -404,55 +271,23 @@
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;
+ boolean isTargetAppImage() {
+ return ("app-image".equals(targetFormat));
}
- static final Set<String> multi_args = new TreeSet<>(Arrays.asList(
+ 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,53 +323,13 @@
}
BundleParams getBundleParams() {
BundleParams bundleParams = new BundleParams();
- // construct app resources relative to output folder!
+ // construct app resources relative to destination 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());
@@ -548,32 +343,10 @@
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 + "}}";
}
< prev index next >