-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Customize Info.plist before jpackage
Resolves #679
- Loading branch information
1 parent
63beaea
commit 1040af3
Showing
5 changed files
with
153 additions
and
43 deletions.
There are no files selected for viewing
59 changes: 59 additions & 0 deletions
59
...se/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/InfoPlistBuilder.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
/* | ||
* Copyright 2020-2021 JetBrains s.r.o. and respective authors and developers. | ||
* Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE.txt file. | ||
*/ | ||
|
||
package org.jetbrains.compose.desktop.application.internal | ||
|
||
import java.io.File | ||
import kotlin.reflect.KProperty | ||
|
||
internal class InfoPlistBuilder { | ||
private val values = LinkedHashMap<InfoPlistKey, String>() | ||
|
||
operator fun get(key: InfoPlistKey): String? = values[key] | ||
operator fun set(key: InfoPlistKey, value: String) { | ||
values[key] = value | ||
} | ||
|
||
fun writeToFile(file: File) { | ||
file.writer().buffered().use { writer -> | ||
writer.run { | ||
appendLine("<?xml version=\"1.0\" ?>") | ||
appendLine("<!DOCTYPE plist PUBLIC \"-//Apple//DTD PLIST 1.0//EN\" \"https://www.apple.com/DTDs/PropertyList-1.0.dtd\">") | ||
appendLine("<plist version=\"1.0\">") | ||
appendLine(" <dict>") | ||
for ((k, v) in values) { | ||
appendLine(" <key>${k.name}</key>") | ||
appendLine(" <string>$v</string>") | ||
} | ||
appendLine(" </dict>") | ||
appendLine("</plist>") | ||
} | ||
} | ||
} | ||
} | ||
|
||
internal data class InfoPlistKey(val name: String) | ||
|
||
internal object PlistKeys { | ||
private operator fun getValue(thisRef: PlistKeys, property: KProperty<*>): InfoPlistKey = | ||
InfoPlistKey(property.name) | ||
|
||
val LSMinimumSystemVersion by this | ||
val CFBundleDevelopmentRegion by this | ||
val CFBundleAllowMixedLocalizations by this | ||
val CFBundleExecutable by this | ||
val CFBundleIconFile by this | ||
val CFBundleIdentifier by this | ||
val CFBundleInfoDictionaryVersion by this | ||
val CFBundleName by this | ||
val CFBundlePackageType by this | ||
val CFBundleShortVersionString by this | ||
val CFBundleSignature by this | ||
val LSApplicationCategoryType by this | ||
val CFBundleVersion by this | ||
val NSHumanReadableCopyright by this | ||
val NSSupportsAutomaticGraphicsSwitching by this | ||
val NSHighResolutionCapable by this | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
gradle-plugins/compose/src/test/test-projects/application/macOptions/Expected-Info.plist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?xml version="1.0" ?> | ||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "https://www.apple.com/DTDs/PropertyList-1.0.dtd"> | ||
<plist version="1.0"> | ||
<dict> | ||
<key>LSMinimumSystemVersion</key> | ||
<string>10.13</string> | ||
<key>CFBundleDevelopmentRegion</key> | ||
<string>English</string> | ||
<key>CFBundleAllowMixedLocalizations</key> | ||
<string>true</string> | ||
<key>CFBundleExecutable</key> | ||
<string>TestPackage</string> | ||
<key>CFBundleIconFile</key> | ||
<string>TestPackage.icns</string> | ||
<key>CFBundleIdentifier</key> | ||
<string>MainKt</string> | ||
<key>CFBundleInfoDictionaryVersion</key> | ||
<string>6.0</string> | ||
<key>CFBundleName</key> | ||
<string>TestPackage</string> | ||
<key>CFBundlePackageType</key> | ||
<string>APPL</string> | ||
<key>CFBundleShortVersionString</key> | ||
<string>1.0.0</string> | ||
<key>LSApplicationCategoryType</key> | ||
<string>Unknown</string> | ||
<key>CFBundleVersion</key> | ||
<string>1.0.0</string> | ||
<key>NSHumanReadableCopyright</key> | ||
<string>Copyright (C) CURRENT_YEAR</string> | ||
<key>NSSupportsAutomaticGraphicsSwitching</key> | ||
<string>true</string> | ||
<key>NSHighResolutionCapable</key> | ||
<string>true</string> | ||
</dict> | ||
</plist> |