twigs/app/build.gradle.kts

105 lines
2.7 KiB
Text
Raw Normal View History

import java.net.URI
2021-08-16 21:25:32 +00:00
import java.util.*
plugins {
java
kotlin("jvm")
application
2022-06-03 02:28:44 +00:00
alias(libs.plugins.shadow)
}
repositories {
mavenLocal()
mavenCentral()
maven {
2021-07-06 01:05:25 +00:00
url = URI("https://repo.maven.apache.org/maven2")
}
}
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)
}
description = "twigs-server"
2021-08-12 21:22:06 +00:00
val twigsMain = "com.wbrawner.twigs.server.ApplicationKt"
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-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()
}