Skip to content

Commit 30fdb20

Browse files
Non-compliant fixes to keep old jpackage behavior
1 parent a451b12 commit 30fdb20

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/MacApplicationBuilder.java

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -165,14 +165,16 @@ private Optional<AppImageSigningConfig> createSigningConfig() throws ConfigExcep
165165
private String validatedBundleName() throws ConfigException {
166166
final var value = Optional.ofNullable(bundleName).orElseGet(() -> {
167167
final var appName = app.name();
168-
if (appName.length() > MAX_BUNDLE_NAME_LENGTH) {
169-
return appName.substring(0, MAX_BUNDLE_NAME_LENGTH);
170-
} else {
171-
return appName;
172-
}
168+
// Commented out for backward compatibility
169+
// if (appName.length() > MAX_BUNDLE_NAME_LENGTH) {
170+
// return appName.substring(0, MAX_BUNDLE_NAME_LENGTH);
171+
// } else {
172+
// return appName;
173+
// }
174+
return appName;
173175
});
174176

175-
if (value.length() > MAX_BUNDLE_NAME_LENGTH) {
177+
if (value.length() > MAX_BUNDLE_NAME_LENGTH && (bundleName != null)) {
176178
Log.error(I18N.format("message.bundle-name-too-long-warning", "--mac-package-name", value));
177179
}
178180

@@ -204,7 +206,7 @@ private String validatedBundleIdentifier() throws ConfigException {
204206
}
205207

206208
private String validatedCategory() throws ConfigException {
207-
return Optional.ofNullable(category).orElseGet(DEFAULTS::category);
209+
return "public.app-category." + Optional.ofNullable(category).orElseGet(DEFAULTS::category);
208210
}
209211

210212
private Optional<Path> validatedIcon() throws ConfigException {

src/jdk.jpackage/macosx/classes/jdk/jpackage/internal/model/MacApplication.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,13 @@
3737
public interface MacApplication extends Application, MacApplicationMixin {
3838

3939
default DottedVersion shortVersion() {
40-
var verComponents = DottedVersion.lazy(version()).getComponents();
41-
return DottedVersion.greedy(IntStream.range(0, 3).mapToObj(idx -> {
40+
final var verComponents = DottedVersion.lazy(version()).getComponents();
41+
// Short version should have exactly three components according to
42+
// https://developer.apple.com/documentation/bundleresources/information-property-list/cfbundleshortversionstring
43+
int maxComponentCount = 3;
44+
// However, if the number of components is less than three, historically, jpackage will not add missing components.
45+
maxComponentCount = Integer.min(maxComponentCount, verComponents.length);
46+
return DottedVersion.greedy(IntStream.range(0, maxComponentCount).mapToObj(idx -> {
4247
if (idx < verComponents.length) {
4348
return verComponents[idx].toString();
4449
} else {

0 commit comments

Comments
 (0)