twigs/app/build.gradle.kts

109 lines
3 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
2021-08-12 21:22:06 +00:00
id("com.github.johnrengelman.shadow") version "7.0.0"
}
repositories {
mavenLocal()
mavenCentral()
maven {
2021-07-06 01:05:25 +00:00
url = URI("https://repo.maven.apache.org/maven2")
}
}
val kotlinVersion: String by rootProject.extra
2021-07-29 00:49:48 +00:00
val ktorVersion: String by rootProject.extra
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"))
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:$kotlinVersion")
implementation("org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion")
2021-07-06 01:08:09 +00:00
implementation("io.ktor:ktor-server-core:$ktorVersion")
implementation("io.ktor:ktor-server-cio:$ktorVersion")
2021-08-06 01:35:42 +00:00
implementation("io.ktor:ktor-server-sessions:$ktorVersion")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0")
2021-07-06 01:08:09 +00:00
implementation("ch.qos.logback:logback-classic:1.2.3")
2021-08-26 13:15:14 +00:00
testImplementation(project(":testhelpers"))
testImplementation("org.junit.jupiter:junit-jupiter-api:5.6.0")
testRuntimeOnly("org.junit.jupiter: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()
}