Browse Source

Allow including all runtime modules

pull/456/head
Alexey Tsvetkov 4 years ago committed by Alexey Tsvetkov
parent
commit
2fac821f99
  1. 1
      gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/dsl/NativeDistributions.kt
  2. 2
      gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/configureApplication.kt
  3. 16
      gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/tasks/AbstractJLinkTask.kt

1
gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/dsl/NativeDistributions.kt

@ -34,6 +34,7 @@ open class NativeDistributions @Inject constructor(
fun modules(vararg modules: String) {
this.modules.addAll(modules.toList())
}
var includeAllModules: Boolean = false
var targetFormats: Set<TargetFormat> = EnumSet.noneOf(TargetFormat::class.java)
fun targetFormats(vararg formats: TargetFormat) {

2
gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/internal/configureApplication.kt

@ -69,6 +69,8 @@ internal fun Project.configurePackagingTasks(apps: Collection<Application>) {
dependsOn(checkRuntime)
javaHome.set(provider { app.javaHomeOrDefault() })
modules.set(provider { app.nativeDistributions.modules })
includeAllModules.set(provider { app.nativeDistributions.includeAllModules })
javaRuntimePropertiesFile.set(checkRuntime.flatMap { it.javaRuntimePropertiesFile })
destinationDir.set(project.layout.buildDirectory.dir("compose/tmp/${app.name}/runtime"))
}

16
gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/desktop/application/tasks/AbstractJLinkTask.kt

@ -1,10 +1,14 @@
package org.jetbrains.compose.desktop.application.tasks
import org.gradle.api.file.RegularFileProperty
import org.gradle.api.provider.ListProperty
import org.gradle.api.provider.Property
import org.gradle.api.tasks.Input
import org.gradle.api.tasks.InputFile
import org.gradle.api.tasks.Optional
import org.jetbrains.compose.desktop.application.dsl.RuntimeCompressionLevel
import org.jetbrains.compose.desktop.application.internal.*
import org.jetbrains.compose.desktop.application.internal.JavaRuntimeProperties
import org.jetbrains.compose.desktop.application.internal.cliArg
import org.jetbrains.compose.desktop.application.internal.notNullProperty
import org.jetbrains.compose.desktop.application.internal.nullableProperty
@ -16,6 +20,12 @@ abstract class AbstractJLinkTask : AbstractJvmToolOperationTask("jlink") {
@get:Input
val modules: ListProperty<String> = objects.listProperty(String::class.java)
@get:Input
val includeAllModules: Property<Boolean> = objects.notNullProperty()
@get:InputFile
val javaRuntimePropertiesFile: RegularFileProperty = objects.fileProperty()
@get:Input
internal val stripDebug: Property<Boolean> = objects.notNullProperty(true)
@ -33,7 +43,11 @@ abstract class AbstractJLinkTask : AbstractJvmToolOperationTask("jlink") {
internal val compressionLevel: Property<RuntimeCompressionLevel?> = objects.nullableProperty()
override fun makeArgs(tmpDir: File): MutableList<String> = super.makeArgs(tmpDir).apply {
modules.get().forEach { m ->
val modulesToInclude =
if (includeAllModules.get()) {
JavaRuntimeProperties.readFromFile(javaRuntimePropertiesFile.ioFile).availableModules
} else modules.get()
modulesToInclude.forEach { m ->
cliArg("--add-modules", m)
}

Loading…
Cancel
Save