< prev index next >
src/jdk.jpackage/share/classes/jdk/jpackage/internal/Arguments.java
Print this page
*** 62,82 ****
*/
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 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 =
new StandardBundlerParam<>(
! IMAGE_MODE,
Boolean.class,
p -> Boolean.FALSE,
(s, p) -> (s == null || "null".equalsIgnoreCase(s)) ?
true : Boolean.valueOf(s));
--- 62,82 ----
*/
public class Arguments {
private static final ResourceBundle I18N = ResourceBundle.getBundle(
"jdk.jpackage.internal.resources.MainResources");
! 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_APP_IMAGE =
new StandardBundlerParam<>(
! APPIMAGE_MODE,
Boolean.class,
p -> Boolean.FALSE,
(s, p) -> (s == null || "null".equalsIgnoreCase(s)) ?
true : Boolean.valueOf(s));
*** 98,109 ****
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;
--- 98,107 ----
*** 150,163 ****
addLaunchers = new ArrayList<>();
}
// CLIOptions is public for DeployParamsTest
public enum CLIOptions {
! CREATE_IMAGE(IMAGE_MODE, OptionCategories.MODE, () -> {
context().bundleType = BundlerType.IMAGE;
context().deployParams.setTargetFormat("image");
! setOptionValue(IMAGE_MODE, true);
}),
CREATE_INSTALLER(INSTALLER_MODE, OptionCategories.MODE, () -> {
setOptionValue(INSTALLER_MODE, true);
context().bundleType = BundlerType.INSTALLER;
--- 148,161 ----
addLaunchers = new ArrayList<>();
}
// CLIOptions is public for DeployParamsTest
public enum CLIOptions {
! CREATE_APP_IMAGE(APPIMAGE_MODE, OptionCategories.MODE, () -> {
context().bundleType = BundlerType.IMAGE;
context().deployParams.setTargetFormat("image");
! setOptionValue(APPIMAGE_MODE, true);
}),
CREATE_INSTALLER(INSTALLER_MODE, OptionCategories.MODE, () -> {
setOptionValue(INSTALLER_MODE, true);
context().bundleType = BundlerType.INSTALLER;
*** 206,222 ****
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);
}),
--- 204,213 ----
*** 270,281 ****
}),
ADD_LAUNCHER ("add-launcher",
OptionCategories.PROPERTY, () -> {
context().addLaunchers.add(
! new AddLauncherArguments(popArg()));
}),
TEMP_ROOT ("temp-root", OptionCategories.PROPERTY, () -> {
context().buildRoot = popArg();
context().userProvidedBuildRoot = true;
--- 261,280 ----
}),
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(name, filename));
}),
TEMP_ROOT ("temp-root", OptionCategories.PROPERTY, () -> {
context().buildRoot = popArg();
context().userProvidedBuildRoot = true;
*** 417,427 ****
public String getId() {
return this.id;
}
String getIdWithPrefix() {
! String prefix = isMode() ? "create-" : "--";
return prefix + this.id;
}
String getShortIdWithPrefix() {
return this.shortId == null ? null : "-" + this.shortId;
--- 416,426 ----
public String getId() {
return this.id;
}
String getIdWithPrefix() {
! String prefix = isMode() ? "" : "--";
return prefix + this.id;
}
String getShortIdWithPrefix() {
return this.shortId == null ? null : "-" + this.shortId;
*** 521,531 ****
// display warning for arguments that are not supported
// for current configuration.
validateArguments();
! addResources(deployParams, input, files);
deployParams.setBundleType(bundleType);
List<Map<String, ? super Object>> launchersAsMap =
new ArrayList<>();
--- 520,530 ----
// display warning for arguments that are not supported
// for current configuration.
validateArguments();
! addResources(deployParams, input);
deployParams.setBundleType(bundleType);
List<Map<String, ? super Object>> launchersAsMap =
new ArrayList<>();
*** 586,596 ****
}
}
private void validateArguments() throws PackagerException {
CLIOptions mode = allOptions.get(0);
! boolean imageOnly = (mode == CLIOptions.CREATE_IMAGE);
boolean hasAppImage = allOptions.contains(
CLIOptions.PREDEFINED_APP_IMAGE);
boolean hasRuntime = allOptions.contains(
CLIOptions.PREDEFINED_RUNTIME_IMAGE);
boolean installerOnly = !imageOnly && hasAppImage;
--- 585,595 ----
}
}
private void validateArguments() throws PackagerException {
CLIOptions mode = allOptions.get(0);
! 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,763 ****
}
return bundleCreated;
}
private void addResources(DeployParams deployParams,
! String inputdir, List<String> inputfiles) {
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;
}
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();
}
--- 725,757 ----
}
return bundleCreated;
}
private void addResources(DeployParams deployParams,
! String inputdir) throws PackagerException {
if (inputdir == null || inputdir.isEmpty()) {
return;
}
File baseDir = new File(inputdir);
if (!baseDir.isDirectory()) {
! throw new PackagerException("ERR_InputNotDirectory", inputdir);
! }
! if (!baseDir.canRead()) {
! throw new PackagerException("ERR_CannotReadInputDir", inputdir);
}
List<String> fileNames;
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 >