Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -84,9 +84,9 @@ LinuxPackage create() throws ConfigException {
private LinuxPackage create(Package pkg) throws ConfigException {
return LinuxPackage.create(pkg, new LinuxPackageMixin.Stub(
Optional.ofNullable(menuGroupName).orElseGet(DEFAULTS::menuGroupName),
Optional.ofNullable(category),
category(),
Optional.ofNullable(additionalDependencies),
Optional.ofNullable(release),
release(),
pkg.asStandardPackageType().map(LinuxPackageArch::getValue).orElseThrow()));
}

Expand Down Expand Up @@ -192,7 +192,7 @@ private record Defaults(String menuGroupName) {

private final PackageBuilder pkgBuilder;

private static final Defaults DEFAULTS = new Defaults(I18N.getString(
"param.menu-group.default"));

// Should be one of https://specifications.freedesktop.org/menu/latest/category-registry.html#main-category-registry
// The category is an ID, not a localizable string
private static final Defaults DEFAULTS = new Defaults("Utility");
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,12 @@ public interface LinuxPackageMixin {
/**
* Gets the name of the start menu group where to create shortcuts for
* application launchers of this package.
* <p>
* It sets the value of the "Categories" property in .desktop files of the
* package.
* <p>
* Should be one of the values from <a href=
* "https://specifications.freedesktop.org/menu/latest/category-registry.html">https://specifications.freedesktop.org/menu/latest/category-registry.html</a>
*
* @return the name of the start menu group where to create shortcuts for
* application launchers of this package
Expand All @@ -44,6 +50,13 @@ public interface LinuxPackageMixin {

/**
* Gets the category of this package.
* <p>
* For RPM packages this is the value of the optional "Group" property.
* <p>
* For DEB packages this is the value of the mandatory "Section" property.
* <a href=
* "https://www.debian.org/doc/debian-policy/ch-archive.html#s-subsections">The
* present list of recognized values.</a>
*
* @return the category of this package
*/
Expand All @@ -62,7 +75,7 @@ public interface LinuxPackageMixin {
* Gets the release of this package. Returns an empty {@link Optional} instance
* if this package doesn't have a release.
* <p>
* For RPM packages, this is the value of a "Release" property in spec file. RPM
* For RPM packages, this is the value of the "Release" property in spec file. RPM
* packages always have a release.
* <p>
* For DEB packages, this is an optional {@code debian_revision} component of a
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ deb.bundler.name=DEB Bundle
rpm.bundler.name=RPM Bundle

param.license-type.default=Unknown
param.menu-group.default=Unknown

resource.deb-control-file=DEB control file
resource.deb-preinstall-script=DEB preinstall script
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -564,7 +564,8 @@ private static void verifyDesktopFile(JPackageCommand cmd, Optional<AppImageFile
for (var e : List.of(
Map.entry("Type", "Application"),
Map.entry("Terminal", "false"),
Map.entry("Comment", launcherDescription)
Map.entry("Comment", launcherDescription),
Map.entry("Categories", Optional.ofNullable(cmd.getArgumentValue("--linux-menu-group")).orElse("Utility"))
)) {
String key = e.getKey();
TKit.assertEquals(e.getValue(), data.find(key).orElseThrow(), String.format(
Expand Down
24 changes: 20 additions & 4 deletions test/jdk/tools/jpackage/linux/ShortcutHintTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,15 @@
import java.nio.file.Path;
import java.util.List;
import jdk.jpackage.test.AdditionalLauncher;
import jdk.jpackage.test.Annotations.Parameter;
import jdk.jpackage.test.Annotations.Test;
import jdk.jpackage.test.FileAssociations;
import jdk.jpackage.test.PackageType;
import jdk.jpackage.test.PackageTest;
import jdk.jpackage.test.TKit;
import jdk.jpackage.test.JPackageCommand;
import jdk.jpackage.test.LinuxHelper;
import jdk.jpackage.test.Annotations.Test;
import jdk.jpackage.test.PackageTest;
import jdk.jpackage.test.PackageType;
import jdk.jpackage.test.RunnablePackageTest.Action;
import jdk.jpackage.test.TKit;

/**
* Test --linux-shortcut parameter. Output of the test should be
Expand Down Expand Up @@ -179,4 +181,18 @@ public static void testDesktopFileFromResourceDir() throws IOException {
.apply(Files.readAllLines(desktopFile));
}).run();
}

/**
* Test "--linux-menu-group" option.
*
* @param menuGroup value of "--linux-menu-group" option
*/
@Test
// Values from https://specifications.freedesktop.org/menu/latest/category-registry.html#main-category-registry
@Parameter("Development")
public static void testMenuGroup(String menuGroup) {
createTest().addInitializer(JPackageCommand::setFakeRuntime).addInitializer(cmd -> {
cmd.addArgument("--linux-shortcut").setArgumentValue("--linux-menu-group", menuGroup);
}).run(Action.CREATE_AND_UNPACK);
}
}