Skip to content

8364564: Shortcut configuration is not recorded in .jpackage.xml file #26604

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
86 commits
Select commit Hold shift + click to select a range
db88a85
LinuxHelper: fix a typo
alexeysemenyukoracle Jul 23, 2025
66f527c
AdditionalLauncher: add AdditionalLauncher.PropertyFile() ctor; AppIm…
alexeysemenyukoracle Jul 24, 2025
53ea833
Introduce MsiDatabase; Implement launcher shortcut verification in MS…
alexeysemenyukoracle Jul 23, 2025
54f2d0e
LauncherIconVerifier: add verifyFileInAppImageOnly() to control if to…
alexeysemenyukoracle Jul 28, 2025
05a79ec
Remove redundant shortcut verification code: it duplicates code in Wi…
alexeysemenyukoracle Jul 24, 2025
d34229f
Simplify AdditionalLauncher.PropertyFile
alexeysemenyukoracle Jul 24, 2025
4cc2f3d
Add missing CommandArguments.verifyMutable() calls.
alexeysemenyukoracle Jul 25, 2025
840d464
WindowsHelper: fix a typo
alexeysemenyukoracle Jul 26, 2025
769fd7f
AddLauncherTest, UpgradeTest, WinShortcutVerifier, ConfigFilesStasher…
alexeysemenyukoracle Jul 24, 2025
06cf7ae
Use JPackageCommand.createMutableCopy()
alexeysemenyukoracle Jul 26, 2025
d5caa5c
Decouple additional launcher configuration and verification in the Ad…
alexeysemenyukoracle Jul 27, 2025
5357688
PerUserCfgTest: follow-up changes in AdditionalLauncher
alexeysemenyukoracle Jul 26, 2025
777830c
LauncherAsServiceVerifier: follow-up for the changes in the Additiona…
alexeysemenyukoracle Jul 27, 2025
1dc3781
Rework .desktop files verification: Always verify .desktop files are …
alexeysemenyukoracle Jul 28, 2025
ff1c5d2
PrintEnv: support `--print-workdir` CLI option and `jpackage.test.app…
alexeysemenyukoracle Jul 30, 2025
02ac3e7
LinuxHelper: add getInvokeShortcutSpecs(); add DesktopFile type to st…
alexeysemenyukoracle Jul 30, 2025
6d62ef7
WinShortcutVerifier: add getInvokeShortcutSpecs(); streamline expectL…
alexeysemenyukoracle Jul 30, 2025
1829a15
AddLShortcutTest: add testStartupDirectory() tests to exercise combin…
alexeysemenyukoracle Jul 30, 2025
3ba7bf7
WinShortcutVerifier: fix bad merge
alexeysemenyukoracle Jul 31, 2025
e7822ea
AddLShortcutTest: make it work on Linux
alexeysemenyukoracle Jul 31, 2025
b75a974
LinuxHelper: Use `gtk-launch` command to launch .desktop files
alexeysemenyukoracle Jul 31, 2025
8d8e7d8
LauncherShortcut: bugfix
alexeysemenyukoracle Jul 31, 2025
eb1570a
LauncherShortcut: make it work with the current variant of jpackage w…
alexeysemenyukoracle Jul 31, 2025
2e7e746
AdditionalLauncher: bugfix
alexeysemenyukoracle Jul 31, 2025
2d754ee
Consistent log message format
alexeysemenyukoracle Aug 1, 2025
67bea7d
Bash script to clean jpackage test log files to reduce noise in diff-s
alexeysemenyukoracle Aug 1, 2025
b5da807
Fix a typo
alexeysemenyukoracle Aug 1, 2025
a56e55a
LinuxHelper: allow empty lines in .desktop files
alexeysemenyukoracle Aug 1, 2025
9a4ec0f
WinShortcutVerifier: make it a better fit for JDK-8308349
alexeysemenyukoracle Aug 1, 2025
36410b7
LinuxHelper: bugfix
alexeysemenyukoracle Aug 1, 2025
24ce3ed
AddLShortcutTest: modify
alexeysemenyukoracle Aug 1, 2025
98b916e
LinuxHelper: bugfix
alexeysemenyukoracle Aug 1, 2025
c8f034f
AddLShortcutTest: make it a better fit for JDK-8308349
alexeysemenyukoracle Aug 1, 2025
c280a9f
clean_test_output.sh: better
alexeysemenyukoracle Aug 1, 2025
6f42811
JPackageCommand: remove path to the unpacked directory from the argum…
alexeysemenyukoracle Aug 1, 2025
b4fcbdb
JPackageCommand: verify names of additional launcher are precisely re…
alexeysemenyukoracle Aug 2, 2025
975a493
LauncherShortcut: add appImageFilePropertyName()
alexeysemenyukoracle Aug 2, 2025
1403066
Use java.time.Duration and java.time.Instant in TKit.waitForFileCreat…
alexeysemenyukoracle Aug 4, 2025
a95677f
Use TKit.waitForFileCreated() to await for test output file
alexeysemenyukoracle Aug 4, 2025
7b86ad1
LinuxHelper: fix a typo
alexeysemenyukoracle Jul 23, 2025
39851db
AdditionalLauncher: add AdditionalLauncher.PropertyFile() ctor; AppIm…
alexeysemenyukoracle Jul 24, 2025
33e85f2
Introduce MsiDatabase; Implement launcher shortcut verification in MS…
alexeysemenyukoracle Jul 23, 2025
476bbf5
LauncherIconVerifier: add verifyFileInAppImageOnly() to control if to…
alexeysemenyukoracle Jul 28, 2025
184ce26
Remove redundant shortcut verification code: it duplicates code in Wi…
alexeysemenyukoracle Jul 24, 2025
095f8dc
Simplify AdditionalLauncher.PropertyFile
alexeysemenyukoracle Jul 24, 2025
ce9114f
Add missing CommandArguments.verifyMutable() calls.
alexeysemenyukoracle Jul 25, 2025
0775aa6
WindowsHelper: fix a typo
alexeysemenyukoracle Jul 26, 2025
fcdb5b0
AddLauncherTest, UpgradeTest, WinShortcutVerifier, ConfigFilesStasher…
alexeysemenyukoracle Jul 24, 2025
7131578
Use JPackageCommand.createMutableCopy()
alexeysemenyukoracle Jul 26, 2025
adc8e14
Decouple additional launcher configuration and verification in the Ad…
alexeysemenyukoracle Jul 27, 2025
512f9f9
PerUserCfgTest: follow-up changes in AdditionalLauncher
alexeysemenyukoracle Jul 26, 2025
1d54092
LauncherAsServiceVerifier: follow-up for the changes in the Additiona…
alexeysemenyukoracle Jul 27, 2025
fd50c91
Rework .desktop files verification: Always verify .desktop files are …
alexeysemenyukoracle Jul 28, 2025
251033b
PrintEnv: support `--print-workdir` CLI option and `jpackage.test.app…
alexeysemenyukoracle Jul 30, 2025
6156136
LinuxHelper: add getInvokeShortcutSpecs(); add DesktopFile type to st…
alexeysemenyukoracle Jul 30, 2025
f877049
WinShortcutVerifier: add getInvokeShortcutSpecs(); streamline expectL…
alexeysemenyukoracle Jul 30, 2025
27ed69b
AddLShortcutTest: add testStartupDirectory() tests to exercise combin…
alexeysemenyukoracle Jul 30, 2025
c76aacd
WinShortcutVerifier: fix bad merge
alexeysemenyukoracle Jul 31, 2025
869a0f6
AddLShortcutTest: make it work on Linux
alexeysemenyukoracle Jul 31, 2025
527b010
LinuxHelper: Use `gtk-launch` command to launch .desktop files
alexeysemenyukoracle Jul 31, 2025
d24a167
LauncherShortcut: bugfix
alexeysemenyukoracle Jul 31, 2025
4e08a42
LauncherShortcut: make it work with the current variant of jpackage w…
alexeysemenyukoracle Jul 31, 2025
442fc74
AdditionalLauncher: bugfix
alexeysemenyukoracle Jul 31, 2025
2dcae64
Consistent log message format
alexeysemenyukoracle Aug 1, 2025
7be8ad0
Bash script to clean jpackage test log files to reduce noise in diff-s
alexeysemenyukoracle Aug 1, 2025
9d55c1c
Fix a typo
alexeysemenyukoracle Aug 1, 2025
1c7e011
LinuxHelper: allow empty lines in .desktop files
alexeysemenyukoracle Aug 1, 2025
d7a1dc2
WinShortcutVerifier: make it a better fit for JDK-8308349
alexeysemenyukoracle Aug 1, 2025
63a2088
LinuxHelper: bugfix
alexeysemenyukoracle Aug 1, 2025
3cd7f7a
AddLShortcutTest: modify
alexeysemenyukoracle Aug 1, 2025
317354f
LinuxHelper: bugfix
alexeysemenyukoracle Aug 1, 2025
9617f83
AddLShortcutTest: make it a better fit for JDK-8308349
alexeysemenyukoracle Aug 1, 2025
0139d14
clean_test_output.sh: better
alexeysemenyukoracle Aug 1, 2025
73836c0
JPackageCommand: remove path to the unpacked directory from the argum…
alexeysemenyukoracle Aug 1, 2025
e80aba5
JPackageCommand: verify names of additional launcher are precisely re…
alexeysemenyukoracle Aug 2, 2025
3e63c20
LauncherShortcut: add appImageFilePropertyName()
alexeysemenyukoracle Aug 2, 2025
ff64379
Use java.time.Duration and java.time.Instant in TKit.waitForFileCreat…
alexeysemenyukoracle Aug 4, 2025
e4cdb22
Use TKit.waitForFileCreated() to await for test output file
alexeysemenyukoracle Aug 4, 2025
4742b3d
Merge branch 'JDK-8334238' of https://github.com/alexeysemenyukoracle…
alexeysemenyukoracle Aug 6, 2025
eb23b4a
Merge branch 'master' into JDK-8334238
alexeysemenyukoracle Aug 6, 2025
2d31e6a
TKit: bugfix
alexeysemenyukoracle Aug 6, 2025
d2cd69d
Merge branch 'master' into JDK-8334238
alexeysemenyukoracle Aug 7, 2025
9413403
LauncherVerifier: add verifyInAppImageFile()
alexeysemenyukoracle Aug 2, 2025
0c0300e
8308349: missing working directory option for launcher when invoked f…
alexeysemenyukoracle Jun 27, 2025
397abf8
Revert excessive changes of JDK-8308349 patch irrelevant to JDK-8364564
alexeysemenyukoracle Aug 2, 2025
7ca2e94
LauncherShortcut: reflects changes in the implementation
alexeysemenyukoracle Aug 2, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@
*/
package jdk.jpackage.internal;

