< prev index next >
src/jdk.jpackage/share/classes/jdk/jpackage/internal/Arguments.java
Print this page
@@ -62,21 +62,21 @@
*/
public class Arguments {
private static final ResourceBundle I18N = ResourceBundle.getBundle(
"jdk.jpackage.internal.resources.MainResources");
- private static final String IMAGE_MODE = "image";
- private static final String INSTALLER_MODE = "installer";
+ private static final String APPIMAGE_MODE = "create-app-image";
+ private static final String INSTALLER_MODE = "create-installer";
private static final String FA_EXTENSIONS = "extension";
private static final String FA_CONTENT_TYPE = "mime-type";
private static final String FA_DESCRIPTION = "description";
private static final String FA_ICON = "icon";
- public static final BundlerParamInfo<Boolean> CREATE_IMAGE =
+ public static final BundlerParamInfo<Boolean> CREATE_APP_IMAGE =
new StandardBundlerParam<>(
- IMAGE_MODE,
+ APPIMAGE_MODE,
Boolean.class,
p -> Boolean.FALSE,
(s, p) -> (s == null || "null".equalsIgnoreCase(s)) ?
true : Boolean.valueOf(s));
@@ -98,12 +98,10 @@
private int pos = 0;
private List<String> argList = null;
private List<CLIOptions> allOptions = null;
- private ArrayList<String> files = null;
-
private String input = null;
private String output = null;
private boolean hasMainJar = false;
private boolean hasMainClass = false;
@@ -150,14 +148,14 @@
addLaunchers = new ArrayList<>();
}
// CLIOptions is public for DeployParamsTest
public enum CLIOptions {
- CREATE_IMAGE(IMAGE_MODE, OptionCategories.MODE, () -> {
+ CREATE_APP_IMAGE(APPIMAGE_MODE, OptionCategories.MODE, () -> {
context().bundleType = BundlerType.IMAGE;
context().deployParams.setTargetFormat("image");
- setOptionValue(IMAGE_MODE, true);
+ setOptionValue(APPIMAGE_MODE, true);
}),
CREATE_INSTALLER(INSTALLER_MODE, OptionCategories.MODE, () -> {
setOptionValue(INSTALLER_MODE, true);
context().bundleType = BundlerType.INSTALLER;
@@ -206,17 +204,10 @@
OptionCategories.PROPERTY, () -> {
String resourceDir = popArg();
setOptionValue("resource-dir", resourceDir);
}),
- FILES ("files", "f", OptionCategories.PROPERTY, () -> {
- context().files = new ArrayList<>();
- String files = popArg();
- context().files.addAll(
- Arrays.asList(files.split(File.pathSeparator)));
- }),
-
ARGUMENTS ("arguments", OptionCategories.PROPERTY, () -> {
List<String> arguments = getArgumentList(popArg());
setOptionValue("arguments", arguments);
}),
@@ -270,12 +261,20 @@
}),
ADD_LAUNCHER ("add-launcher",
OptionCategories.PROPERTY, () -> {
+ String spec = popArg();
+ String name = null;
+ String filename = spec;
+ if (spec.contains("=")) {
+ String[] values = spec.split("=", 2);
+ name = values[0];
+ filename = values[1];
+ }
context().addLaunchers.add(
- new AddLauncherArguments(popArg()));
+ new AddLauncherArguments(name, filename));
}),
TEMP_ROOT ("temp-root", OptionCategories.PROPERTY, () -> {
context().buildRoot = popArg();
context().userProvidedBuildRoot = true;
@@ -417,11 +416,11 @@
public String getId() {
return this.id;
}
String getIdWithPrefix() {
- String prefix = isMode() ? "create-" : "--";
+ String prefix = isMode() ? "" : "--";
return prefix + this.id;
}
String getShortIdWithPrefix() {
return this.shortId == null ? null : "-" + this.shortId;
@@ -521,11 +520,11 @@
// display warning for arguments that are not supported
// for current configuration.
validateArguments();
- addResources(deployParams, input, files);
+ addResources(deployParams, input);
deployParams.setBundleType(bundleType);
List<Map<String, ? super Object>> launchersAsMap =
new ArrayList<>();
@@ -586,11 +585,11 @@
}
}
private void validateArguments() throws PackagerException {
CLIOptions mode = allOptions.get(0);
- boolean imageOnly = (mode == CLIOptions.CREATE_IMAGE);
+ boolean imageOnly = (mode == CLIOptions.CREATE_APP_IMAGE);
boolean hasAppImage = allOptions.contains(
CLIOptions.PREDEFINED_APP_IMAGE);
boolean hasRuntime = allOptions.contains(
CLIOptions.PREDEFINED_RUNTIME_IMAGE);
boolean installerOnly = !imageOnly && hasAppImage;
@@ -726,38 +725,33 @@
}
return bundleCreated;
}
private void addResources(DeployParams deployParams,
- String inputdir, List<String> inputfiles) {
+ String inputdir) throws PackagerException {
if (inputdir == null || inputdir.isEmpty()) {
return;
}
File baseDir = new File(inputdir);
if (!baseDir.isDirectory()) {
- Log.error(
- "Unable to add resources: \"--input\" is not a directory.");
- return;
+ throw new PackagerException("ERR_InputNotDirectory", inputdir);
+ }
+ if (!baseDir.canRead()) {
+ throw new PackagerException("ERR_CannotReadInputDir", inputdir);
}
List<String> fileNames;
- if (inputfiles != null) {
- fileNames = inputfiles;
- } else {
- // "-files" is omitted, all files in input cdir (which
- // is a mandatory argument in this case) will be packaged.
fileNames = new ArrayList<>();
try (Stream<Path> files = Files.list(baseDir.toPath())) {
files.forEach(file -> fileNames.add(
file.getFileName().toString()));
} catch (IOException e) {
Log.error("Unable to add resources: " + e.getMessage());
}
- }
fileNames.forEach(file -> deployParams.addResource(baseDir, file));
deployParams.setClasspath();
}
< prev index next >