You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
435 lines
18 KiB
435 lines
18 KiB
3 years ago
|
/*
|
||
|
* 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.
|
||
|
*/
|
||
|
|
||
4 years ago
|
package org.jetbrains.compose.desktop.application.internal
|
||
4 years ago
|
|
||
|
import org.gradle.api.*
|
||
3 years ago
|
import org.gradle.api.file.Directory
|
||
4 years ago
|
import org.gradle.api.file.DuplicatesStrategy
|
||
|
import org.gradle.api.file.FileCollection
|
||
|
import org.gradle.api.provider.Provider
|
||
4 years ago
|
import org.gradle.api.tasks.*
|
||
4 years ago
|
import org.gradle.jvm.tasks.Jar
|
||
2 years ago
|
import org.jetbrains.compose.desktop.application.dsl.JvmApplication
|
||
4 years ago
|
import org.jetbrains.compose.desktop.application.dsl.TargetFormat
|
||
3 years ago
|
import org.jetbrains.compose.desktop.application.internal.validation.validatePackageVersions
|
||
3 years ago
|
import org.jetbrains.compose.desktop.application.tasks.*
|
||
2 years ago
|
import org.jetbrains.compose.desktop.tasks.AbstractUnpackDefaultComposeApplicationResourcesTask
|
||
3 years ago
|
import org.jetbrains.compose.internal.*
|
||
4 years ago
|
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
|
||
|
import java.io.File
|
||
|
import java.util.*
|
||
|
|
||
3 years ago
|
private val defaultJvmArgs = listOf("-D$CONFIGURE_SWING_GLOBALS=true")
|
||
3 years ago
|
|
||
4 years ago
|
// todo: multiple launchers
|
||
|
// todo: file associations
|
||
|
// todo: use workers
|
||
2 years ago
|
internal fun configureJvmApplication(
|
||
|
project: Project,
|
||
|
app: JvmApplication,
|
||
|
unpackDefaultResources: TaskProvider<AbstractUnpackDefaultComposeApplicationResourcesTask>
|
||
|
) {
|
||
4 years ago
|
if (app._isDefaultConfigurationEnabled) {
|
||
3 years ago
|
if (project.plugins.hasPlugin(KOTLIN_MPP_PLUGIN_ID)) {
|
||
4 years ago
|
project.configureFromMppPlugin(app)
|
||
3 years ago
|
} else if (project.plugins.hasPlugin(KOTLIN_JVM_PLUGIN_ID)) {
|
||
3 years ago
|
val mainSourceSet = project.javaSourceSets.getByName("main")
|
||
4 years ago
|
app.from(mainSourceSet)
|
||
4 years ago
|
}
|
||
|
}
|
||
3 years ago
|
project.validatePackageVersions(app)
|
||
2 years ago
|
project.configurePackagingTasks(listOf(app), unpackDefaultResources)
|
||
4 years ago
|
project.configureWix()
|
||
4 years ago
|
}
|
||
|
|
||
2 years ago
|
internal fun Project.configureFromMppPlugin(mainApplication: JvmApplication) {
|
||
4 years ago
|
var isJvmTargetConfigured = false
|
||
3 years ago
|
mppExt.targets.all { target ->
|
||
4 years ago
|
if (target.platformType == KotlinPlatformType.jvm) {
|
||
|
if (!isJvmTargetConfigured) {
|
||
|
mainApplication.from(target)
|
||
|
isJvmTargetConfigured = true
|
||
|
} else {
|
||
4 years ago
|
logger.error("w: Default configuration for Compose Desktop Application is disabled: " +
|
||
4 years ago
|
"multiple Kotlin JVM targets definitions are detected. " +
|
||
|
"Specify, which target to use by using `compose.desktop.application.from(kotlinMppTarget)`")
|
||
|
mainApplication.disableDefaultConfiguration()
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
2 years ago
|
internal fun Project.configurePackagingTasks(
|
||
|
apps: Collection<JvmApplication>,
|
||
|
unpackDefaultResources: TaskProvider<AbstractUnpackDefaultComposeApplicationResourcesTask>
|
||
|
) {
|
||
4 years ago
|
for (app in apps) {
|
||
2 years ago
|
val checkRuntime = tasks.composeDesktopJvmTask<AbstractCheckNativeDistributionRuntime>(
|
||
3 years ago
|
taskName("checkRuntime", app)
|
||
|
) {
|
||
|
javaHome.set(provider { app.javaHomeOrDefault() })
|
||
|
javaRuntimePropertiesFile.set(
|
||
|
project.layout.buildDirectory.file("compose/tmp/${app.name}/runtime-properties/properties.bin")
|
||
|
)
|
||
|
}
|
||
|
|
||
2 years ago
|
tasks.composeDesktopJvmTask<AbstractSuggestModulesTask>(taskName("suggestRuntimeModules", app)) {
|
||
3 years ago
|
dependsOn(checkRuntime)
|
||
|
javaHome.set(provider { app.javaHomeOrDefault() })
|
||
|
modules.set(provider { app.nativeDistributions.modules })
|
||
|
|
||
|
app._configurationSource?.let { configSource ->
|
||
|
dependsOn(configSource.jarTaskName)
|
||
|
files.from(configSource.runtimeClasspath(project))
|
||
|
launcherMainJar.set(app.mainJar.orElse(configSource.jarTask(project).flatMap { it.archiveFile }))
|
||
|
}
|
||
|
}
|
||
|
|
||
2 years ago
|
val prepareAppResources = tasks.composeDesktopJvmTask<Sync>(
|
||
3 years ago
|
taskName("prepareAppResources", app)
|
||
|
) {
|
||
|
val appResourcesRootDir = app.nativeDistributions.appResourcesRootDir
|
||
|
if (appResourcesRootDir.isPresent) {
|
||
|
from(appResourcesRootDir.dir("common"))
|
||
|
from(appResourcesRootDir.dir(currentOS.id))
|
||
|
from(appResourcesRootDir.dir(currentTarget.id))
|
||
|
}
|
||
|
|
||
|
val destDir = project.layout.buildDirectory.dir("compose/tmp/${app.name}/resources")
|
||
|
into(destDir)
|
||
|
}
|
||
|
|
||
2 years ago
|
val createRuntimeImage = tasks.composeDesktopJvmTask<AbstractJLinkTask>(
|
||
4 years ago
|
taskName("createRuntimeImage", app)
|
||
|
) {
|
||
3 years ago
|
dependsOn(checkRuntime)
|
||
4 years ago
|
javaHome.set(provider { app.javaHomeOrDefault() })
|
||
|
modules.set(provider { app.nativeDistributions.modules })
|
||
3 years ago
|
includeAllModules.set(provider { app.nativeDistributions.includeAllModules })
|
||
|
javaRuntimePropertiesFile.set(checkRuntime.flatMap { it.javaRuntimePropertiesFile })
|
||
4 years ago
|
destinationDir.set(project.layout.buildDirectory.dir("compose/tmp/${app.name}/runtime"))
|
||
|
}
|
||
|
|
||
2 years ago
|
val createDistributable = tasks.composeDesktopJvmTask<AbstractJPackageTask>(
|
||
3 years ago
|
taskName("createDistributable", app),
|
||
|
args = listOf(TargetFormat.AppImage)
|
||
|
) {
|
||
3 years ago
|
configurePackagingTask(
|
||
|
app,
|
||
|
createRuntimeImage = createRuntimeImage,
|
||
2 years ago
|
prepareAppResources = prepareAppResources,
|
||
2 years ago
|
checkRuntime = checkRuntime,
|
||
|
unpackDefaultResources = unpackDefaultResources
|
||
3 years ago
|
)
|
||
3 years ago
|
}
|
||
|
|
||
4 years ago
|
val packageFormats = app.nativeDistributions.targetFormats.map { targetFormat ->
|
||
2 years ago
|
val packageFormat = tasks.composeDesktopJvmTask<AbstractJPackageTask>(
|
||
4 years ago
|
taskName("package", app, targetFormat.name),
|
||
|
args = listOf(targetFormat)
|
||
|
) {
|
||
3 years ago
|
// On Mac we want to patch bundled Info.plist file,
|
||
|
// so we create an app image, change its Info.plist,
|
||
|
// then create an installer based on the app image.
|
||
|
// We could create an installer the same way on other platforms, but
|
||
|
// in some cases there are failures with JDK 15.
|
||
|
// See [AbstractJPackageTask.patchInfoPlistIfNeeded]
|
||
|
if (currentOS != OS.MacOS) {
|
||
3 years ago
|
configurePackagingTask(
|
||
|
app,
|
||
|
createRuntimeImage = createRuntimeImage,
|
||
2 years ago
|
prepareAppResources = prepareAppResources,
|
||
2 years ago
|
checkRuntime = checkRuntime,
|
||
|
unpackDefaultResources = unpackDefaultResources
|
||
3 years ago
|
)
|
||
3 years ago
|
} else {
|
||
2 years ago
|
configurePackagingTask(
|
||
|
app,
|
||
|
createAppImage = createDistributable,
|
||
2 years ago
|
checkRuntime = checkRuntime,
|
||
|
unpackDefaultResources = unpackDefaultResources
|
||
2 years ago
|
)
|
||
3 years ago
|
}
|
||
4 years ago
|
}
|
||
3 years ago
|
|
||
|
if (targetFormat.isCompatibleWith(OS.MacOS)) {
|
||
|
check(targetFormat == TargetFormat.Dmg || targetFormat == TargetFormat.Pkg) {
|
||
|
"Unexpected target format for MacOS: $targetFormat"
|
||
|
}
|
||
|
|
||
3 years ago
|
val notarizationRequestsDir = project.layout.buildDirectory.dir("compose/notarization/${app.name}")
|
||
2 years ago
|
val upload = tasks.composeDesktopJvmTask<AbstractUploadAppForNotarizationTask>(
|
||
3 years ago
|
taskName("notarize", app, targetFormat.name),
|
||
|
args = listOf(targetFormat)
|
||
|
) {
|
||
3 years ago
|
configureUploadForNotarizationTask(app, packageFormat, notarizationRequestsDir)
|
||
3 years ago
|
}
|
||
|
|
||
2 years ago
|
tasks.composeDesktopJvmTask<AbstractCheckNotarizationStatusTask>(
|
||
3 years ago
|
taskName("checkNotarizationStatus", app)
|
||
3 years ago
|
) {
|
||
3 years ago
|
configureCheckNotarizationStatusTask(app, notarizationRequestsDir)
|
||
3 years ago
|
}
|
||
|
}
|
||
|
|
||
|
packageFormat
|
||
4 years ago
|
}
|
||
|
|
||
2 years ago
|
val packageAll = tasks.composeDesktopJvmTask<DefaultTask>(taskName("package", app)) {
|
||
4 years ago
|
dependsOn(packageFormats)
|
||
|
}
|
||
|
|
||
2 years ago
|
val packageUberJarForCurrentOS = project.tasks.composeDesktopJvmTask<Jar>(taskName("package", app, "uberJarForCurrentOS")) {
|
||
4 years ago
|
configurePackageUberJarForCurrentOS(app)
|
||
|
}
|
||
|
|
||
2 years ago
|
val runDistributable = project.tasks.composeDesktopJvmTask<AbstractRunDistributableTask>(
|
||
4 years ago
|
taskName("runDistributable", app),
|
||
|
args = listOf(createDistributable)
|
||
|
)
|
||
3 years ago
|
|
||
2 years ago
|
val run = project.tasks.composeDesktopJvmTask<JavaExec>(taskName("run", app)) {
|
||
3 years ago
|
configureRunTask(app, prepareAppResources = prepareAppResources)
|
||
3 years ago
|
}
|
||
4 years ago
|
}
|
||
|
}
|
||
|
|
||
4 years ago
|
internal fun AbstractJPackageTask.configurePackagingTask(
|
||
2 years ago
|
app: JvmApplication,
|
||
3 years ago
|
createAppImage: TaskProvider<AbstractJPackageTask>? = null,
|
||
3 years ago
|
createRuntimeImage: TaskProvider<AbstractJLinkTask>? = null,
|
||
2 years ago
|
prepareAppResources: TaskProvider<Sync>? = null,
|
||
2 years ago
|
checkRuntime: TaskProvider<AbstractCheckNativeDistributionRuntime>? = null,
|
||
|
unpackDefaultResources: TaskProvider<AbstractUnpackDefaultComposeApplicationResourcesTask>
|
||
4 years ago
|
) {
|
||
4 years ago
|
enabled = targetFormat.isCompatibleWithCurrentOS
|
||
4 years ago
|
|
||
3 years ago
|
createAppImage?.let { createAppImage ->
|
||
|
dependsOn(createAppImage)
|
||
|
appImage.set(createAppImage.flatMap { it.destinationDir })
|
||
|
}
|
||
|
|
||
|
createRuntimeImage?.let { createRuntimeImage ->
|
||
|
dependsOn(createRuntimeImage)
|
||
|
runtimeImage.set(createRuntimeImage.flatMap { it.destinationDir })
|
||
|
}
|
||
4 years ago
|
|
||
3 years ago
|
prepareAppResources?.let { prepareResources ->
|
||
|
dependsOn(prepareResources)
|
||
|
val resourcesDir = project.layout.dir(prepareResources.map { it.destinationDir })
|
||
|
appResourcesDir.set(resourcesDir)
|
||
|
}
|
||
|
|
||
2 years ago
|
checkRuntime?.let { checkRuntime ->
|
||
|
dependsOn(checkRuntime)
|
||
|
javaRuntimePropertiesFile.set(checkRuntime.flatMap { it.javaRuntimePropertiesFile })
|
||
|
}
|
||
|
|
||
2 years ago
|
configurePlatformSettings(app, unpackDefaultResources)
|
||
4 years ago
|
|
||
|
app.nativeDistributions.let { executables ->
|
||
4 years ago
|
packageName.set(app._packageNameProvider(project))
|
||
4 years ago
|
packageDescription.set(provider { executables.description })
|
||
|
packageCopyright.set(provider { executables.copyright })
|
||
|
packageVendor.set(provider { executables.vendor })
|
||
3 years ago
|
packageVersion.set(packageVersionFor(project, app, targetFormat))
|
||
3 years ago
|
licenseFile.set(executables.licenseFile)
|
||
4 years ago
|
}
|
||
|
|
||
4 years ago
|
destinationDir.set(app.nativeDistributions.outputBaseDir.map { it.dir("${app.name}/${targetFormat.outputDirName}") })
|
||
4 years ago
|
javaHome.set(provider { app.javaHomeOrDefault() })
|
||
|
|
||
|
launcherMainJar.set(app.mainJar.orNull)
|
||
2 years ago
|
files.from(app._fromFiles)
|
||
4 years ago
|
dependsOn(*app._dependenciesTaskNames.toTypedArray())
|
||
|
|
||
|
app._configurationSource?.let { configSource ->
|
||
|
dependsOn(configSource.jarTaskName)
|
||
3 years ago
|
files.from(configSource.runtimeClasspath(project))
|
||
4 years ago
|
launcherMainJar.set(app.mainJar.orElse(configSource.jarTask(project).flatMap { it.archiveFile }))
|
||
|
}
|
||
|
|
||
|
launcherMainClass.set(provider { app.mainClass })
|
||
3 years ago
|
launcherJvmArgs.set(provider { defaultJvmArgs + app.jvmArgs })
|
||
4 years ago
|
launcherArgs.set(provider { app.args })
|
||
|
}
|
||
|
|
||
3 years ago
|
internal fun AbstractUploadAppForNotarizationTask.configureUploadForNotarizationTask(
|
||
2 years ago
|
app: JvmApplication,
|
||
3 years ago
|
packageFormat: TaskProvider<AbstractJPackageTask>,
|
||
3 years ago
|
requestsDir: Provider<Directory>
|
||
3 years ago
|
) {
|
||
|
dependsOn(packageFormat)
|
||
|
inputDir.set(packageFormat.flatMap { it.destinationDir })
|
||
3 years ago
|
this.requestsDir.set(requestsDir)
|
||
3 years ago
|
configureCommonNotarizationSettings(app)
|
||
|
}
|
||
|
|
||
|
internal fun AbstractCheckNotarizationStatusTask.configureCheckNotarizationStatusTask(
|
||
2 years ago
|
app: JvmApplication,
|
||
3 years ago
|
requestsDir: Provider<Directory>
|
||
3 years ago
|
) {
|
||
3 years ago
|
requestDir.set(requestsDir)
|
||
3 years ago
|
configureCommonNotarizationSettings(app)
|
||
|
}
|
||
|
|
||
|
internal fun AbstractNotarizationTask.configureCommonNotarizationSettings(
|
||
2 years ago
|
app: JvmApplication
|
||
3 years ago
|
) {
|
||
|
nonValidatedBundleID.set(app.nativeDistributions.macOS.bundleID)
|
||
|
nonValidatedNotarizationSettings = app.nativeDistributions.macOS.notarization
|
||
|
}
|
||
|
|
||
2 years ago
|
internal fun AbstractJPackageTask.configurePlatformSettings(
|
||
|
app: JvmApplication,
|
||
|
unpackDefaultResources: TaskProvider<AbstractUnpackDefaultComposeApplicationResourcesTask>
|
||
|
) {
|
||
|
dependsOn(unpackDefaultResources)
|
||
4 years ago
|
when (currentOS) {
|
||
4 years ago
|
OS.Linux -> {
|
||
4 years ago
|
app.nativeDistributions.linux.also { linux ->
|
||
4 years ago
|
linuxShortcut.set(provider { linux.shortcut })
|
||
|
linuxAppCategory.set(provider { linux.appCategory })
|
||
|
linuxAppRelease.set(provider { linux.appRelease })
|
||
|
linuxDebMaintainer.set(provider { linux.debMaintainer })
|
||
|
linuxMenuGroup.set(provider { linux.menuGroup })
|
||
|
linuxPackageName.set(provider { linux.packageName })
|
||
|
linuxRpmLicenseType.set(provider { linux.rpmLicenseType })
|
||
2 years ago
|
iconFile.set(linux.iconFile.orElse(unpackDefaultResources.flatMap { it.resources.linuxIcon }))
|
||
3 years ago
|
installationPath.set(linux.installationPath)
|
||
4 years ago
|
}
|
||
|
}
|
||
|
OS.Windows -> {
|
||
4 years ago
|
app.nativeDistributions.windows.also { win ->
|
||
4 years ago
|
winConsole.set(provider { win.console })
|
||
|
winDirChooser.set(provider { win.dirChooser })
|
||
|
winPerUserInstall.set(provider { win.perUserInstall })
|
||
|
winShortcut.set(provider { win.shortcut })
|
||
|
winMenu.set(provider { win.menu })
|
||
|
winMenuGroup.set(provider { win.menuGroup })
|
||
|
winUpgradeUuid.set(provider { win.upgradeUuid })
|
||
2 years ago
|
iconFile.set(win.iconFile.orElse(unpackDefaultResources.flatMap { it.resources.windowsIcon }))
|
||
3 years ago
|
installationPath.set(win.installationPath)
|
||
4 years ago
|
}
|
||
|
}
|
||
|
OS.MacOS -> {
|
||
4 years ago
|
app.nativeDistributions.macOS.also { mac ->
|
||
4 years ago
|
macPackageName.set(provider { mac.packageName })
|
||
3 years ago
|
macDockName.set(
|
||
|
if (mac.setDockNameSameAsPackageName)
|
||
|
provider { mac.dockName }.orElse(macPackageName).orElse(packageName)
|
||
|
else
|
||
|
provider { mac.dockName }
|
||
|
)
|
||
2 years ago
|
macAppStore.set(mac.appStore)
|
||
|
macAppCategory.set(mac.appCategory)
|
||
|
macEntitlementsFile.set(mac.entitlementsFile)
|
||
2 years ago
|
macRuntimeEntitlementsFile.set(mac.runtimeEntitlementsFile)
|
||
2 years ago
|
packageBuildVersion.set(packageBuildVersionFor(project, app, targetFormat))
|
||
3 years ago
|
nonValidatedMacBundleID.set(provider { mac.bundleID })
|
||
2 years ago
|
macProvisioningProfile.set(mac.provisioningProfile)
|
||
2 years ago
|
macRuntimeProvisioningProfile.set(mac.runtimeProvisioningProfile)
|
||
3 years ago
|
macExtraPlistKeysRawXml.set(provider { mac.infoPlistSettings.extraKeysRawXml })
|
||
3 years ago
|
nonValidatedMacSigningSettings = app.nativeDistributions.macOS.signing
|
||
2 years ago
|
iconFile.set(mac.iconFile.orElse(unpackDefaultResources.flatMap { it.resources.macIcon }))
|
||
3 years ago
|
installationPath.set(mac.installationPath)
|
||
4 years ago
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
3 years ago
|
private fun JavaExec.configureRunTask(
|
||
2 years ago
|
app: JvmApplication,
|
||
3 years ago
|
prepareAppResources: TaskProvider<Sync>
|
||
|
) {
|
||
|
dependsOn(prepareAppResources)
|
||
|
|
||
4 years ago
|
mainClass.set(provider { app.mainClass })
|
||
|
executable(javaExecutable(app.javaHomeOrDefault()))
|
||
3 years ago
|
jvmArgs = arrayListOf<String>().apply {
|
||
|
addAll(defaultJvmArgs)
|
||
3 years ago
|
|
||
|
if (currentOS == OS.MacOS) {
|
||
|
val file = app.nativeDistributions.macOS.iconFile.ioFileOrNull
|
||
|
if (file != null) add("-Xdock:icon=$file")
|
||
|
}
|
||
|
|
||
3 years ago
|
addAll(app.jvmArgs)
|
||
|
val appResourcesDir = prepareAppResources.get().destinationDir
|
||
|
add("-D$APP_RESOURCES_DIR=${appResourcesDir.absolutePath}")
|
||
|
}
|
||
4 years ago
|
args = app.args
|
||
4 years ago
|
|
||
4 years ago
|
val cp = project.objects.fileCollection()
|
||
|
// adding a null value will cause future invocations of `from` to throw an NPE
|
||
|
app.mainJar.orNull?.let { cp.from(it) }
|
||
|
cp.from(app._fromFiles)
|
||
|
dependsOn(*app._dependenciesTaskNames.toTypedArray())
|
||
4 years ago
|
|
||
4 years ago
|
app._configurationSource?.let { configSource ->
|
||
|
dependsOn(configSource.jarTaskName)
|
||
3 years ago
|
cp.from(configSource.runtimeClasspath(project))
|
||
4 years ago
|
}
|
||
4 years ago
|
|
||
|
classpath = cp
|
||
4 years ago
|
}
|
||
|
|
||
2 years ago
|
private fun Jar.configurePackageUberJarForCurrentOS(app: JvmApplication) {
|
||
4 years ago
|
fun flattenJars(files: FileCollection): FileCollection =
|
||
|
project.files({
|
||
4 years ago
|
files.map { if (it.isZipOrJar()) project.zipTree(it) else it }
|
||
4 years ago
|
})
|
||
|
|
||
|
// adding a null value will cause future invocations of `from` to throw an NPE
|
||
|
app.mainJar.orNull?.let { from(it) }
|
||
|
from(flattenJars(app._fromFiles))
|
||
|
dependsOn(*app._dependenciesTaskNames.toTypedArray())
|
||
|
|
||
|
app._configurationSource?.let { configSource ->
|
||
|
dependsOn(configSource.jarTaskName)
|
||
3 years ago
|
from(flattenJars(configSource.runtimeClasspath(project)))
|
||
4 years ago
|
}
|
||
|
|
||
|
app.mainClass?.let { manifest.attributes["Main-Class"] = it }
|
||
|
duplicatesStrategy = DuplicatesStrategy.EXCLUDE
|
||
|
archiveAppendix.set(currentTarget.id)
|
||
|
archiveBaseName.set(app._packageNameProvider(project))
|
||
3 years ago
|
archiveVersion.set(packageVersionFor(project, app, TargetFormat.AppImage))
|
||
4 years ago
|
destinationDirectory.set(project.layout.buildDirectory.dir("compose/jars"))
|
||
|
|
||
|
doLast {
|
||
4 years ago
|
logger.lifecycle("The jar is written to ${archiveFile.ioFile.canonicalPath}")
|
||
4 years ago
|
}
|
||
|
}
|
||
|
|
||
|
private fun File.isZipOrJar() =
|
||
|
name.endsWith(".jar", ignoreCase = true)
|
||
|
|| name.endsWith(".zip", ignoreCase = true)
|
||
|
|
||
2 years ago
|
internal fun JvmApplication.javaHomeOrDefault(): String =
|
||
4 years ago
|
javaHome ?: System.getProperty("java.home")
|
||
|
|
||
2 years ago
|
private inline fun <reified T : Task> TaskContainer.composeDesktopJvmTask(
|
||
4 years ago
|
name: String,
|
||
|
args: List<Any> = emptyList(),
|
||
|
noinline configureFn: T.() -> Unit = {}
|
||
|
) = register(name, T::class.java, *args.toTypedArray()).apply {
|
||
|
configure {
|
||
4 years ago
|
it.group = "compose desktop"
|
||
4 years ago
|
it.configureFn()
|
||
|
}
|
||
|
}
|
||
|
|
||
2 years ago
|
internal fun JvmApplication._packageNameProvider(project: Project): Provider<String> =
|
||
4 years ago
|
project.provider { nativeDistributions.packageName ?: project.name }
|
||
|
|
||
2 years ago
|
private fun taskName(action: String, app: JvmApplication, suffix: String? = null): String =
|
||
|
listOfNotNull(
|
||
4 years ago
|
action,
|
||
2 years ago
|
app.name.takeIf { it != "main" }?.uppercaseFirstChar(),
|
||
|
suffix?.uppercaseFirstChar()
|
||
|
).joinToString("")
|