mirror of
https://github.com/jlengrand/compose-multiplatform.git
synced 2026-03-10 08:11:20 +00:00
@@ -13,6 +13,8 @@ abstract class PlatformSettings (objects: ObjectFactory) {
|
||||
|
||||
open class MacOSPlatformSettings @Inject constructor(objects: ObjectFactory): PlatformSettings(objects) {
|
||||
var packageName: String? = null
|
||||
var dockName: String? = null
|
||||
var setDockNameSameAsPackageName: Boolean = true
|
||||
var dmgPackageVersion: String? = null
|
||||
var pkgPackageVersion: String? = null
|
||||
|
||||
|
||||
@@ -221,6 +221,12 @@ internal fun AbstractJPackageTask.configurePlatformSettings(app: Application) {
|
||||
OS.MacOS -> {
|
||||
app.nativeDistributions.macOS.also { mac ->
|
||||
macPackageName.set(provider { mac.packageName })
|
||||
macDockName.set(
|
||||
if (mac.setDockNameSameAsPackageName)
|
||||
provider { mac.dockName }.orElse(macPackageName).orElse(packageName)
|
||||
else
|
||||
provider { mac.dockName }
|
||||
)
|
||||
nonValidatedMacBundleID.set(provider { mac.bundleID })
|
||||
nonValidatedMacSigningSettings = app.nativeDistributions.macOS.signing
|
||||
iconFile.set(mac.iconFile)
|
||||
|
||||
@@ -118,6 +118,10 @@ abstract class AbstractJPackageTask @Inject constructor(
|
||||
@get:Optional
|
||||
val macPackageName: Property<String?> = objects.nullableProperty()
|
||||
|
||||
@get:Input
|
||||
@get:Optional
|
||||
val macDockName: Property<String?> = objects.nullableProperty()
|
||||
|
||||
@get:Input
|
||||
@get:Optional
|
||||
val winConsole: Property<Boolean?> = objects.nullableProperty()
|
||||
@@ -252,6 +256,9 @@ abstract class AbstractJPackageTask @Inject constructor(
|
||||
OS.MacOS -> {
|
||||
cliArg("--mac-package-name", macPackageName)
|
||||
cliArg("--mac-package-identifier", nonValidatedMacBundleID)
|
||||
macDockName.orNull?.let { dockName ->
|
||||
cliArg("--java-options", "-Xdock:name=\"$dockName\"")
|
||||
}
|
||||
|
||||
withValidatedMacOSSigning { signing ->
|
||||
cliArg("--mac-sign", true)
|
||||
|
||||
@@ -7,6 +7,7 @@ import org.jetbrains.compose.desktop.application.internal.currentOS
|
||||
import org.jetbrains.compose.desktop.application.internal.currentTarget
|
||||
import org.jetbrains.compose.test.*
|
||||
import org.junit.jupiter.api.Assertions.assertEquals
|
||||
import org.junit.jupiter.api.Assumptions
|
||||
import org.junit.jupiter.api.Test
|
||||
import java.util.jar.JarFile
|
||||
|
||||
@@ -135,4 +136,16 @@ class DesktopApplicationTest : GradlePluginTestBase() {
|
||||
check.logContains("Compose Gradle plugin test log warning!")
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
fun testMacOptions() {
|
||||
Assumptions.assumeTrue(currentOS == OS.MacOS)
|
||||
|
||||
with(testProject(TestProjects.macOptions)) {
|
||||
gradle(":runDistributable").build().checks { check ->
|
||||
check.taskOutcome(":runDistributable", TaskOutcome.SUCCESS)
|
||||
check.logContains("Hello, from Mac OS!")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,4 +6,5 @@ object TestProjects {
|
||||
const val jvmKotlinDsl = "application/jvmKotlinDsl"
|
||||
const val moduleClashCli = "application/moduleClashCli"
|
||||
const val javaLogger = "application/javaLogger"
|
||||
const val macOptions = "application/macOptions"
|
||||
}
|
||||
@@ -46,6 +46,9 @@ compose.desktop {
|
||||
menuGroup = "compose"
|
||||
upgradeUuid = "2d6ff464-75be-40ad-a256-56420b9cc374"
|
||||
}
|
||||
macOS {
|
||||
dockName = "CustomDockName"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
import org.jetbrains.compose.desktop.application.dsl.TargetFormat
|
||||
|
||||
plugins {
|
||||
id "org.jetbrains.kotlin.jvm"
|
||||
id "org.jetbrains.compose"
|
||||
}
|
||||
|
||||
repositories {
|
||||
google()
|
||||
mavenCentral()
|
||||
jcenter()
|
||||
maven {
|
||||
url "https://maven.pkg.jetbrains.space/public/p/compose/dev"
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
implementation "org.jetbrains.kotlin:kotlin-stdlib"
|
||||
implementation compose.desktop.currentOs
|
||||
}
|
||||
|
||||
compose.desktop {
|
||||
application {
|
||||
mainClass = "MainKt"
|
||||
nativeDistributions {
|
||||
packageName = "TestPackage"
|
||||
macOS {
|
||||
dockName = "CustomDockName"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
pluginManagement {
|
||||
plugins {
|
||||
id 'org.jetbrains.kotlin.jvm' version 'KOTLIN_VERSION_PLACEHOLDER'
|
||||
id 'org.jetbrains.compose' version 'COMPOSE_VERSION_PLACEHOLDER'
|
||||
}
|
||||
repositories {
|
||||
mavenLocal()
|
||||
gradlePluginPortal()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
fun main() {
|
||||
println("Hello, from Mac OS!")
|
||||
}
|
||||
Reference in New Issue
Block a user