< prev index next >
src/jdk.jpackage/share/classes/jdk/jpackage/internal/Arguments.java
Print this page
*** 72,100 ****
private static final String FA_DESCRIPTION = "description";
private static final String FA_ICON = "icon";
public static final BundlerParamInfo<Boolean> CREATE_IMAGE =
new StandardBundlerParam<>(
- I18N.getString("param.create-image.name"),
- I18N.getString("param.create-image.description"),
IMAGE_MODE,
Boolean.class,
p -> Boolean.FALSE,
(s, p) -> (s == null || "null".equalsIgnoreCase(s)) ?
true : Boolean.valueOf(s));
public static final BundlerParamInfo<Boolean> CREATE_INSTALLER =
new StandardBundlerParam<>(
- I18N.getString("param.create-installer.name"),
- I18N.getString("param.create-installer.description"),
INSTALLER_MODE,
Boolean.class,
p -> Boolean.FALSE,
(s, p) -> (s == null || "null".equalsIgnoreCase(s)) ?
true : Boolean.valueOf(s));
! // regexp for parsing args (for example, for secondary launchers)
private static Pattern pattern = Pattern.compile(
"(?:(?:([\"'])(?:\\\\\\1|.)*?(?:\\1|$))|(?:\\\\[\"'\\s]|[^\\s]))++");
private DeployParams deployParams = null;
private BundlerType bundleType = null;
--- 72,96 ----
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));
public static final BundlerParamInfo<Boolean> CREATE_INSTALLER =
new StandardBundlerParam<>(
INSTALLER_MODE,
Boolean.class,
p -> Boolean.FALSE,
(s, p) -> (s == null || "null".equalsIgnoreCase(s)) ?
true : Boolean.valueOf(s));
! // regexp for parsing args (for example, for additional launchers)
private static Pattern pattern = Pattern.compile(
"(?:(?:([\"'])(?:\\\\\\1|.)*?(?:\\1|$))|(?:\\\\[\"'\\s]|[^\\s]))++");
private DeployParams deployParams = null;
private BundlerType bundleType = null;
*** 121,131 ****
private static boolean runtimeInstaller = false;
private List<jdk.jpackage.internal.Bundler> platformBundlers = null;
! private List<SecondaryLauncherArguments> secondaryLaunchers = null;
private static Map<String, CLIOptions> argIds = new HashMap<>();
private static Map<String, CLIOptions> argShortIds = new HashMap<>();
{
--- 117,127 ----
private static boolean runtimeInstaller = false;
private List<jdk.jpackage.internal.Bundler> platformBundlers = null;
! private List<AddLauncherArguments> addLaunchers = null;
private static Map<String, CLIOptions> argIds = new HashMap<>();
private static Map<String, CLIOptions> argShortIds = new HashMap<>();
{
*** 157,172 ****
context().bundleType = BundlerType.INSTALLER;
String format = "installer";
context().deployParams.setTargetFormat(format);
}),
- RUNTIME_INSTALLER("runtime-installer",
- OptionCategories.PROPERTY, () -> {
- runtimeInstaller = true;
- setOptionValue("runtime-installer", true);
- }),
-
INSTALLER_TYPE("installer-type", OptionCategories.PROPERTY, () -> {
String type = popArg();
if (BundlerType.INSTALLER.equals(context().bundleType)) {
context().deployParams.setTargetFormat(type);
context().hasTargetFormat = true;
--- 153,162 ----
*** 186,196 ****
DESCRIPTION ("description", "d", OptionCategories.PROPERTY),
VENDOR ("vendor", OptionCategories.PROPERTY),
! APPCLASS ("main-class", "c", OptionCategories.PROPERTY, () -> {
context().hasMainClass = true;
setOptionValue("main-class", popArg());
}),
NAME ("name", "n", OptionCategories.PROPERTY),
--- 176,186 ----
DESCRIPTION ("description", "d", OptionCategories.PROPERTY),
VENDOR ("vendor", OptionCategories.PROPERTY),
! APPCLASS ("main-class", OptionCategories.PROPERTY, () -> {
context().hasMainClass = true;
setOptionValue("main-class", popArg());
}),
NAME ("name", "n", OptionCategories.PROPERTY),
*** 200,213 ****
VERBOSE ("verbose", OptionCategories.PROPERTY, () -> {
setOptionValue("verbose", true);
Log.setVerbose(true);
}),
- OVERWRITE ("overwrite", OptionCategories.PROPERTY, () -> {
- setOptionValue("overwrite", true);
- }),
-
RESOURCE_DIR("resource-dir",
OptionCategories.PROPERTY, () -> {
String resourceDir = popArg();
setOptionValue("resource-dir", resourceDir);
}),
--- 190,199 ----
*** 217,236 ****
String files = popArg();
context().files.addAll(
Arrays.asList(files.split(File.pathSeparator)));
}),
! ARGUMENTS ("arguments", "a", OptionCategories.PROPERTY, () -> {
List<String> arguments = getArgumentList(popArg());
setOptionValue("arguments", arguments);
}),
- STRIP_NATIVE_COMMANDS ("strip-native-commands",
- OptionCategories.PROPERTY, () -> {
- setOptionValue("strip-native-commands", true);
- }),
-
ICON ("icon", OptionCategories.PROPERTY),
CATEGORY ("category", OptionCategories.PROPERTY),
COPYRIGHT ("copyright", OptionCategories.PROPERTY),
LICENSE_FILE ("license-file", OptionCategories.PROPERTY),
--- 203,217 ----
String files = popArg();
context().files.addAll(
Arrays.asList(files.split(File.pathSeparator)));
}),
! ARGUMENTS ("arguments", OptionCategories.PROPERTY, () -> {
List<String> arguments = getArgumentList(popArg());
setOptionValue("arguments", arguments);
}),
ICON ("icon", OptionCategories.PROPERTY),
CATEGORY ("category", OptionCategories.PROPERTY),
COPYRIGHT ("copyright", OptionCategories.PROPERTY),
LICENSE_FILE ("license-file", OptionCategories.PROPERTY),
*** 277,296 ****
// check that we really add _another_ value to the list
setOptionValue("file-associations", associationList);
}),
! SECONDARY_LAUNCHER ("secondary-launcher",
OptionCategories.PROPERTY, () -> {
! context().secondaryLaunchers.add(
! new SecondaryLauncherArguments(popArg()));
}),
! BUILD_ROOT ("build-root", OptionCategories.PROPERTY, () -> {
context().buildRoot = popArg();
context().userProvidedBuildRoot = true;
! setOptionValue("build-root", context().buildRoot);
}),
INSTALL_DIR ("install-dir", OptionCategories.PROPERTY),
PREDEFINED_APP_IMAGE ("app-image", OptionCategories.PROPERTY, ()-> {
--- 258,277 ----
// check that we really add _another_ value to the list
setOptionValue("file-associations", associationList);
}),
! ADD_LAUNCHER ("add-launcher",
OptionCategories.PROPERTY, () -> {
! context().addLaunchers.add(
! new AddLauncherArguments(popArg()));
}),
! TEMP_ROOT ("temp-root", OptionCategories.PROPERTY, () -> {
context().buildRoot = popArg();
context().userProvidedBuildRoot = true;
! setOptionValue("temp-root", context().buildRoot);
}),
INSTALL_DIR ("install-dir", OptionCategories.PROPERTY),
PREDEFINED_APP_IMAGE ("app-image", OptionCategories.PROPERTY, ()-> {
*** 298,308 ****
context().hasAppImage = true;
}),
PREDEFINED_RUNTIME_IMAGE ("runtime-image", OptionCategories.PROPERTY),
! MAIN_JAR ("main-jar", "j", OptionCategories.PROPERTY, () -> {
context().mainJarPath = popArg();
context().hasMainJar = true;
setOptionValue("main-jar", context().mainJarPath);
}),
--- 279,289 ----
context().hasAppImage = true;
}),
PREDEFINED_RUNTIME_IMAGE ("runtime-image", OptionCategories.PROPERTY),
! MAIN_JAR ("main-jar", OptionCategories.PROPERTY, () -> {
context().mainJarPath = popArg();
context().hasMainJar = true;
setOptionValue("main-jar", context().mainJarPath);
}),
*** 502,512 ****
deployParams = new DeployParams();
bundleType = BundlerType.NONE;
allOptions = new ArrayList<>();
! secondaryLaunchers = new ArrayList<>();
}
public boolean processArguments() throws Exception {
try {
--- 483,493 ----
deployParams = new DeployParams();
bundleType = BundlerType.NONE;
allOptions = new ArrayList<>();
! addLaunchers = new ArrayList<>();
}
public boolean processArguments() throws Exception {
try {
*** 551,566 ****
deployParams.setBundleType(bundleType);
List<Map<String, ? super Object>> launchersAsMap =
new ArrayList<>();
! for (SecondaryLauncherArguments sl : secondaryLaunchers) {
launchersAsMap.add(sl.getLauncherMap());
}
deployParams.addBundleArgument(
! StandardBundlerParam.SECONDARY_LAUNCHERS.getID(),
launchersAsMap);
// at this point deployParams should be already configured
deployParams.validate();
--- 532,547 ----
deployParams.setBundleType(bundleType);
List<Map<String, ? super Object>> launchersAsMap =
new ArrayList<>();
! for (AddLauncherArguments sl : addLaunchers) {
launchersAsMap.add(sl.getLauncherMap());
}
deployParams.addBundleArgument(
! StandardBundlerParam.ADD_LAUNCHERS.getID(),
launchersAsMap);
// at this point deployParams should be already configured
deployParams.validate();
*** 569,586 ****
// validate name(s)
ArrayList<String> usedNames = new ArrayList<String>();
usedNames.add(bp.getName()); // add main app name
! for (SecondaryLauncherArguments sl : secondaryLaunchers) {
Map<String, ? super Object> slMap = sl.getLauncherMap();
String slName =
(String) slMap.get(Arguments.CLIOptions.NAME.getId());
if (slName == null) {
! throw new PackagerException("ERR_NoSecondaryLauncherName");
}
! // same rules apply to secondary launcher names as app name
DeployParams.validateName(slName, false);
for (String usedName : usedNames) {
if (slName.equals(usedName)) {
throw new PackagerException("ERR_NoUniqueName");
}
--- 550,567 ----
// validate name(s)
ArrayList<String> usedNames = new ArrayList<String>();
usedNames.add(bp.getName()); // add main app name
! for (AddLauncherArguments sl : addLaunchers) {
Map<String, ? super Object> slMap = sl.getLauncherMap();
String slName =
(String) slMap.get(Arguments.CLIOptions.NAME.getId());
if (slName == null) {
! throw new PackagerException("ERR_NoAddLauncherName");
}
! // same rules apply to additional launcher names as app name
DeployParams.validateName(slName, false);
for (String usedName : usedNames) {
if (slName.equals(usedName)) {
throw new PackagerException("ERR_NoUniqueName");
}
*** 603,623 ****
return false;
}
}
}
! private void validateArguments() {
CLIOptions mode = allOptions.get(0);
for (CLIOptions option : allOptions) {
! if(!ValidOptions.checkIfSupported(mode, option)) {
! String key = "warning.unsupported.option";
! if (ValidOptions.checkIfOtherSupported(mode, option)) {
! key = "warning.unsupported.mode.option";
}
! Log.info(MessageFormat.format(I18N.getString(key),
! option.getId(), mode));
}
}
}
private List<jdk.jpackage.internal.Bundler> getPlatformBundlers() {
--- 584,633 ----
return false;
}
}
}
! 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;
+ boolean runtimeInstall = !imageOnly && hasRuntime && !hasAppImage &&
+ !hasMainModule && !hasMainJar;
+
for (CLIOptions option : allOptions) {
! if (!ValidOptions.checkIfSupported(option)) {
! // includes option valid only on different platform
! throw new PackagerException("ERR_UnsupportedOption",
! option.getIdWithPrefix());
! }
! if (imageOnly) {
! if (!ValidOptions.checkIfImageSupported(option)) {
! throw new PackagerException("ERR_NotImageOption",
! option.getIdWithPrefix());
! }
! } else if (installerOnly || runtimeInstall) {
! if (!ValidOptions.checkIfInstallerSupported(option)) {
! String key = runtimeInstaller ?
! "ERR_NoInstallerEntryPoint" : "ERR_NotInstallerOption";
! throw new PackagerException(key, option.getIdWithPrefix());
! }
! }
}
! if (installerOnly && hasRuntime) {
! // note --runtime-image is only for image or runtime installer.
! throw new PackagerException("ERR_NotInstallerOption",
! CLIOptions.PREDEFINED_RUNTIME_IMAGE.getIdWithPrefix());
}
+ if (hasMainJar && hasMainModule) {
+ throw new PackagerException("ERR_BothMainJarAndModule");
+ }
+ if (imageOnly && !hasMainJar && !hasMainModule) {
+ throw new PackagerException("ERR_NoEntryPoint");
}
}
private List<jdk.jpackage.internal.Bundler> getPlatformBundlers() {
*** 645,663 ****
private boolean generateBundle(Map<String,? super Object> params)
throws PackagerException {
boolean bundleCreated = false;
! // the build-root needs to be fetched from the params early,
// to prevent each copy of the params (such as may be used for
! // secondary launchers) from generating a separate build-root when
// the default is used (the default is a new temp directory)
// The bundler.cleanup() below would not otherwise be able to
// clean these extra (and unneeded) temp directories.
! StandardBundlerParam.BUILD_ROOT.fetchFrom(params);
!
! for (jdk.jpackage.internal.Bundler bundler : getPlatformBundlers()) {
Map<String, ? super Object> localParams = new HashMap<>(params);
try {
if (bundler.validate(localParams)) {
File result =
bundler.execute(localParams, deployParams.outdir);
--- 655,677 ----
private boolean generateBundle(Map<String,? super Object> params)
throws PackagerException {
boolean bundleCreated = false;
! // the temp-root needs to be fetched from the params early,
// to prevent each copy of the params (such as may be used for
! // additional launchers) from generating a separate temp-root when
// the default is used (the default is a new temp directory)
// The bundler.cleanup() below would not otherwise be able to
// clean these extra (and unneeded) temp directories.
! StandardBundlerParam.TEMP_ROOT.fetchFrom(params);
! List<jdk.jpackage.internal.Bundler> bundlers = getPlatformBundlers();
! if (bundlers.isEmpty()) {
! throw new PackagerException("ERR_InvalidInstallerType",
! deployParams.getTargetFormat());
! }
! for (jdk.jpackage.internal.Bundler bundler : bundlers) {
Map<String, ? super Object> localParams = new HashMap<>(params);
try {
if (bundler.validate(localParams)) {
File result =
bundler.execute(localParams, deployParams.outdir);
< prev index next >