Skip to content

Commit a451b12

Browse files
Don't add redundant elements to Info.plist when file associations are not specified
1 parent fd08005 commit a451b12

File tree

1 file changed

+18
-12
lines changed

1 file changed

+18
-12
lines changed

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

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -338,25 +338,31 @@ private static void sign(AppImageBuildEnv<MacApplication, MacApplicationLayout>
338338

339339
private static void writeCFBundleDocumentTypes(XMLStreamWriter xml,
340340
MacApplication app) throws XMLStreamException, IOException {
341-
writeKey(xml, "CFBundleDocumentTypes");
342-
for (var fa : app.fileAssociations().toList()) {
343-
writeArray(xml, toXmlConsumer(() -> {
344-
writeDict(xml, toXmlConsumer(() -> {
345-
addFaToCFBundleDocumentTypes(xml, app, (MacFileAssociation) fa);
341+
final var fas = app.fileAssociations().toList();
342+
if (!fas.isEmpty()) {
343+
writeKey(xml, "CFBundleDocumentTypes");
344+
for (var fa : fas) {
345+
writeArray(xml, toXmlConsumer(() -> {
346+
writeDict(xml, toXmlConsumer(() -> {
347+
addFaToCFBundleDocumentTypes(xml, app, (MacFileAssociation) fa);
348+
}));
346349
}));
347-
}));
350+
}
348351
}
349352
}
350353

351354
private static void writeUTExportedTypeDeclarations(XMLStreamWriter xml,
352355
MacApplication app) throws XMLStreamException, IOException {
353-
writeKey(xml, "UTExportedTypeDeclarations");
354-
for (var fa : app.fileAssociations().toList()) {
355-
writeArray(xml, toXmlConsumer(() -> {
356-
writeDict(xml, toXmlConsumer(() -> {
357-
addFaToUTExportedTypeDeclarations(xml, app, (MacFileAssociation) fa);
356+
final var fas = app.fileAssociations().toList();
357+
if (!fas.isEmpty()) {
358+
writeKey(xml, "UTExportedTypeDeclarations");
359+
for (var fa : fas) {
360+
writeArray(xml, toXmlConsumer(() -> {
361+
writeDict(xml, toXmlConsumer(() -> {
362+
addFaToUTExportedTypeDeclarations(xml, app, (MacFileAssociation) fa);
363+
}));
358364
}));
359-
}));
365+
}
360366
}
361367
}
362368

0 commit comments

Comments
 (0)