From d904e2150319439053d89c723733463c4810bde9 Mon Sep 17 00:00:00 2001 From: Kristóf Marussy Date: Sun, 9 Apr 2023 02:54:51 +0200 Subject: build: organize build scripts into packages Also take advantage of precompiled Kotlin scripts to write build scripts in a more straightforward manner through generated accessors. Might increase memory usage of Gradle. --- subprojects/language-web/build.gradle.kts | 94 ++++++++++++++++--------------- 1 file changed, 48 insertions(+), 46 deletions(-) (limited to 'subprojects/language-web') diff --git a/subprojects/language-web/build.gradle.kts b/subprojects/language-web/build.gradle.kts index b59763a8..d2a39d56 100644 --- a/subprojects/language-web/build.gradle.kts +++ b/subprojects/language-web/build.gradle.kts @@ -1,6 +1,6 @@ plugins { - id("refinery-java-application") - id("refinery-xtext-conventions") + id("tools.refinery.gradle.java-application") + id("tools.refinery.gradle.xtext-generated") } val webapp: Configuration by configurations.creating { @@ -21,64 +21,66 @@ dependencies { testImplementation(libs.jetty.websocket.client) } -val generateXtextLanguage by project(":refinery-language").tasks.existing - -for (taskName in listOf("compileJava", "processResources")) { - tasks.named(taskName) { - dependsOn(generateXtextLanguage) - } -} - application { mainClass.set("tools.refinery.language.web.ServerLauncher") // Enable JDK 19 preview features for virtual thread support. applicationDefaultJvmArgs += "--enable-preview" } -tasks.withType(JavaCompile::class) { - options.release.set(19) - // Enable JDK 19 preview features for virtual thread support. - options.compilerArgs.plusAssign("--enable-preview") -} - // Enable JDK 19 preview features for virtual thread support. fun enablePreview(task: JavaForkOptions) { task.jvmArgs("--enable-preview") } -tasks.withType(Test::class) { - enablePreview(this) -} +tasks { + val generateXtextLanguage by project(":refinery-language").tasks.existing -tasks.jar { - dependsOn(webapp) - from(webapp) { - into("webapp") + for (taskName in listOf("compileJava", "processResources")) { + named(taskName) { + dependsOn(generateXtextLanguage) + } } -} -tasks.shadowJar { - dependsOn(webapp) - from(project.sourceSets.main.map { it.output }) - exclude("META-INF/INDEX.LIST", "META-INF/*.SF", "META-INF/*.DSA", "META-INF/*.RSA","schema/*", - ".options", ".api_description", "*.profile", "about.*", "about_*.html", "about_files/*", - "plugin.xml", "systembundle.properties", "profile.list", "META-INF/resources/xtext/**") - append("plugin.properties") - from(webapp) { - into("webapp") + withType(JavaCompile::class) { + options.release.set(19) + // Enable JDK 19 preview features for virtual thread support. + options.compilerArgs.plusAssign("--enable-preview") + } + + withType(Test::class) { + enablePreview(this) + } + + jar { + dependsOn(webapp) + from(webapp) { + into("webapp") + } + } + + shadowJar { + dependsOn(webapp) + from(project.sourceSets.main.map { it.output }) + exclude("META-INF/INDEX.LIST", "META-INF/*.SF", "META-INF/*.DSA", "META-INF/*.RSA", "schema/*", + ".options", ".api_description", "*.profile", "about.*", "about_*.html", "about_files/*", + "plugin.xml", "systembundle.properties", "profile.list", "META-INF/resources/xtext/**") + append("plugin.properties") + from(webapp) { + into("webapp") + } } -} -tasks.register("serveBackend") { - dependsOn(webapp) - val mainRuntimeClasspath = sourceSets.main.map { it.runtimeClasspath } - dependsOn(mainRuntimeClasspath) - classpath(mainRuntimeClasspath) - mainClass.set(application.mainClass) - enablePreview(this) - standardInput = System.`in` - val baseResource = webapp.incoming.artifacts.artifactFiles.first() - environment("BASE_RESOURCE", baseResource) - group = "run" - description = "Start a Jetty web server serving the Xtex API and assets." + register("serveBackend") { + dependsOn(webapp) + val mainRuntimeClasspath = sourceSets.main.map { it.runtimeClasspath } + dependsOn(mainRuntimeClasspath) + classpath(mainRuntimeClasspath) + mainClass.set(application.mainClass) + enablePreview(this) + standardInput = System.`in` + val baseResource = webapp.incoming.artifacts.artifactFiles.first() + environment("BASE_RESOURCE", baseResource) + group = "run" + description = "Start a Jetty web server serving the Xtex API and assets." + } } -- cgit v1.2.3-54-g00ecf