Skip to content

Commit 6a4b622

Browse files
committed
8286122: [macos]: App bundle cannot upload to Mac App Store due to info.plist embedded in java exe
Reviewed-by: mbaesken Backport-of: b523c88480ba5c8f9d78537c9de0abcbf1f867c0
1 parent c3aa29f commit 6a4b622

File tree

7 files changed

+329
-4
lines changed

7 files changed

+329
-4
lines changed

src/jdk.jpackage/share/classes/jdk/jpackage/internal/DeployParams.java

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2011, 2021, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2011, 2022, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -38,7 +38,6 @@
3838
import java.util.Set;
3939
import java.util.TreeMap;
4040
import java.util.TreeSet;
41-
import java.util.stream.Collectors;
4241
import java.util.stream.Stream;
4342

4443
/**
@@ -146,6 +145,7 @@ static void validateName(String s, boolean forApp)
146145
}
147146
}
148147

148+
@SuppressWarnings("unchecked")
149149
public void validate() throws PackagerException {
150150
boolean hasModule = (bundlerArguments.get(
151151
Arguments.CLIOptions.MODULE.getId()) != null);
@@ -161,6 +161,8 @@ public void validate() throws PackagerException {
161161
Arguments.CLIOptions.INPUT.getId()) != null);
162162
boolean hasModulePath = (bundlerArguments.get(
163163
Arguments.CLIOptions.MODULE_PATH.getId()) != null);
164+
boolean hasMacAppStore = (bundlerArguments.get(
165+
Arguments.CLIOptions.MAC_APP_STORE.getId()) != null);
164166
boolean runtimeInstaller = !isTargetAppImage() &&
165167
!hasAppImage && !hasModule && !hasMain && hasRuntimeImage;
166168

@@ -273,6 +275,45 @@ public void validate() throws PackagerException {
273275
Path.of(icon).toAbsolutePath().toString());
274276
}
275277
}
278+
279+
280+
if (hasMacAppStore) {
281+
// Validate jlink-options if mac-app-store is set
282+
Object jlinkOptions = bundlerArguments.get(
283+
Arguments.CLIOptions.JLINK_OPTIONS.getId());
284+
if (jlinkOptions instanceof List) {
285+
List<String> options = (List<String>) jlinkOptions;
286+
if (!options.contains("--strip-native-commands")) {
287+
throw new PackagerException(
288+
"ERR_MissingJLinkOptMacAppStore",
289+
"--strip-native-commands");
290+
}
291+
}
292+
293+
// Validate runtime if mac-app-store is set. Predefined runtime
294+
// should not contain "bin" folder.
295+
runtime = (String)bundlerArguments.get(
296+
Arguments.CLIOptions.PREDEFINED_RUNTIME_IMAGE.getId());
297+
if (runtime != null) {
298+
// Should exist from check above if not null
299+
Path topImage = Path.of(runtime);
300+
301+
// On Mac topImage can be runtime root or runtime home.
302+
Path runtimeHome = topImage.resolve("Contents/Home");
303+
if (Files.isDirectory(runtimeHome)) {
304+
// topImage references runtime root, adjust it to pick data
305+
// from runtime home
306+
topImage = runtimeHome;
307+
}
308+
309+
Path runtimeBin = topImage.resolve("bin");
310+
if (Files.isDirectory(runtimeBin)) {
311+
throw new PackagerException(
312+
"ERR_MacAppStoreRuntimeBinExists",
313+
topImage.toAbsolutePath().toString());
314+
}
315+
}
316+
}
276317
}
277318

278319
void setTargetFormat(String t) {

src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/MainResources.properties

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,3 +109,5 @@ ERR_NoEntryPoint=Error: creating application image requires --main-jar or --modu
109109
ERR_InputNotDirectory=Error: Input directory specified is not a directory: {0}
110110
ERR_CannotReadInputDir=Error: No permission to read from input directory: {0}
111111
ERR_CannotParseOptions=Error: Processing @filename option: {0}
112+
ERR_MissingJLinkOptMacAppStore=Error: --mac-app-store argument requires a {0} option for --jlink-options argument
113+
ERR_MacAppStoreRuntimeBinExists=Error: Runtime image "{0}" should not contain "bin" folder. Use --strip-native-commands jlink option when generating runtime image used with --mac-app-store argument.
Lines changed: 112 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,112 @@
1+
#
2+
# Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
3+
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
#
5+
# This code is free software; you can redistribute it and/or modify it
6+
# under the terms of the GNU General Public License version 2 only, as
7+
# published by the Free Software Foundation. Oracle designates this
8+
# particular file as subject to the "Classpath" exception as provided
9+
# by Oracle in the LICENSE file that accompanied this code.
10+
#
11+
# This code is distributed in the hope that it will be useful, but WITHOUT
12+
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13+
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
14+
# version 2 for more details (a copy is included in the LICENSE file that
15+
# accompanied this code).
16+
#
17+
# You should have received a copy of the GNU General Public License version
18+
# 2 along with this work; if not, write to the Free Software Foundation,
19+
# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
20+
#
21+
# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
22+
# or visit www.oracle.com if you need additional information or have any
23+
# questions.
24+
#
25+
#
26+
27+
param.copyright.default=Copyright (C) {0,date,YYYY}
28+
param.description.default=Kein Wert
29+
param.vendor.default=Unbekannt
30+
31+
message.using-default-resource=Standardpackageressource {0} {1} wird verwendet (durch Hinzuf\u00FCgen von {2} zu resource-dir ist eine Anpassung m\u00F6glich).
32+
message.no-default-resource=Keine Standardpackageressource {0} {1} (durch Hinzuf\u00FCgen von {2} zu resource-dir ist eine Anpassung m\u00F6glich).
33+
message.using-custom-resource-from-file=Benutzerdefinierte Packageressource {0} wird verwendet (aus Datei {1} geladen).
34+
message.using-custom-resource=Benutzerdefinierte Packageressource {0} wird verwendet (aus {1} geladen).
35+
message.creating-app-bundle=Anwendungspackage {0} wird in {1} erstellt
36+
message.app-image-dir-does-not-exist=Angegebenes Anwendungsimageverzeichnis {0}: {1} ist nicht vorhanden
37+
message.app-image-dir-does-not-exist.advice=Best\u00E4tigen Sie, dass der Wert f\u00FCr {0} vorhanden ist
38+
message.runtime-image-dir-does-not-exist=Angegebenes Laufzeitimageverzeichnis {0}: {1} ist nicht vorhanden
39+
message.runtime-image-dir-does-not-exist.advice=Best\u00E4tigen Sie, dass der Wert f\u00FCr {0} vorhanden ist
40+
message.resource-dir-does-not-exist=Angegebenes Ressourcenverzeichnis {0}: {1} ist nicht vorhanden
41+
message.debug-working-directory=Arbeitsverzeichnis f\u00FCr Debug beibehalten: {0}
42+
message.bundle-created={0}-Package wurde erfolgreich erstellt
43+
message.module-version=Version "{0}" aus Modul "{1}" wird als Anwendungsversion verwendet
44+
message.module-class=Klasse "{0}" aus Modul "{1}" wird als Anwendungshauptklasse verwendet
45+
46+
error.version-string-empty="Version darf keine leere Zeichenfolge sein"
47+
error.version-string-zero-length-component="Version [{0}] enth\u00E4lt eine Komponente mit einer Nulll\u00E4nge"
48+
error.version-string-invalid-component="Version [{0}] enth\u00E4lt ung\u00FCltige Komponente [{1}]"
49+
50+
error.cannot-create-output-dir=Zielverzeichnis {0} kann nicht erstellt werden
51+
error.cannot-write-to-output-dir=Zielverzeichnis {0} ist schreibgesch\u00FCtzt
52+
error.root-exists=Fehler: Anwendungszielverzeichnis {0} ist bereits vorhanden
53+
error.no-main-class-with-main-jar=Es wurde keine Hauptklasse angegeben oder in der JAR-Datei {0} gefunden
54+
error.no-main-class-with-main-jar.advice=Geben Sie eine Hauptklasse an, oder stellen Sie sicher, dass die JAR-Datei {0} eine Hauptklasse im Manifest angibt
55+
error.no-main-class=Es wurde keine Hauptklasse angegeben oder in den angegebenen Anwendungsressourcen gefunden
56+
error.no-main-class.advice=Geben Sie eine Anwendungsklasse an, oder stellen Sie sicher, dass die appResources eine JAR-Datei mit einer Anwendungsklasse im Manifest enthalten
57+
error.main-jar-does-not-exist=Die konfigurierte Haupt-JAR-Datei ist im Eingabeverzeichnis nicht vorhanden {0}
58+
error.main-jar-does-not-exist.advice=Die Haupt-JAR-Datei muss relativ zum Eingabeverzeichnis (nicht als absoluter Pfad) angegeben werden und muss in diesem Verzeichnis vorhanden sein
59+
error.no-module-in-path="{0}-Modul im Modulpfad nicht gefunden"
60+
error.not-path-parameter="Ung\u00FCltiger Wert f\u00FCr Parameter {0}: {1}"
61+
error.no-input-parameter="--input-Parameter f\u00FCr nicht modulare Anwendung fehlt"
62+
error.no-main-jar-parameter="--main-jar-Parameter f\u00FCr nicht modulare Anwendung fehlt"
63+
64+
error.no-content-types-for-file-association=F\u00FCr Dateiverkn\u00FCpfungsnummer {0} wurden keine MIME-Typen angegeben
65+
error.no-content-types-for-file-association.advice=Geben Sie einen MIME-Typ f\u00FCr Dateiverkn\u00FCpfungsnummer {0} an
66+
error.too-many-content-types-for-file-association=F\u00FCr Dateiverkn\u00FCpfungsnummer {0} wurde mehr als ein MIME-Typ angegeben
67+
error.too-many-content-types-for-file-association.advice=Geben Sie nur einen MIME-Typ f\u00FCr Dateiverkn\u00FCpfungsnummer {0} an
68+
69+
error.tool-not-found={0} kann nicht gefunden werden. Grund: {1}
70+
error.tool-not-found.advice=Installieren Sie {0}
71+
error.tool-old-version={0} {1} oder eine neuere Version kann nicht gefunden werden
72+
error.tool-old-version.advice=Installieren Sie {0} {1} oder eine neuere Version
73+
error.jlink.failed=jlink nicht erfolgreich mit: {0}
74+
error.blocked.option=jlink-Option [{0}] ist in --jlink-options nicht zul\u00E4ssig
75+
error.no.name=Name nicht mit --name angegeben. Es kann auch kein Name aus app-image abgeleitet werden
76+
77+
warning.no.jdk.modules.found=Warnung: Keine JDK-Module gefunden
78+
warning.foreign-app-image=Warnung: app-image-Verzeichnis ({0}) wurde von jpackage nicht generiert.
79+
warning.invalid-app-image=Warnung: .jpackage.xml kann in app-image-Verzeichnis ({0}) nicht geparst werden
80+
81+
MSG_BundlerFailed=Fehler: Bundler "{1}" ({0}) konnte kein Package generieren
82+
MSG_BundlerConfigException=Bundler {0} aufgrund eines Konfigurationsproblems \u00FCbersprungen: {1} \nEmpfehlung zur Behebung: {2}
83+
MSG_BundlerConfigExceptionNoAdvice=Bundler {0} aufgrund eines Konfigurationsproblems \u00FCbersprungen: {1}
84+
MSG_BundlerRuntimeException=Bundler {0} nicht erfolgreich. Grund: {1}
85+
MSG_BundlerFailed=Fehler: Bundler "{1}" ({0}) konnte kein Package generieren
86+
87+
ERR_NoMainClass=Fehler: Hauptanwendungsklasse fehlt
88+
ERR_UnsupportedOption=Fehler: Option [{0}] ist auf dieser Plattform ung\u00FCltig
89+
ERR_InvalidTypeOption=Fehler: Option [{0}] ist nicht g\u00FCltig mit Typ [{1}]
90+
ERR_NoInstallerEntryPoint=Fehler: Option [{0}] ist nicht g\u00FCltig ohne Einstiegspunktoption --module oder --main-jar
91+
ERR_MutuallyExclusiveOptions="Fehler: Optionen [{0}] und [{1}] schlie\u00DFen sich gegenseitig aus
92+
93+
ERR_MissingArgument=Fehler: Fehlendes Argument: {0}
94+
ERR_MissingAppResources=Fehler: Keine Anwendungs-JAR-Dateien gefunden
95+
ERR_AppImageNotExist=Fehler: Anwendungsimageverzeichnis "{0}" ist nicht vorhanden
96+
ERR_NoAddLauncherName=Fehler: F\u00FCr Option --add-launcher m\u00FCssen ein Name und ein Dateipfad angegeben werden (--add-launcher <Name>=<Dateipfad>)
97+
ERR_NoUniqueName=Fehler: F\u00FCr --add-launcher <Name>=<Dateipfad> ist ein eindeutiger Name erforderlich
98+
ERR_NoJreInstallerName=Fehler: F\u00FCr JRE-Installationsprogramme ist ein Namensparameter erforderlich
99+
ERR_InvalidAppName=Fehler: Ung\u00FCltiger Anwendungsname: {0}
100+
ERR_InvalidSLName=Fehler: Ung\u00FCltiger Name f\u00FCr hinzuzuf\u00FCgenden Launcher: {0}
101+
ERR_IconFileNotExit=Fehler: Die angegebene Symboldatei [{0}] ist nicht vorhanden
102+
ERR_LicenseFileNotExit=Fehler: Die angegebene Lizenzdatei ist nicht vorhanden
103+
ERR_BuildRootInvalid=Fehler: Das tempor\u00E4re Verzeichnis ({0}) darf nicht vorhanden oder muss leer sein
104+
ERR_InvalidOption=Fehler: Ung\u00FCltige Option: [{0}]
105+
ERR_InvalidInstallerType=Fehler: Ung\u00FCltiger oder nicht unterst\u00FCtzter Typ: [{0}]
106+
ERR_BothMainJarAndModule=Fehler: Die Optionen --main-jar und --module d\u00FCrfen nicht beide vorhanden sein
107+
ERR_NoEntryPoint=Fehler: F\u00FCr das Erstellen des Anwendungsimages muss entweder die Option --main-jar oder die Option --module angegeben werden
108+
ERR_InputNotDirectory=Fehler: Das angegebene Eingabeverzeichnis ist kein Verzeichnis: {0}
109+
ERR_CannotReadInputDir=Fehler: Keine Berechtigung zum Lesen aus Eingabeverzeichnis vorhanden: {0}
110+
ERR_CannotParseOptions=Fehler: Option @filename wird verarbeitet: {0}
111+
ERR_MissingJLinkOptMacAppStore=Error: --mac-app-store argument requires a {0} option for --jlink-options argument
112+
ERR_MacAppStoreRuntimeBinExists=Error: Runtime image "{0}" should not contain "bin" folder. Use --strip-native-commands jlink option when generating runtime image used with --mac-app-store argument.

src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/MainResources_ja.properties

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved.
2+
# Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
33
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
#
55
# This code is free software; you can redistribute it and/or modify it
@@ -108,3 +108,5 @@ ERR_NoEntryPoint=\u30A8\u30E9\u30FC: \u30A2\u30D7\u30EA\u30B1\u30FC\u30B7\u30E7\
108108
ERR_InputNotDirectory=\u30A8\u30E9\u30FC: \u6307\u5B9A\u3055\u308C\u305F\u5165\u529B\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u306F\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u3067\u306F\u3042\u308A\u307E\u305B\u3093: {0}
109109
ERR_CannotReadInputDir=\u30A8\u30E9\u30FC: \u5165\u529B\u30C7\u30A3\u30EC\u30AF\u30C8\u30EA\u304B\u3089\u8AAD\u307F\u53D6\u308B\u6A29\u9650\u304C\u3042\u308A\u307E\u305B\u3093: {0}
110110
ERR_CannotParseOptions=\u30A8\u30E9\u30FC: @filename\u30AA\u30D7\u30B7\u30E7\u30F3\u306E\u51E6\u7406: {0}
111+
ERR_MissingJLinkOptMacAppStore=Error: --mac-app-store argument requires a {0} option for --jlink-options argument
112+
ERR_MacAppStoreRuntimeBinExists=Error: Runtime image "{0}" should not contain "bin" folder. Use --strip-native-commands jlink option when generating runtime image used with --mac-app-store argument.

src/jdk.jpackage/share/classes/jdk/jpackage/internal/resources/MainResources_zh_CN.properties

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#
2-
# Copyright (c) 2017, 2021, Oracle and/or its affiliates. All rights reserved.
2+
# Copyright (c) 2017, 2022, Oracle and/or its affiliates. All rights reserved.
33
# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
#
55
# This code is free software; you can redistribute it and/or modify it
@@ -108,3 +108,5 @@ ERR_NoEntryPoint=\u9519\u8BEF\uFF1A\u521B\u5EFA\u5E94\u7528\u7A0B\u5E8F\u6620\u5
108108
ERR_InputNotDirectory=\u9519\u8BEF\uFF1A\u6307\u5B9A\u7684\u8F93\u5165\u76EE\u5F55\u4E0D\u662F\u76EE\u5F55\uFF1A{0}
109109
ERR_CannotReadInputDir=\u9519\u8BEF\uFF1A\u65E0\u6743\u4ECE\u8F93\u5165\u76EE\u5F55\u8BFB\u53D6\uFF1A{0}
110110
ERR_CannotParseOptions=\u9519\u8BEF\uFF1A\u6B63\u5728\u5904\u7406 @filename \u9009\u9879\uFF1A{0}
111+
ERR_MissingJLinkOptMacAppStore=Error: --mac-app-store argument requires a {0} option for --jlink-options argument
112+
ERR_MacAppStoreRuntimeBinExists=Error: Runtime image "{0}" should not contain "bin" folder. Use --strip-native-commands jlink option when generating runtime image used with --mac-app-store argument.
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/*
2+
* Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation.
8+
*
9+
* This code is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
* version 2 for more details (a copy is included in the LICENSE file that
13+
* accompanied this code).
14+
*
15+
* You should have received a copy of the GNU General Public License version
16+
* 2 along with this work; if not, write to the Free Software Foundation,
17+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18+
*
19+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20+
* or visit www.oracle.com if you need additional information or have any
21+
* questions.
22+
*/
23+
24+
import jdk.jpackage.test.JPackageCommand;
25+
import jdk.jpackage.test.Annotations.Test;
26+
27+
/**
28+
* Tests generation of app image with --mac-app-store and --jlink-options. jpackage should able
29+
* to generate app image if "--strip-native-commands" is specified for --jlink-options and should
30+
* fail if it is not specified.
31+
*/
32+
33+
/*
34+
* @test
35+
* @summary jpackage with --mac-app-store and --jlink-options
36+
* @library ../helpers
37+
* @library /test/lib
38+
* @build jdk.jpackage.test.*
39+
* @build MacAppStoreJLinkOptionsTest
40+
* @modules jdk.jpackage/jdk.jpackage.internal
41+
* @requires (os.family == "mac")
42+
* @run main/othervm -Xmx512m jdk.jpackage.test.Main
43+
* --jpt-run=MacAppStoreJLinkOptionsTest
44+
*/
45+
public class MacAppStoreJLinkOptionsTest {
46+
47+
@Test
48+
public static void testWithStripNativeCommands() throws Exception {
49+
JPackageCommand cmd = JPackageCommand.helloAppImage();
50+
cmd.addArguments("--mac-app-store", "--jlink-options",
51+
"--strip-debug --no-man-pages --no-header-files --strip-native-commands");
52+
53+
cmd.executeAndAssertHelloAppImageCreated();
54+
}
55+
56+
@Test
57+
public static void testWithoutStripNativeCommands() throws Exception {
58+
JPackageCommand cmd = JPackageCommand.helloAppImage();
59+
cmd.addArguments("--mac-app-store", "--jlink-options",
60+
"--strip-debug --no-man-pages --no-header-files");
61+
62+
cmd.execute(1);
63+
}
64+
}

0 commit comments

Comments
 (0)