2021-08-16 21:25:32 +00:00
|
|
|
import java.util.*
|
|
|
|
|
2021-08-16 03:10:39 +00:00
|
|
|
plugins {
|
|
|
|
`java-library`
|
2022-06-03 02:28:44 +00:00
|
|
|
alias(libs.plugins.kotlin.jvm)
|
2021-08-16 03:10:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
dependencies {
|
|
|
|
implementation(kotlin("stdlib"))
|
2022-06-03 02:28:44 +00:00
|
|
|
api(libs.ktor.server.core)
|
2023-09-25 02:07:31 +00:00
|
|
|
implementation(libs.ktor.server.html)
|
2022-06-03 02:28:44 +00:00
|
|
|
testImplementation(libs.junit.jupiter.api)
|
|
|
|
testRuntimeOnly(libs.junit.jupiter.engine)
|
2021-08-16 03:10:39 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
tasks.getByName<Test>("test") {
|
|
|
|
useJUnitPlatform()
|
|
|
|
}
|
2021-08-16 21:25:32 +00:00
|
|
|
|
|
|
|
// TODO: Replace this hack with either a git submodule or an internal Kotlin-based UI
|
|
|
|
tasks.register("package") {
|
|
|
|
doLast {
|
|
|
|
val built = File(rootProject.rootDir.parent, "twigs-web/dist/twigs")
|
|
|
|
if (built.exists()) {
|
|
|
|
built.deleteRecursively()
|
|
|
|
}
|
|
|
|
val dest = File(project.projectDir, "src/main/resources/twigs")
|
|
|
|
if (dest.exists()) {
|
|
|
|
dest.deleteRecursively()
|
|
|
|
}
|
|
|
|
var command = listOf(
|
|
|
|
"cd", "../../twigs-web", ";",
|
|
|
|
"npm", "i", ";",
|
|
|
|
"npm", "run", "package"
|
|
|
|
)
|
|
|
|
command = if (System.getProperty("os.name").toLowerCase(Locale.ROOT).contains("windows")) {
|
|
|
|
listOf("powershell", "-Command") + command
|
|
|
|
} else {
|
|
|
|
listOf("bash", "-c", "\"${command.joinToString(" ")}\"")
|
|
|
|
}
|
|
|
|
exec {
|
|
|
|
commandLine(command)
|
|
|
|
}
|
|
|
|
if (!built.copyRecursively(dest, true) || !dest.isDirectory) {
|
|
|
|
throw GradleException("Failed to copy files from ${built.absolutePath} to ${dest.absolutePath}")
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-08-26 13:15:14 +00:00
|
|
|
//tasks.getByName("processResources") {
|
|
|
|
// dependsOn.add("package")
|
|
|
|
//}
|