import jdk.jpackage.internal.model.LinuxPackage;
import jdk.jpackage.internal.model.LinuxLauncher;
import jdk.jpackage.internal.model.Package;
import jdk.jpackage.internal.model.Launcher;
import static jdk.jpackage.internal.ApplicationImageUtils.createLauncherIconResource;
import static jdk.jpackage.internal.model.LauncherShortcut.toRequest;
import static jdk.jpackage.internal.util.function.ThrowingFunction.toFunction;

import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
Expand All @@ -45,12 +45,13 @@
import javax.imageio.ImageIO;
import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamWriter;
import static jdk.jpackage.internal.ApplicationImageUtils.createLauncherIconResource;
import jdk.jpackage.internal.model.FileAssociation;
import jdk.jpackage.internal.model.LinuxLauncher;
import jdk.jpackage.internal.model.LinuxPackage;
import jdk.jpackage.internal.model.Package;
import jdk.jpackage.internal.util.CompositeProxy;
import jdk.jpackage.internal.util.PathUtils;
import jdk.jpackage.internal.util.XmlUtils;
import static jdk.jpackage.internal.util.function.ThrowingFunction.toFunction;

/**
* Helper to create files for desktop integration.
Expand All @@ -77,7 +78,7 @@ private DesktopIntegration(BuildEnv env, LinuxPackage pkg, LinuxLauncher launche
// Need desktop and icon files if one of conditions is met:
// - there are file associations configured
// - user explicitly requested to create a shortcut
boolean withDesktopFile = !associations.isEmpty() || launcher.shortcut().orElse(false);
boolean withDesktopFile = !associations.isEmpty() || toRequest(launcher.shortcut()).orElse(false);

var curIconResource = createLauncherIconResource(pkg.app(), launcher,
env::createResource);
Expand Down Expand Up @@ -132,7 +133,7 @@ private DesktopIntegration(BuildEnv env, LinuxPackage pkg, LinuxLauncher launche
nestedIntegrations = pkg.app().additionalLaunchers().stream().map(v -> {
return (LinuxLauncher)v;
}).filter(l -> {
return l.shortcut().orElse(true);
return toRequest(l.shortcut()).orElse(true);
}).map(toFunction(l -> {
return new DesktopIntegration(env, pkg, l);
})).toList();
Expand Down Expand Up @@ -225,15 +226,17 @@ private List<String> requiredPackagesSelf() {
}

private Map<String, String> createDataForDesktopFile() {

var installedLayout = pkg.asInstalledPackageApplicationLayout().orElseThrow();

Map<String, String> data = new HashMap<>();
data.put("APPLICATION_NAME", launcher.name());
data.put("APPLICATION_DESCRIPTION", launcher.description());
data.put("APPLICATION_ICON", iconFile.map(
f -> f.installPath().toString()).orElse(null));
data.put("DEPLOY_BUNDLE_CATEGORY", pkg.menuGroupName());
data.put("APPLICATION_LAUNCHER", Enquoter.forPropertyValues().applyTo(
pkg.asInstalledPackageApplicationLayout().orElseThrow().launchersDirectory().resolve(
launcher.executableNameWithSuffix()).toString()));
installedLayout.launchersDirectory().resolve(launcher.executableNameWithSuffix()).toString()));

return data;
}
Expand Down Expand Up @@ -481,7 +484,7 @@ private static int getIconSize(FileAssociation fa) {

private final BuildEnv env;
private final LinuxPackage pkg;
private final Launcher launcher;
private final LinuxLauncher launcher;

private final List<LinuxFileAssociation> associations;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,14 @@
import static jdk.jpackage.internal.FromParams.createApplicationBundlerParam;
import static jdk.jpackage.internal.FromParams.createPackageBuilder;
import static jdk.jpackage.internal.FromParams.createPackageBundlerParam;
import static jdk.jpackage.internal.FromParams.findLauncherShortcut;
import static jdk.jpackage.internal.LinuxPackagingPipeline.APPLICATION_LAYOUT;
import static jdk.jpackage.internal.StandardBundlerParam.SHORTCUT_HINT;
import static jdk.jpackage.internal.model.StandardPackageType.LINUX_DEB;
import static jdk.jpackage.internal.model.StandardPackageType.LINUX_RPM;
import static jdk.jpackage.internal.util.function.ThrowingFunction.toFunction;

import java.io.IOException;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Stream;
import jdk.jpackage.internal.model.ConfigException;
import jdk.jpackage.internal.model.LinuxApplication;
import jdk.jpackage.internal.model.LinuxLauncher;
Expand All @@ -51,11 +49,10 @@ final class LinuxFromParams {
private static LinuxApplication createLinuxApplication(
Map<String, ? super Object> params) throws ConfigException, IOException {
final var launcherFromParams = new LauncherFromParams();

final var app = createApplicationBuilder(params, toFunction(launcherParams -> {
final var launcher = launcherFromParams.create(launcherParams);
final var shortcut = Stream.of(SHORTCUT_HINT, LINUX_SHORTCUT_HINT).map(param -> {
return param.findIn(launcherParams);
}).filter(Optional::isPresent).map(Optional::get).findFirst();
final var shortcut = findLauncherShortcut(LINUX_SHORTCUT_HINT, params, launcherParams);
return LinuxLauncher.create(launcher, new LinuxLauncherMixin.Stub(shortcut));
}), APPLICATION_LAYOUT).create();
return LinuxApplication.create(app);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
*/
package jdk.jpackage.internal.model;

