Refactor build and server setup
Introduced a versioning task in a new `version.gradle.kts` file to auto-generate version properties. The main server setup in `Main.kt` was refactored to streamline server initialization using `UndertowServer`. Dependencies and configurations in `build.gradle.kts` were updated to deploy effectively, including improved yarn lock handling and symbolic link integration.
This commit is contained in:
@@ -1,5 +1,9 @@
|
|||||||
|
import java.nio.file.Files
|
||||||
|
import java.nio.file.Paths
|
||||||
|
|
||||||
buildscript {
|
buildscript {
|
||||||
apply(from = "common.gradle.kts")
|
apply(from = "common.gradle.kts")
|
||||||
|
apply(from = "version.gradle.kts")
|
||||||
}
|
}
|
||||||
|
|
||||||
plugins {
|
plugins {
|
||||||
@@ -53,14 +57,14 @@ kotlin {
|
|||||||
dependencies {
|
dependencies {
|
||||||
implementation(project(":common"))
|
implementation(project(":common"))
|
||||||
//base
|
//base
|
||||||
api("nl.astraeus:kotlin-css-generator:1.0.9-SNAPSHOT")
|
implementation("nl.astraeus:kotlin-css-generator:1.0.10")
|
||||||
implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.6.0")
|
implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.6.0")
|
||||||
|
implementation("nl.astraeus:vst-ui-base:1.1.2")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val jsMain by getting {
|
val jsMain by getting {
|
||||||
dependencies {
|
dependencies {
|
||||||
implementation("nl.astraeus:kotlin-komponent:1.2.4-SNAPSHOT")
|
implementation("nl.astraeus:kotlin-komponent:1.2.4")
|
||||||
implementation("nl.astraeus:vst-ui-base:1.0.1-SNAPSHOT")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
val jsTest by getting {
|
val jsTest by getting {
|
||||||
@@ -91,3 +95,88 @@ kotlin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
application {
|
||||||
|
mainClass.set("nl.astraeus.vst.chip.MainKt")
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Hardcoded deploy configuration */
|
||||||
|
|
||||||
|
val deployDirectory = "vst-chip.midi-vst.com"
|
||||||
|
|
||||||
|
tasks.register<Copy>("unzipDistribution") {
|
||||||
|
mustRunAfter("removeSymbolicLink")
|
||||||
|
val zipDir = layout.projectDirectory.dir("build/distributions")
|
||||||
|
val zipFile = zipDir.file("${project.name}-${project.version}.zip")
|
||||||
|
|
||||||
|
val outputDir = file("/home/rnentjes/www/${deployDirectory}")
|
||||||
|
|
||||||
|
from(zipTree(zipFile))
|
||||||
|
into(outputDir)
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.register("createSymbolicLink") {
|
||||||
|
mustRunAfter("unzipDistribution")
|
||||||
|
doLast {
|
||||||
|
val targetDir =
|
||||||
|
Paths.get("/home/rnentjes/www/${deployDirectory}/${project.name}-${project.version}") // Directory to link to
|
||||||
|
val symlink =
|
||||||
|
Paths.get("/home/rnentjes/www/${deployDirectory}/${project.name}") // Path for the symbolic link
|
||||||
|
|
||||||
|
if (!Files.exists(targetDir)) {
|
||||||
|
throw IllegalArgumentException("Target directory does not exist: $targetDir")
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Files.exists(symlink)) {
|
||||||
|
println("Symbolic link already exists: $symlink")
|
||||||
|
} else {
|
||||||
|
Files.createSymbolicLink(symlink, targetDir)
|
||||||
|
println("Symbolic link created: $symlink -> $targetDir")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.register<Copy>("copyWeb") {
|
||||||
|
val webDir = layout.projectDirectory.dir("web")
|
||||||
|
val outputDir = file("/home/rnentjes/www/${deployDirectory}/web")
|
||||||
|
|
||||||
|
from(webDir)
|
||||||
|
into(outputDir)
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.named<Task>("build") {
|
||||||
|
dependsOn("generateVersionProperties")
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.named("kotlinUpgradeYarnLock") {
|
||||||
|
mustRunAfter("clean")
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.named("build") {
|
||||||
|
mustRunAfter("kotlinUpgradeYarnLock")
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.named("build") {
|
||||||
|
mustRunAfter("kotlinUpgradeYarnLock")
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.named("copyWeb") {
|
||||||
|
mustRunAfter("build")
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.register("removeSymbolicLink") {
|
||||||
|
mustRunAfter("build")
|
||||||
|
doLast {
|
||||||
|
delete(layout.projectDirectory.file("/home/rnentjes/www/${deployDirectory}/${project.name}"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tasks.register("deploy") {
|
||||||
|
dependsOn("clean")
|
||||||
|
dependsOn("kotlinUpgradeYarnLock")
|
||||||
|
dependsOn("build")
|
||||||
|
dependsOn("copyWeb")
|
||||||
|
dependsOn("removeSymbolicLink")
|
||||||
|
dependsOn("unzipDistribution")
|
||||||
|
dependsOn("createSymbolicLink")
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,9 +1,12 @@
|
|||||||
group = "nl.astraeus"
|
group = "nl.astraeus"
|
||||||
version = "1.0.0-SNAPSHOT"
|
version = "0.1.0"
|
||||||
|
|
||||||
allprojects {
|
allprojects {
|
||||||
repositories {
|
repositories {
|
||||||
mavenLocal()
|
mavenLocal()
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
maven {
|
||||||
|
url = uri("https://gitea.astraeus.nl:8443/api/packages/rnentjes/maven")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,6 @@
|
|||||||
@file:OptIn(ExperimentalKotlinGradlePluginApi::class)
|
@file:OptIn(ExperimentalKotlinGradlePluginApi::class)
|
||||||
|
|
||||||
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
|
import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi
|
||||||
import org.jetbrains.kotlin.gradle.ExperimentalWasmDsl
|
|
||||||
|
|
||||||
buildscript {
|
buildscript {
|
||||||
apply(from = "../common.gradle.kts")
|
apply(from = "../common.gradle.kts")
|
||||||
@@ -18,19 +17,20 @@ kotlin {
|
|||||||
}
|
}
|
||||||
browser()
|
browser()
|
||||||
}
|
}
|
||||||
@OptIn(ExperimentalWasmDsl::class)
|
/* @OptIn(ExperimentalWasmDsl::class)
|
||||||
wasmJs {
|
wasmJs {
|
||||||
browser()
|
browser()
|
||||||
mavenPublication {
|
mavenPublication {
|
||||||
groupId = group as String
|
groupId = group as String
|
||||||
pom { name = "${project.name}-wasm-js" }
|
pom { name = "${project.name}-wasm-js" }
|
||||||
}
|
}
|
||||||
}
|
}*/
|
||||||
jvm()
|
jvm()
|
||||||
|
|
||||||
sourceSets {
|
sourceSets {
|
||||||
val commonMain by getting
|
val commonMain by getting
|
||||||
val jsMain by getting
|
val jsMain by getting
|
||||||
val wasmJsMain by getting
|
val jvmMain by getting
|
||||||
|
//val wasmJsMain by getting
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
|
import jdk.tools.jlink.resources.plugins
|
||||||
|
|
||||||
pluginManagement {
|
pluginManagement {
|
||||||
plugins {
|
plugins {
|
||||||
kotlin("multiplatform") version "2.0.20-RC"
|
kotlin("multiplatform") version "2.0.21"
|
||||||
id("org.gradle.toolchains.foojay-resolver-convention") version "0.5.0"
|
|
||||||
}
|
}
|
||||||
repositories {
|
repositories {
|
||||||
gradlePluginPortal()
|
gradlePluginPortal()
|
||||||
|
|||||||
@@ -1,15 +1,9 @@
|
|||||||
package nl.astraeus.vst.chip
|
package nl.astraeus.vst.chip
|
||||||
|
|
||||||
import com.zaxxer.hikari.HikariConfig
|
import nl.astraeus.vst.base.Settings
|
||||||
import io.undertow.Undertow
|
import nl.astraeus.vst.base.web.UndertowServer
|
||||||
import io.undertow.UndertowOptions
|
|
||||||
import io.undertow.server.session.InMemorySessionManager
|
|
||||||
import io.undertow.server.session.SessionAttachmentHandler
|
|
||||||
import io.undertow.server.session.SessionCookieConfig
|
|
||||||
import nl.astraeus.vst.chip.db.Database
|
|
||||||
import nl.astraeus.vst.chip.logger.LogLevel
|
import nl.astraeus.vst.chip.logger.LogLevel
|
||||||
import nl.astraeus.vst.chip.logger.Logger
|
import nl.astraeus.vst.chip.logger.Logger
|
||||||
import nl.astraeus.vst.chip.web.RequestHandler
|
|
||||||
|
|
||||||
fun main() {
|
fun main() {
|
||||||
Logger.level = LogLevel.DEBUG
|
Logger.level = LogLevel.DEBUG
|
||||||
@@ -18,6 +12,10 @@ fun main() {
|
|||||||
e.printStackTrace()
|
e.printStackTrace()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Settings.port = 9005
|
||||||
|
Settings.jdbcStatsPort = 6005
|
||||||
|
|
||||||
|
/*
|
||||||
Class.forName("nl.astraeus.jdbc.Driver")
|
Class.forName("nl.astraeus.jdbc.Driver")
|
||||||
|
|
||||||
Database.initialize(HikariConfig().apply {
|
Database.initialize(HikariConfig().apply {
|
||||||
@@ -46,4 +44,12 @@ fun main() {
|
|||||||
|
|
||||||
println("Starting server at port ${Settings.port}...")
|
println("Starting server at port ${Settings.port}...")
|
||||||
server?.start()
|
server?.start()
|
||||||
|
*/
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
UndertowServer.start(
|
||||||
|
"Vst Chip",
|
||||||
|
"/vst-chip-worklet-ui.js"
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
20
version.gradle.kts
Normal file
20
version.gradle.kts
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
import java.util.*
|
||||||
|
|
||||||
|
tasks.register("generateVersionProperties") {
|
||||||
|
doLast {
|
||||||
|
val versionDir = layout.buildDirectory.dir("processedResources/jvm/main")
|
||||||
|
val versionFile = versionDir.get().file("version.properties").asFile
|
||||||
|
versionDir.get().asFile.mkdirs()
|
||||||
|
|
||||||
|
val properties = Properties().apply {
|
||||||
|
setProperty("group", project.group.toString())
|
||||||
|
setProperty("name", project.name.toString())
|
||||||
|
setProperty("version", project.version.toString())
|
||||||
|
setProperty("buildTime", Date().toString())
|
||||||
|
}
|
||||||
|
|
||||||
|
versionFile.writer().use { writer ->
|
||||||
|
properties.store(writer, "Version information")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user