On Tue, 25 Nov 2025 19:00:33 GMT, Alexander Matveev <[email protected]> 
wrote:

>> test/jdk/tools/jpackage/share/ServiceTest.java line 229:
>> 
>>> 227:             
>>> appImageCmd.cmd().orElseThrow().addArgument("--mac-app-store");
>>> 228:         }
>>> 229: 
>> 
>> Why do we need this option for an app image?
>
> Without it jpackage will add launchers as a service even if `--mac-app-store` 
> is specified for PKG. I do not think it is a bug. jpackage takes 
> `--mac-app-store` value from predefined app image. Specifying it when 
> generating PKG at line 265 is not needed and was added to make 
> `cmd.hasArgument("--mac-app-store")` work. Maybe we need another approach and 
> add isMacAppStore() function somewhere which will check predefined app image 
> or `cmd.hasArgument("--mac-app-store")` to figure out if we generating for 
> Mac App Store.

Ah, right. We store the value of the `--mac-app-store` option in the app image 
file. Then `LauncherAsServiceVerifier.launcherAsService()` should be as follows:


diff --git 
a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/LauncherAsServiceVerifier.java
 
b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/LauncherAsServiceVerifier.java
index 0be6cf685f6..a0c7164f5a4 100644
--- 
a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/LauncherAsServiceVerifier.java
+++ 
b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/LauncherAsServiceVerifier.java
@@ -239,7 +239,9 @@ private static Map<Boolean, List<String>> 
partitionLaunchers(JPackageCommand cmd
     }

     static boolean launcherAsService(JPackageCommand cmd, String launcherName) 
{
-        if (cmd.isMainLauncher(launcherName)) {
+        if (MacHelper.isForAppStore(cmd)) {
+            return false;
+        } else if (cmd.isMainLauncher(launcherName)) {
             return PropertyFinder.findLauncherProperty(cmd, null,
                     
PropertyFinder.cmdlineBooleanOption("--launcher-as-service"),
                     PropertyFinder.nop(),


This will eliminate the need for cmd.hasArgument("--mac-app-store") in the PKG 
bundling command line.

> Maybe we need another approach and add isMacAppStore() function somewhere 
> which will check predefined app image or cmd.hasArgument("--mac-app-store") 
> to figure out if we generating for Mac App Store.


diff --git a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/MacHelper.java 
b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/MacHelper.java
index a6d24af2b25..f7b124db1db 100644
--- a/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/MacHelper.java
+++ b/test/jdk/tools/jpackage/helpers/jdk/jpackage/test/MacHelper.java
@@ -797,6 +797,15 @@ private static String getPackageId(JPackageCommand cmd) {
         ).orElseGet(cmd::name);
     }

+    static boolean isForAppStore(JPackageCommand cmd) {
+        return PropertyFinder.findAppProperty(cmd,
+                PropertyFinder.cmdlineBooleanOption("--mac-app-image"),
+                PropertyFinder.appImageFile(appImageFile -> {
+                    return Boolean.toString(appImageFile.macAppStore());
+                })
+        ).map(Boolean::parseBoolean).orElse(false);
+    }
+
     public static boolean isXcodeDevToolsInstalled() {
         return Inner.XCODE_DEV_TOOLS_INSTALLED;
     }

-------------

PR Review Comment: https://git.openjdk.org/jdk/pull/28487#discussion_r2561194108

Reply via email to