VIAaaS/build.gradle.kts

166 lines
5.3 KiB
Plaintext
Raw Normal View History

2021-05-14 12:13:49 +02:00
import com.googlecode.htmlcompressor.compressor.HtmlCompressor
2021-05-08 13:51:58 +02:00
import org.gradlewebtools.minify.minifier.js.JSMinifierOptions
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
2021-05-08 14:23:20 +02:00
import java.nio.file.Files as JFiles
2021-05-08 15:56:38 +02:00
buildscript {
repositories { mavenCentral() }
dependencies { classpath("com.github.hazendaz:htmlcompressor:1.7.1") }
}
2020-08-15 23:02:35 +02:00
plugins {
`java-library`
2020-08-15 23:02:35 +02:00
application
2021-07-14 00:05:36 +02:00
kotlin("jvm") version "1.5.21"
2021-02-19 12:34:18 +01:00
id("maven-publish")
2021-05-07 00:16:02 +02:00
id("com.github.johnrengelman.shadow") version "7.0.0"
id("com.github.ben-manes.versions") version "0.39.0"
2021-03-30 16:32:47 +02:00
id("com.palantir.git-version") version "0.12.3"
2021-06-19 14:23:35 +02:00
id("org.gradlewebtools.minify") version "1.2.0" apply false
2020-08-15 23:02:35 +02:00
}
application {
mainClass.set("com.viaversion.aas.VIAaaSKt")
applicationDefaultJvmArgs = listOf("-Dio.ktor.development=true")
2020-08-15 23:02:35 +02:00
}
java {
toolchain {
languageVersion.set(JavaLanguageVersion.of(11))
}
withSourcesJar()
2020-08-15 23:02:35 +02:00
}
val compileKotlin: KotlinCompile by tasks
compileKotlin.kotlinOptions.jvmTarget = "11"
val gitVersion: groovy.lang.Closure<String> by extra
2020-08-15 23:02:35 +02:00
group = "com.github.creeper123123321.viaaas"
2021-07-20 20:26:39 +02:00
version = "0.4.9+" + try {
gitVersion()
} catch (e: Exception) {
"unknown"
}
2020-08-15 23:02:35 +02:00
extra.set("archivesBaseName", "VIAaaS")
repositories {
mavenCentral()
maven("https://oss.sonatype.org/content/repositories/snapshots")
maven("https://repo.viaversion.com/")
2021-02-02 17:06:50 +01:00
maven("https://repo.aikar.co/content/groups/aikar/")
2021-03-26 23:48:48 +01:00
maven("https://jitpack.io")
2021-06-26 01:40:51 +02:00
maven("https://nexus.velocitypowered.com/repository/maven-public/")
2021-05-27 01:56:13 +02:00
mavenLocal()
2020-08-15 23:02:35 +02:00
}
dependencies {
2021-05-08 11:08:08 +02:00
implementation(kotlin("stdlib-jdk8"))
2021-05-17 01:58:25 +02:00
implementation(kotlin("reflect"))
2021-05-08 13:51:58 +02:00
2021-07-07 15:12:29 +02:00
val vvVer = "4.0.2-SNAPSHOT"
val vbVer = "4.0.2-SNAPSHOT"
2021-07-25 18:30:52 +02:00
val vrVer = "18448b0fef"
2021-06-19 14:23:35 +02:00
implementation("com.viaversion:viaversion:$vvVer") { isTransitive = false }
implementation("com.viaversion:viabackwards:$vbVer") { isTransitive = false }
implementation("com.github.ViaVersion.ViaRewind:viarewind-all:$vrVer") { isTransitive = false }
2021-06-08 00:34:24 +02:00
2021-05-19 19:28:17 +02:00
implementation("io.netty:netty-all:4.1.65.Final")
2021-06-25 00:53:59 +02:00
implementation("io.netty:netty-tcnative-boringssl-static:2.0.40.Final")
implementation("com.google.guava:guava:30.1.1-jre")
2021-07-07 15:12:29 +02:00
implementation("com.velocitypowered:velocity-native:3.0.0")
implementation("org.powernukkit.fastutil:fastutil-lite:8.1.1")
implementation("org.yaml:snakeyaml:1.29")
2021-03-30 16:32:47 +02:00
val log4jVer = "2.14.1"
val slf4jVer = "1.7.31"
2021-05-08 11:08:08 +02:00
implementation("net.minecrell:terminalconsoleappender:1.2.0")
implementation("org.apache.logging.log4j:log4j-core:$log4jVer")
implementation("org.apache.logging.log4j:log4j-iostreams:$log4jVer")
implementation("org.apache.logging.log4j:log4j-jul:$log4jVer")
implementation("org.apache.logging.log4j:log4j-slf4j-impl:$log4jVer")
2021-05-19 19:06:13 +02:00
implementation("org.jline:jline-terminal-jansi:3.20.0")
implementation("org.slf4j:slf4j-api:$slf4jVer")
2020-09-20 17:43:26 +02:00
val ktorVersion = "1.6.1"
2020-09-20 17:43:26 +02:00
implementation("io.ktor:ktor-network-tls-certificates:$ktorVersion")
implementation("io.ktor:ktor-websockets:$ktorVersion")
2020-09-20 17:43:26 +02:00
implementation("io.ktor:ktor-server-netty:$ktorVersion")
2021-06-19 14:23:35 +02:00
implementation("io.ktor:ktor-client-gson:$ktorVersion")
implementation("io.ktor:ktor-client-java:$ktorVersion")
2021-02-10 14:27:06 +01:00
implementation("io.ktor:ktor-client-logging-jvm:$ktorVersion")
2020-10-24 22:53:44 +02:00
testImplementation("io.ktor:ktor-server-test-host:$ktorVersion")
2021-07-07 15:12:29 +02:00
implementation("com.auth0:java-jwt:3.18.1")
2020-08-15 23:02:35 +02:00
}
val run: JavaExec by tasks
run.standardInput = System.`in`
project.configurations.implementation.get().isCanBeResolved = true
tasks {
named<com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar>("shadowJar") {
configurations = listOf(project.configurations.implementation.get())
transform(com.github.jengelman.gradle.plugins.shadow.transformers.Log4j2PluginsCacheFileTransformer::class.java)
}
build {
dependsOn(shadowJar)
dependsOn(named("dependencyUpdates"))
}
2021-03-05 22:56:11 +01:00
jar {
manifest.attributes("Multi-Release" to "true")
}
2020-11-06 19:57:56 +01:00
}
2021-05-08 13:51:58 +02:00
class JsMinifyFilter(reader: java.io.Reader) : java.io.FilterReader("".reader()) {
init {
val minifier = org.gradlewebtools.minify.minifier.js.JsMinifier(
minifierOptions = JSMinifierOptions(originalFileNames = true)
)
2021-05-08 14:23:20 +02:00
val file = JFiles.createTempDirectory("via-").resolve("tmp-minify.js").toFile().also {
2021-05-08 13:51:58 +02:00
it.writeText(reader.readText())
}
minifier.minify(file.parentFile, file.parentFile)
`in` = file.readText(Charsets.UTF_8).reader()
file.delete()
2021-05-08 14:23:20 +02:00
file.parentFile.delete()
2021-05-08 13:51:58 +02:00
}
}
2021-05-08 15:56:38 +02:00
class HtmlMinifyFilter(reader: java.io.Reader) : java.io.FilterReader("".reader()) {
init {
`in` = HtmlCompressor().compress(reader.readText()).reader()
}
}
tasks.named<ProcessResources>("processResources") {
filesMatching("viaaas_info.json") {
2021-05-04 22:15:06 +02:00
filter<org.apache.tools.ant.filters.ReplaceTokens>(
"tokens" to mapOf(
"version" to project.property("version")
2021-05-04 22:15:06 +02:00
)
)
}
2021-05-08 13:51:58 +02:00
filesMatching("**/*.js") {
2021-05-08 15:56:38 +02:00
filter<JsMinifyFilter>()
}
filesMatching("**/*.html") {
filter<HtmlMinifyFilter>()
2021-05-08 13:51:58 +02:00
}
}
2020-12-13 20:59:03 +01:00
2021-02-19 12:34:18 +01:00
publishing {
publications {
create<MavenPublication>("maven") {
artifact(tasks.getByName("shadowJar")) {
builtBy(tasks.getByName("shadowJar"))
}
}
}
repositories {
// mavenLocal()
}
}