mirror of
https://github.com/jlengrand/compose-multiplatform.git
synced 2026-03-10 15:48:51 +00:00
committed by
Alexey Tsvetkov
parent
2f7f05babd
commit
0314bc4b80
@@ -0,0 +1,38 @@
|
||||
package org.jetbrains.compose.desktop.application.internal
|
||||
|
||||
import org.gradle.api.Project
|
||||
import org.gradle.api.file.RegularFile
|
||||
import org.gradle.api.provider.Provider
|
||||
import org.jetbrains.compose.ComposeBuildConfig
|
||||
|
||||
internal object DefaultIcons {
|
||||
fun forLinux(project: Project): Provider<RegularFile> =
|
||||
unpackIconIfNeeded(project, platformName = "linux", iconExt = "png")
|
||||
|
||||
fun forWindows(project: Project): Provider<RegularFile> =
|
||||
unpackIconIfNeeded(project, platformName = "windows", iconExt = "ico")
|
||||
|
||||
fun forMac(project: Project): Provider<RegularFile> =
|
||||
unpackIconIfNeeded(project, platformName = "mac", iconExt = "icns")
|
||||
|
||||
private fun unpackIconIfNeeded(project: Project, platformName: String, iconExt: String): Provider<RegularFile> {
|
||||
val iconsDir = project.layout.buildDirectory.dir("compose/default-icons/${ComposeBuildConfig.composeVersion}")
|
||||
val targetFile = iconsDir.map { it.file("icon-$platformName.$iconExt") }
|
||||
val targetIoFile = targetFile.ioFile
|
||||
val sourceIconName = "default-compose-desktop-icon-$platformName.$iconExt"
|
||||
|
||||
if (targetIoFile.exists()) return targetFile
|
||||
|
||||
val iconResourceStream = DefaultIcons.javaClass.classLoader.getResourceAsStream(sourceIconName)
|
||||
?: error("Could not find default icon resource: $sourceIconName")
|
||||
iconResourceStream.use { input ->
|
||||
targetIoFile.parentFile.mkdirs()
|
||||
targetIoFile.createNewFile()
|
||||
targetIoFile.outputStream().buffered().use { output ->
|
||||
input.copyTo(output)
|
||||
}
|
||||
}
|
||||
|
||||
return targetFile
|
||||
}
|
||||
}
|
||||
@@ -213,7 +213,7 @@ internal fun AbstractJPackageTask.configurePlatformSettings(app: Application) {
|
||||
linuxMenuGroup.set(provider { linux.menuGroup })
|
||||
linuxPackageName.set(provider { linux.packageName })
|
||||
linuxRpmLicenseType.set(provider { linux.rpmLicenseType })
|
||||
iconFile.set(linux.iconFile)
|
||||
iconFile.set(linux.iconFile.orElse(DefaultIcons.forLinux(project)))
|
||||
installationPath.set(linux.installationPath)
|
||||
}
|
||||
}
|
||||
@@ -226,7 +226,7 @@ internal fun AbstractJPackageTask.configurePlatformSettings(app: Application) {
|
||||
winMenu.set(provider { win.menu })
|
||||
winMenuGroup.set(provider { win.menuGroup })
|
||||
winUpgradeUuid.set(provider { win.upgradeUuid })
|
||||
iconFile.set(win.iconFile)
|
||||
iconFile.set(win.iconFile.orElse(DefaultIcons.forWindows(project)))
|
||||
installationPath.set(win.installationPath)
|
||||
}
|
||||
}
|
||||
@@ -241,7 +241,7 @@ internal fun AbstractJPackageTask.configurePlatformSettings(app: Application) {
|
||||
)
|
||||
nonValidatedMacBundleID.set(provider { mac.bundleID })
|
||||
nonValidatedMacSigningSettings = app.nativeDistributions.macOS.signing
|
||||
iconFile.set(mac.iconFile)
|
||||
iconFile.set(mac.iconFile.orElse(DefaultIcons.forMac(project)))
|
||||
installationPath.set(mac.installationPath)
|
||||
}
|
||||
}
|
||||
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 181 KiB |
Binary file not shown.
Binary file not shown.
|
After Width: | Height: | Size: 109 KiB |
Reference in New Issue
Block a user