import java.util.HashMap;
import java.util.Map;
import jdk.jpackage.internal.util.CompositeProxy;

Expand All @@ -36,9 +37,11 @@ public interface LinuxLauncher extends Launcher, LinuxLauncherMixin {

@Override
default Map<String, String> extraAppImageFileData() {
return shortcut().map(v -> {
return Map.of("shortcut", Boolean.toString(v));
}).orElseGet(Map::of);
Map<String, String> map = new HashMap<>();
shortcut().ifPresent(shortcut -> {
shortcut.store(SHORTCUT_ID, map::put);
});
return map;
}

/**
Expand All @@ -52,4 +55,6 @@ default Map<String, String> extraAppImageFileData() {
public static LinuxLauncher create(Launcher launcher, LinuxLauncherMixin mixin) {
return CompositeProxy.create(LinuxLauncher.class, launcher, mixin);
}

public static final String SHORTCUT_ID = "linux-shortcut";
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,24 +32,20 @@
public interface LinuxLauncherMixin {

/**
* Gets the start menu shortcut setting of this application launcher.
* Gets the start menu shortcut of this application launcher.
* <p>
* Returns <code>true</code> if this application launcher was requested to have
* the start menu shortcut.
* <p>
* Returns <code>false</code> if this application launcher was requested not to
* have the start menu shortcut.
* <p>
* Returns an empty {@link Optional} instance if there was no request about the
* start menu shortcut for this application launcher.
* Returns a non-empty {@link Optional} instance if a request about the start
* menu shortcut for this application launcher was made and an empty
* {@link Optional} instance if there was no request about the start menu
* shortcut for this application launcher.
*
* @return the start menu shortcut setting of this application launcher
* @return the start menu shortcut of this application launcher
*/
Optional<Boolean> shortcut();
Optional<LauncherShortcut> shortcut();

/**
* Default implementation of {@link LinuxLauncherMixin} interface.
*/
record Stub(Optional<Boolean> shortcut) implements LinuxLauncherMixin {
record Stub(Optional<LauncherShortcut> shortcut) implements LinuxLauncherMixin {
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,6 @@
import jdk.jpackage.internal.Arguments.CLIOptions;
import static jdk.jpackage.internal.StandardBundlerParam.LAUNCHER_DATA;
import static jdk.jpackage.internal.StandardBundlerParam.APP_NAME;
import static jdk.jpackage.internal.StandardBundlerParam.MENU_HINT;
import static jdk.jpackage.internal.StandardBundlerParam.SHORTCUT_HINT;

/*
* AddLauncherArguments
Expand Down Expand Up @@ -135,16 +133,16 @@ private void initLauncherMap() {
Arguments.putUnlessNull(bundleParams,
CLIOptions.WIN_CONSOLE_HINT.getId(),
getOptionValue(CLIOptions.WIN_CONSOLE_HINT));
Arguments.putUnlessNull(bundleParams, SHORTCUT_HINT.getID(),
Arguments.putUnlessNull(bundleParams, CLIOptions.WIN_SHORTCUT_HINT.getId(),
getOptionValue(CLIOptions.WIN_SHORTCUT_HINT));
Arguments.putUnlessNull(bundleParams, MENU_HINT.getID(),
Arguments.putUnlessNull(bundleParams, CLIOptions.WIN_MENU_HINT.getId(),
getOptionValue(CLIOptions.WIN_MENU_HINT));
}

if (OperatingSystem.isLinux()) {
Arguments.putUnlessNull(bundleParams, CLIOptions.LINUX_CATEGORY.getId(),
getOptionValue(CLIOptions.LINUX_CATEGORY));
Arguments.putUnlessNull(bundleParams, SHORTCUT_HINT.getID(),
Arguments.putUnlessNull(bundleParams, CLIOptions.LINUX_SHORTCUT_HINT.getId(),
getOptionValue(CLIOptions.LINUX_SHORTCUT_HINT));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
*/
package jdk.jpackage.internal;

import static jdk.jpackage.internal.Arguments.CLIOptions.LINUX_SHORTCUT_HINT;
import static jdk.jpackage.internal.Arguments.CLIOptions.WIN_MENU_HINT;
import static jdk.jpackage.internal.Arguments.CLIOptions.WIN_SHORTCUT_HINT;
import static jdk.jpackage.internal.StandardBundlerParam.ABOUT_URL;
import static jdk.jpackage.internal.StandardBundlerParam.ADD_LAUNCHERS;
import static jdk.jpackage.internal.StandardBundlerParam.ADD_MODULES;
Expand Down Expand Up @@ -63,6 +66,8 @@
import jdk.jpackage.internal.model.ConfigException;
import jdk.jpackage.internal.model.ExternalApplication.LauncherInfo;
import jdk.jpackage.internal.model.Launcher;
import jdk.jpackage.internal.model.LauncherShortcut;
import jdk.jpackage.internal.model.LauncherShortcutStartupDirectory;
import jdk.jpackage.internal.model.PackageType;
import jdk.jpackage.internal.model.RuntimeLayout;
import jdk.jpackage.internal.util.function.ThrowingFunction;
Expand Down Expand Up @@ -165,6 +170,32 @@ static Optional<jdk.jpackage.internal.model.Package> getCurrentPackage(Map<Strin
jdk.jpackage.internal.model.Package.class.getName()));
}

static Optional<LauncherShortcut> findLauncherShortcut(
BundlerParamInfo<Boolean> shortcutParam,
Map<String, ? super Object> mainParams,
Map<String, ? super Object> launcherParams) {

Optional<Boolean> launcherValue;
if (launcherParams == mainParams) {
// The main launcher
launcherValue = Optional.empty();
} else {
launcherValue = shortcutParam.findIn(launcherParams);
}

return launcherValue.map(withShortcut -> {
if (withShortcut) {
return Optional.of(LauncherShortcutStartupDirectory.DEFAULT);
} else {
return Optional.<LauncherShortcutStartupDirectory>empty();
}
}).or(() -> {
return shortcutParam.findIn(mainParams).map(_ -> {
return Optional.of(LauncherShortcutStartupDirectory.DEFAULT);
});
}).map(LauncherShortcut::new);
}

private static ApplicationLaunchers createLaunchers(
Map<String, ? super Object> params,
Function<Map<String, ? super Object>, Launcher> launcherMapper) {
Expand Down Expand Up @@ -195,8 +226,9 @@ private static ApplicationLaunchers createLaunchers(
// mainParams), APP_NAME.fetchFrom(launcherParams)));
launcherParams.put(DESCRIPTION.getID(), DESCRIPTION.fetchFrom(mainParams));
}
return AddLauncherArguments.merge(mainParams, launcherParams, ICON.getID(), ADD_LAUNCHERS
.getID(), FILE_ASSOCIATIONS.getID());
return AddLauncherArguments.merge(mainParams, launcherParams, ICON.getID(),
ADD_LAUNCHERS.getID(), FILE_ASSOCIATIONS.getID(), WIN_MENU_HINT.getId(),
WIN_SHORTCUT_HINT.getId(), LINUX_SHORTCUT_HINT.getId());
}

static final BundlerParamInfo<Application> APPLICATION = createApplicationBundlerParam(null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -307,24 +307,6 @@ final class StandardBundlerParam {
true : Boolean.valueOf(s)
);

static final BundlerParamInfo<Boolean> SHORTCUT_HINT =
new BundlerParamInfo<>(
"shortcut-hint", // not directly related to a CLI option
Boolean.class,
params -> true, // defaults to true
(s, p) -> (s == null || "null".equalsIgnoreCase(s)) ?
true : Boolean.valueOf(s)
);

static final BundlerParamInfo<Boolean> MENU_HINT =
new BundlerParamInfo<>(
"menu-hint", // not directly related to a CLI option
Boolean.class,
params -> true, // defaults to true
(s, p) -> (s == null || "null".equalsIgnoreCase(s)) ?
true : Boolean.valueOf(s)
);

static final BundlerParamInfo<Path> RESOURCE_DIR =
new BundlerParamInfo<>(
Arguments.CLIOptions.RESOURCE_DIR.getId(),
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
/*
* Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation. Oracle designates this
* particular file as subject to the "Classpath" exception as provided
* by Oracle in the LICENSE file that accompanied this code.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* 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.model;

import java.util.Objects;
import java.util.Optional;
import java.util.function.BiConsumer;

/**
* A shortcut to launch an application launcher.
*/
public record LauncherShortcut(Optional<LauncherShortcutStartupDirectory> startupDirectory) {

public LauncherShortcut {
Objects.requireNonNull(startupDirectory);
}

public LauncherShortcut(LauncherShortcutStartupDirectory startupDirectory) {
this(Optional.of(startupDirectory));
}

public LauncherShortcut() {
this(Optional.empty());
}

void store(String propertyName, BiConsumer<String, String> sink) {
Objects.requireNonNull(propertyName);
Objects.requireNonNull(sink);
if (startupDirectory.isEmpty()) {
sink.accept(propertyName, Boolean.FALSE.toString());
} else {
startupDirectory.ifPresent(v -> {
sink.accept(propertyName, v.asStringValue());
});
}
}

/**
* Converts the given shortcut into a shortcut request.
* <p>
* Returns <code>true</code> if shortcut was explicitly requested.
* <p>
* Returns <code>false</code> if no shortcut was explicitly requested.
* <p>
* Returns an empty {@link Optional} instance if there was no shortcut request.
*
* @return shortcut request
*/
public static Optional<Boolean> toRequest(Optional<LauncherShortcut> shortcut) {
return shortcut.map(v -> v.startupDirectory().isPresent());
}
}
Loading