setup docker build
This commit is contained in:
@@ -35,6 +35,15 @@ tasks.withType<Test> {
|
||||
jvmArgs("--enable-preview")
|
||||
}
|
||||
|
||||
tasks.register("deps") {
|
||||
group = "build"
|
||||
description = "resolves all resolvable configurations"
|
||||
|
||||
doLast {
|
||||
configurations.filter { it.isCanBeResolved }.forEach { it.resolve() }
|
||||
}
|
||||
}
|
||||
|
||||
val application = extensions.findByType<JavaApplication>()
|
||||
application?.apply {
|
||||
applicationDefaultJvmArgs = listOf("--enable-preview")
|
||||
|
@@ -0,0 +1,68 @@
|
||||
package eu.jonahbauer.chat.build.jlink
|
||||
|
||||
import org.gradle.api.DefaultTask
|
||||
import org.gradle.api.file.ConfigurableFileCollection
|
||||
import org.gradle.api.file.DirectoryProperty
|
||||
import org.gradle.api.file.RegularFileProperty
|
||||
import org.gradle.api.plugins.JavaPluginExtension
|
||||
import org.gradle.api.plugins.internal.JavaPluginHelper
|
||||
import org.gradle.api.provider.ListProperty
|
||||
import org.gradle.api.tasks.*
|
||||
import org.gradle.api.tasks.internal.JavaExecExecutableUtils
|
||||
import org.gradle.jvm.toolchain.JavaToolchainService
|
||||
import org.gradle.jvm.toolchain.internal.JavaExecutableUtils
|
||||
import org.gradle.kotlin.dsl.getByType
|
||||
|
||||
abstract class JLinkTask : DefaultTask() {
|
||||
@get:OutputDirectory
|
||||
abstract val output : DirectoryProperty
|
||||
|
||||
@get:InputFile
|
||||
abstract val executable : RegularFileProperty
|
||||
|
||||
@get:InputFiles
|
||||
abstract val modulePath : ConfigurableFileCollection
|
||||
|
||||
@get:Input
|
||||
abstract val modules : ListProperty<String>
|
||||
|
||||
@get:Input
|
||||
abstract val options : ListProperty<String>
|
||||
|
||||
init {
|
||||
group = "distribution"
|
||||
description = "assembles a modular runtime image using jlink"
|
||||
|
||||
output.convention(project.layout.buildDirectory.dir("dist/jre"))
|
||||
modules.convention(listOf("ALL-MODULE-PATH"))
|
||||
|
||||
if (project.pluginManager.hasPlugin("java")) {
|
||||
val feature = JavaPluginHelper.getJavaComponent(project).mainFeature
|
||||
modulePath.from(feature.runtimeClasspathConfiguration)
|
||||
modulePath.from(feature.jarTask)
|
||||
|
||||
val toolchains = project.extensions.getByType(JavaToolchainService::class)
|
||||
val java = project.extensions.getByType(JavaPluginExtension::class)
|
||||
|
||||
executable.convention(toolchains.launcherFor(java.toolchain)
|
||||
.map { it.metadata.installationPath }
|
||||
.map { it.dir("bin").file("jlink") })
|
||||
}
|
||||
}
|
||||
|
||||
@TaskAction
|
||||
fun execute() {
|
||||
val args = options.get() + listOf(
|
||||
"--module-path", modulePath.asPath,
|
||||
"--output", output.get().asFile.path,
|
||||
"--add-modules", modules.get().joinToString(",")
|
||||
)
|
||||
val executable = executable.get().asFile.path
|
||||
|
||||
project.delete(output)
|
||||
project.exec {
|
||||
this.executable = executable
|
||||
this.args = args
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user