Browse Source

Add icons support to packaging

pull/28/head
Alexey Tsvetkov 4 years ago committed by Alexey Tsvetkov
parent
commit
927abf0d03
  1. BIN
      examples/imageviewer/common/src/desktopMain/resources/images/icon-linux.png
  2. BIN
      examples/imageviewer/common/src/desktopMain/resources/images/icon-mac.icns
  3. BIN
      examples/imageviewer/common/src/desktopMain/resources/images/icon-windows.ico
  4. 11
      examples/imageviewer/desktop/build.gradle.kts
  5. 7
      gradle-plugins/compose-desktop-application/src/main/kotlin/org/jetbrains/compose/desktop/application/ApplicationPlugin.kt
  6. 14
      gradle-plugins/compose-desktop-application/src/main/kotlin/org/jetbrains/compose/desktop/application/dsl/PlatformSettings.kt

BIN
examples/imageviewer/common/src/desktopMain/resources/images/icon-linux.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

BIN
examples/imageviewer/common/src/desktopMain/resources/images/icon-mac.icns

Binary file not shown.

BIN
examples/imageviewer/common/src/desktopMain/resources/images/icon-windows.ico

Binary file not shown.

After

Width:  |  Height:  |  Size: 66 KiB

11
examples/imageviewer/desktop/build.gradle.kts

@ -29,6 +29,17 @@ compose.desktop {
targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb) targetFormats(TargetFormat.Dmg, TargetFormat.Msi, TargetFormat.Deb)
packageName = "ImageViewer" packageName = "ImageViewer"
modules("jdk.crypto.ec") modules("jdk.crypto.ec")
val iconsRoot = project.file("../common/src/desktopMain/resources/images")
macOS {
iconFile.set(iconsRoot.resolve("icon-mac.icns"))
}
windows {
iconFile.set(iconsRoot.resolve("icon-windows.ico"))
}
linux {
iconFile.set(iconsRoot.resolve("icon-linux.png"))
}
} }
} }
} }

7
gradle-plugins/compose-desktop-application/src/main/kotlin/org/jetbrains/compose/desktop/application/ApplicationPlugin.kt

@ -25,7 +25,6 @@ private const val PLUGIN_ID = "org.jetbrains.compose.desktop.application"
// todo: fix windows // todo: fix windows
// todo: multiple launchers // todo: multiple launchers
// todo: file associations // todo: file associations
// todo: icon
// todo: use workers // todo: use workers
@Suppress("unused") // Gradle plugin entry point @Suppress("unused") // Gradle plugin entry point
open class ApplicationPlugin : Plugin<Project> { open class ApplicationPlugin : Plugin<Project> {
@ -100,6 +99,7 @@ internal fun AbstractJPackageTask.configurePackagingTask(app: Application) {
linuxMenuGroup.set(provider { linux.menuGroup }) linuxMenuGroup.set(provider { linux.menuGroup })
linuxPackageName.set(provider { linux.packageName }) linuxPackageName.set(provider { linux.packageName })
linuxRpmLicenseType.set(provider { linux.rpmLicenseType }) linuxRpmLicenseType.set(provider { linux.rpmLicenseType })
iconFile.set(linux.iconFile)
} }
} }
OS.Windows -> { OS.Windows -> {
@ -111,6 +111,7 @@ internal fun AbstractJPackageTask.configurePackagingTask(app: Application) {
winMenu.set(provider { win.menu }) winMenu.set(provider { win.menu })
winMenuGroup.set(provider { win.menuGroup }) winMenuGroup.set(provider { win.menuGroup })
winUpgradeUuid.set(provider { win.upgradeUuid }) winUpgradeUuid.set(provider { win.upgradeUuid })
iconFile.set(win.iconFile)
} }
} }
OS.MacOS -> { OS.MacOS -> {
@ -121,6 +122,7 @@ internal fun AbstractJPackageTask.configurePackagingTask(app: Application) {
macSigningKeyUserName.set(provider { mac.signing.keyUserName }) macSigningKeyUserName.set(provider { mac.signing.keyUserName })
macSigningKeychain.set(project.layout.file(provider { mac.signing.keychain })) macSigningKeychain.set(project.layout.file(provider { mac.signing.keychain }))
macBundleSigningPrefix.set(provider { mac.signing.bundlePrefix }) macBundleSigningPrefix.set(provider { mac.signing.bundlePrefix })
iconFile.set(mac.iconFile)
} }
} }
} }
@ -131,8 +133,7 @@ internal fun AbstractJPackageTask.configurePackagingTask(app: Application) {
packageCopyright.set(provider { executables.copyright }) packageCopyright.set(provider { executables.copyright })
packageVendor.set(provider { executables.vendor }) packageVendor.set(provider { executables.vendor })
packageVersion.set(provider { packageVersion.set(provider {
targetPlatformSettings.version executables.version
?: executables.version
?: project.version.toString().takeIf { it != "unspecified" } ?: project.version.toString().takeIf { it != "unspecified" }
}) })
} }

14
gradle-plugins/compose-desktop-application/src/main/kotlin/org/jetbrains/compose/desktop/application/dsl/PlatformSettings.kt

@ -1,14 +1,16 @@
package org.jetbrains.compose.desktop.application.dsl package org.jetbrains.compose.desktop.application.dsl
import org.gradle.api.Action import org.gradle.api.Action
import org.gradle.api.file.RegularFileProperty
import org.gradle.api.model.ObjectFactory
import java.io.File import java.io.File
import javax.inject.Inject
abstract class PlatformSettings { abstract class PlatformSettings (objects: ObjectFactory) {
var version: String? = null val iconFile: RegularFileProperty = objects.fileProperty()
var installDir: String? = null
} }
open class MacOSPlatformSettings : PlatformSettings() { open class MacOSPlatformSettings @Inject constructor(objects: ObjectFactory): PlatformSettings(objects) {
var packageIdentifier: String? = null var packageIdentifier: String? = null
var packageName: String? = null var packageName: String? = null
val signing: MacOSSigningSettings = MacOSSigningSettings() val signing: MacOSSigningSettings = MacOSSigningSettings()
@ -31,7 +33,7 @@ open class MacOSSigningSettings {
var keyUserName: String? = null var keyUserName: String? = null
} }
open class LinuxPlatformSettings : PlatformSettings() { open class LinuxPlatformSettings @Inject constructor(objects: ObjectFactory): PlatformSettings(objects) {
var shortcut: Boolean = false var shortcut: Boolean = false
var packageName: String? = null var packageName: String? = null
var appRelease: String? = null var appRelease: String? = null
@ -41,7 +43,7 @@ open class LinuxPlatformSettings : PlatformSettings() {
var rpmLicenseType: String? = null var rpmLicenseType: String? = null
} }
open class WindowsPlatformSettings : PlatformSettings() { open class WindowsPlatformSettings @Inject constructor(objects: ObjectFactory): PlatformSettings(objects) {
var console: Boolean = false var console: Boolean = false
var dirChooser: Boolean = false var dirChooser: Boolean = false
var perUserInstall: Boolean = false var perUserInstall: Boolean = false

Loading…
Cancel
Save