Browse Source

Fix getting runtime classpath from Kotlin MPP target

runtimeElementsConfigurationName is not a resolvable configuration
pull/28/head
Alexey Tsvetkov 4 years ago committed by Alexey Tsvetkov
parent
commit
66a392b11f
  1. 10
      gradle-plugins/compose-desktop-application/src/main/kotlin/org/jetbrains/compose/desktop/application/ApplicationPlugin.kt

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

@ -1,6 +1,7 @@
package org.jetbrains.compose.desktop.application package org.jetbrains.compose.desktop.application
import org.gradle.api.* import org.gradle.api.*
import org.gradle.api.file.FileCollection
import org.gradle.api.plugins.JavaPluginConvention import org.gradle.api.plugins.JavaPluginConvention
import org.gradle.api.tasks.JavaExec import org.gradle.api.tasks.JavaExec
import org.gradle.api.tasks.TaskContainer import org.gradle.api.tasks.TaskContainer
@ -17,7 +18,9 @@ import org.jetbrains.compose.desktop.application.internal.currentOS
import org.jetbrains.compose.desktop.application.internal.provider import org.jetbrains.compose.desktop.application.internal.provider
import org.jetbrains.compose.desktop.application.tasks.AbstractJPackageTask import org.jetbrains.compose.desktop.application.tasks.AbstractJPackageTask
import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension import org.jetbrains.kotlin.gradle.dsl.KotlinMultiplatformExtension
import org.jetbrains.kotlin.gradle.plugin.KotlinCompilationToRunnableFiles
import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
import org.jetbrains.kotlin.gradle.plugin.KotlinTarget
import java.io.File import java.io.File
import java.util.* import java.util.*
@ -157,7 +160,7 @@ internal fun AbstractJPackageTask.configurePackagingTask(app: Application) {
val target = configSource.target val target = configSource.target
dependsOn(target.artifactsTaskName) dependsOn(target.artifactsTaskName)
launcherMainJar.set(app.mainJar.orElse(jarFromJarTaskByName(target.artifactsTaskName))) launcherMainJar.set(app.mainJar.orElse(jarFromJarTaskByName(target.artifactsTaskName)))
files.from(project.configurations.named(target.runtimeElementsConfigurationName)) files.from(target.runtimeFiles())
} }
} }
modules.set(provider { app.nativeDistributions.modules }) modules.set(provider { app.nativeDistributions.modules })
@ -191,7 +194,7 @@ private fun Project.configureRunTask(app: Application) {
is ConfigurationSource.KotlinMppTarget -> { is ConfigurationSource.KotlinMppTarget -> {
val target = configSource.target val target = configSource.target
dependsOn(target.artifactsTaskName) dependsOn(target.artifactsTaskName)
cp.from(configurations.named(target.runtimeElementsConfigurationName)) cp.from(target.runtimeFiles())
} }
} }
@ -199,6 +202,9 @@ private fun Project.configureRunTask(app: Application) {
} }
} }
private fun KotlinTarget.runtimeFiles(): FileCollection =
(compilations.getByName("main") as KotlinCompilationToRunnableFiles).runtimeDependencyFiles
private fun Application.javaHomeOrDefault(): String = private fun Application.javaHomeOrDefault(): String =
javaHome ?: System.getProperty("java.home") javaHome ?: System.getProperty("java.home")

Loading…
Cancel
Save