2021-03-30 01:31:22 +00:00
|
|
|
import java.net.URI
|
2021-08-16 21:25:32 +00:00
|
|
|
import java.util.*
|
2021-03-30 01:31:22 +00:00
|
|
|
|
|
|
|
plugins {
|
|
|
|
java
|
|
|
|
kotlin("jvm")
|
2021-07-06 15:48:48 +00:00
|
|
|
application
|
2022-06-03 02:28:44 +00:00
|
|
|
alias(libs.plugins.shadow)
|
2021-03-30 01:31:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
repositories {
|
|
|
|
mavenLocal()
|
|
|
|
mavenCentral()
|
|
|
|
maven {
|
2021-07-06 01:05:25 +00:00
|
|
|
url = URI("https://repo.maven.apache.org/maven2")
|
2021-03-30 01:31:22 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
dependencies {
|
2021-07-29 16:40:22 +00:00
|
|
|
implementation(project(":api"))
|
|
|
|
implementation(project(":core"))
|
2021-08-12 21:22:06 +00:00
|
|
|
implementation(project(":db"))
|
2021-08-16 03:10:39 +00:00
|
|
|
implementation(project(":web"))
|
2022-06-03 02:28:44 +00:00
|
|
|
implementation(libs.kotlin.reflect)
|
|
|
|
implementation(libs.ktor.server.core)
|
|
|
|
implementation(libs.ktor.server.cio)
|
|
|
|
implementation(libs.ktor.server.sessions)
|
|
|
|
implementation(libs.kotlin.coroutines.core)
|
|
|
|
implementation(libs.logback)
|
2021-08-26 13:15:14 +00:00
|
|
|
testImplementation(project(":testhelpers"))
|
2022-06-03 02:28:44 +00:00
|
|
|
testImplementation(libs.junit.jupiter.api)
|
|
|
|
testRuntimeOnly(libs.junit.jupiter.engine)
|
2021-03-30 01:31:22 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
description = "twigs-server"
|
|
|
|
|
2021-08-12 21:22:06 +00:00
|
|
|
val twigsMain = "com.wbrawner.twigs.server.ApplicationKt"
|
2021-03-30 01:31:22 +00:00
|
|
|
|
2021-07-06 15:48:48 +00:00
|
|
|
application {
|
|
|
|
mainClass.set(twigsMain)
|
|
|
|
}
|
|
|
|
|
2021-08-12 21:22:06 +00:00
|
|
|
tasks.shadowJar {
|
|
|
|
manifest {
|
|
|
|
attributes("Main-Class" to twigsMain)
|
|
|
|
archiveBaseName.set("twigs")
|
|
|
|
archiveClassifier.set("")
|
|
|
|
archiveVersion.set("")
|
|
|
|
}
|
2021-03-30 01:31:22 +00:00
|
|
|
}
|
2021-08-16 21:25:32 +00:00
|
|
|
|
|
|
|
val captainDefinition = File(project.buildDir, "captain-definition")
|
|
|
|
val tarFile = File(project.buildDir, "twigs.tar")
|
|
|
|
|
|
|
|
tasks.register("package") {
|
|
|
|
dependsOn(":app:shadowJar")
|
|
|
|
doLast {
|
|
|
|
captainDefinition.createNewFile()
|
|
|
|
captainDefinition.outputStream().writer().use {
|
|
|
|
it.appendLine(
|
|
|
|
"""
|
|
|
|
{
|
|
|
|
"schemaVersion": 2,
|
|
|
|
"dockerfileLines": [
|
|
|
|
"FROM adoptopenjdk:openj9",
|
|
|
|
"COPY libs/twigs.jar twigs.jar",
|
|
|
|
"CMD /opt/java/openjdk/bin/java ${'$'}JVM_ARGS -jar /twigs.jar"
|
|
|
|
]
|
|
|
|
}
|
|
|
|
""".trimIndent()
|
|
|
|
)
|
|
|
|
}
|
|
|
|
exec {
|
|
|
|
commandLine(
|
|
|
|
"tar",
|
|
|
|
"-C",
|
|
|
|
project.buildDir.absolutePath,
|
|
|
|
"-cf",
|
|
|
|
project.buildDir.name + File.separator + tarFile.name,
|
|
|
|
captainDefinition.name,
|
|
|
|
"libs/twigs.jar"
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
tasks.register("publish") {
|
|
|
|
dependsOn(":app:package")
|
|
|
|
doLast {
|
2021-09-15 20:03:50 +00:00
|
|
|
var command = listOf("caprover", "deploy", "-t", "build/${tarFile.name}", "-n", "wbrawner", "-a", "twigs-dev")
|
2021-08-16 21:25:32 +00:00
|
|
|
command = if (System.getProperty("os.name").toLowerCase(Locale.ROOT).contains("windows")) {
|
|
|
|
listOf("powershell", "-Command") + command
|
|
|
|
} else {
|
|
|
|
listOf("bash", "-c", "\"${command.joinToString(" ")}\"")
|
|
|
|
}
|
|
|
|
exec {
|
|
|
|
commandLine(command)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2021-08-26 13:15:14 +00:00
|
|
|
|
|
|
|
tasks.getByName<Test>("test") {
|
|
|
|
useJUnitPlatform()
|
|
|
|
}
|