diff --git a/.gitignore b/.gitignore index 0e13346..823d2ca 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,5 @@ # Ignore Gradle build output directory build + +server/src/main/resources/react diff --git a/server/build.gradle.kts b/server/build.gradle.kts index 8faec9c..41dcb09 100644 --- a/server/build.gradle.kts +++ b/server/build.gradle.kts @@ -1,6 +1,9 @@ +import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar + plugins { // id("org.jetbrains.kotlin.jvm") version "1.4.21" application + id("com.github.johnrengelman.shadow") version "6.1.0" } @@ -84,5 +87,43 @@ dependencies { } application { - mainClass.set("ir.armor.tachidesk.Main") + val name = "ir.armor.tachidesk.Main" + mainClass.set(name) + + // Required by ShadowJar. + mainClassName = name } + +sourceSets { + main { + resources { + srcDir("src/main/resources") + } + } +} + +tasks { + jar { + manifest { + attributes( + mapOf( + "Main-Class" to "com.example.MainKt", //will make your jar (produced by jar task) runnable + "ImplementationTitle" to project.name, + "Implementation-Version" to project.version) + ) + } + } + shadowJar { + manifest.inheritFrom(jar.get().manifest) //will make your shadowJar (produced by jar task) runnable + } +} + +tasks.withType { + destinationDir = File("$rootDir/server/build") + //dependsOn(":webUI:copyBuild") +} + +tasks.named("processResources") { + dependsOn(":webUI:copyBuild") +} + diff --git a/server/src/main/kotlin/ir/armor/tachidesk/Main.kt b/server/src/main/kotlin/ir/armor/tachidesk/Main.kt index b1b1d38..0324799 100644 --- a/server/src/main/kotlin/ir/armor/tachidesk/Main.kt +++ b/server/src/main/kotlin/ir/armor/tachidesk/Main.kt @@ -37,7 +37,12 @@ class Main { - val app = Javalin.create().start(4567) + val app = Javalin.create { config -> + // config.addSinglePageRoot("/", "") + config.addStaticFiles("/react") + }.start(4567) + + app.before() { ctx -> // allow the client which is running on another port diff --git a/webUI/build.gradle.kts b/webUI/build.gradle.kts index 2a13182..f265f2c 100644 --- a/webUI/build.gradle.kts +++ b/webUI/build.gradle.kts @@ -5,4 +5,17 @@ plugins { node { workDir = file("${project.projectDir}/react/") nodeModulesDir = file("${project.projectDir}/react/node_modules") -} \ No newline at end of file +} + +tasks.named("yarn_build") { + dependsOn("yarn_install") +} + +tasks.register("copyBuild") { + from(file("$rootDir/webUI/react/build")) + into(file("$rootDir/server/src/main/resources/react")) +} + +tasks.named("copyBuild") { + dependsOn("yarn_build") +} diff --git a/webUI/node_modules/.yarn-integrity b/webUI/node_modules/.yarn-integrity new file mode 100644 index 0000000..6848ff5 --- /dev/null +++ b/webUI/node_modules/.yarn-integrity @@ -0,0 +1,10 @@ +{ + "systemParams": "linux-x64-88", + "modulesFolders": [], + "flags": [], + "linkedModules": [], + "topLevelPatterns": [], + "lockfileEntries": {}, + "files": [], + "artifacts": {} +} \ No newline at end of file diff --git a/webUI/yarn.lock b/webUI/yarn.lock new file mode 100644 index 0000000..fb57ccd --- /dev/null +++ b/webUI/yarn.lock @@ -0,0 +1,4 @@ +# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. +# yarn lockfile v1 + +