VIAaaS/build.gradle.kts

191 lines
6.8 KiB
Plaintext
Raw Normal View History

2022-10-09 17:30:39 +02:00
import com.github.jengelman.gradle.plugins.shadow.tasks.ShadowJar
import com.github.jengelman.gradle.plugins.shadow.transformers.Log4j2PluginsCacheFileTransformer
2021-10-30 12:53:07 +02:00
import com.google.javascript.jscomp.CompilerOptions.LanguageMode
2021-05-14 12:13:49 +02:00
import com.googlecode.htmlcompressor.compressor.HtmlCompressor
2021-08-19 01:20:57 +02:00
import org.gradlewebtools.minify.minifier.js.JsMinifier
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:2.0.0") }
2021-05-08 15:56:38 +02:00
}
2020-08-15 23:02:35 +02:00
plugins {
`java-library`
2020-08-15 23:02:35 +02:00
application
kotlin("jvm") version "1.9.22"
2021-02-19 12:34:18 +01:00
id("maven-publish")
id("com.github.ben-manes.versions") version "0.50.0"
id("com.github.johnrengelman.shadow") version "8.1.1"
id("com.palantir.git-version") version "3.0.0"
2023-01-04 12:32:43 +01:00
id("org.gradlewebtools.minify") version "1.3.2" apply false
2020-08-15 23:02:35 +02:00
}
application {
mainClass.set("com.viaversion.aas.VIAaaSKt")
2020-08-15 23:02:35 +02:00
}
java {
toolchain {
2024-01-19 23:57:54 +01:00
languageVersion.set(JavaLanguageVersion.of(17))
vendor.set(JvmVendorSpec.ADOPTIUM)
}
withSourcesJar()
2020-08-15 23:02:35 +02:00
}
val compileKotlin: KotlinCompile by tasks
2024-01-19 23:57:54 +01:00
compileKotlin.kotlinOptions.jvmTarget = "17"
val gitVersion: groovy.lang.Closure<String> by extra
group = "com.viaversion.aas"
2023-01-22 21:48:43 +01:00
version = "0.4.19+" + try {
gitVersion()
} catch (e: Exception) {
"unknown"
}
2020-08-15 23:02:35 +02:00
extra.set("archivesBaseName", "VIAaaS")
repositories {
mavenCentral()
maven("https://repo.viaversion.com/")
2022-06-17 01:42:37 +02:00
maven("https://repo.papermc.io/repository/maven-public/")
2021-10-30 12:53:07 +02:00
maven("https://jitpack.io/")
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
2024-01-26 15:33:19 +01:00
val vvVer = "4.10.0-24w04a-SNAPSHOT"
val vbVer = "4.10.0-24w04a-SNAPSHOT"
val vrVer = "3.0.6-SNAPSHOT"
2021-06-19 14:23:35 +02:00
implementation("com.viaversion:viaversion:$vvVer") { isTransitive = false }
implementation("com.viaversion:viabackwards:$vbVer") { isTransitive = false }
implementation("com.viaversion:viarewind-universal:$vrVer") { isTransitive = false }
2023-12-07 14:01:47 +01:00
implementation("net.raphimc:ViaAprilFools:2.0.11-SNAPSHOT")
implementation("net.raphimc:ViaLegacy:2.2.22-SNAPSHOT")
2021-06-08 00:34:24 +02:00
2024-01-19 23:05:25 +01:00
val nettyVer = "4.1.105.Final"
2022-09-29 01:14:24 +02:00
implementation("io.netty:netty-handler-proxy:$nettyVer")
implementation("io.netty:netty-resolver-dns:$nettyVer")
implementation("io.netty:netty-transport-native-epoll:$nettyVer:linux-aarch_64")
implementation("io.netty:netty-transport-native-epoll:$nettyVer:linux-x86_64")
implementation("io.netty:netty-tcnative-boringssl-static:2.0.62.Final:linux-aarch_64")
implementation("io.netty:netty-tcnative-boringssl-static:2.0.62.Final:linux-x86_64")
implementation("io.netty.incubator:netty-incubator-transport-native-io_uring:0.0.23.Final:linux-aarch_64")
implementation("io.netty.incubator:netty-incubator-transport-native-io_uring:0.0.23.Final:linux-x86_64")
implementation("com.google.guava:guava:33.0.0-jre")
implementation("com.velocitypowered:velocity-native:3.3.0-SNAPSHOT")
implementation("net.coobird:thumbnailator:0.4.20")
implementation("org.powernukkit.fastutil:fastutil-lite:8.1.1")
implementation("org.yaml:snakeyaml:2.2")
val log4jVer = "2.22.1"
val slf4jVer = "2.0.11"
implementation("com.lmax:disruptor:3.4.4")
2021-09-08 00:28:35 +02:00
implementation("net.minecrell:terminalconsoleappender:1.3.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")
2022-09-28 21:14:09 +02:00
implementation("org.apache.logging.log4j:log4j-slf4j2-impl:$log4jVer")
implementation("org.jline:jline-terminal-jansi:3.25.0")
implementation("org.slf4j:slf4j-api:$slf4jVer")
2020-09-20 17:43:26 +02:00
val ktorVersion = "2.3.7"
2022-04-16 23:00:35 +02:00
implementation("io.ktor:ktor-network-tls-certificates-jvm:$ktorVersion")
2022-01-31 13:24:56 +01:00
implementation("io.ktor:ktor-server-websockets:$ktorVersion")
2022-04-16 23:00:35 +02:00
implementation("io.ktor:ktor-server-netty-jvm:$ktorVersion")
2022-01-31 13:24:56 +01:00
implementation("io.ktor:ktor-server-caching-headers:$ktorVersion")
implementation("io.ktor:ktor-server-call-logging:$ktorVersion")
implementation("io.ktor:ktor-server-compression:$ktorVersion")
2022-08-21 17:11:12 +02:00
implementation("io.ktor:ktor-server-config-yaml:$ktorVersion")
2022-01-31 13:24:56 +01:00
implementation("io.ktor:ktor-server-content-negotiation:$ktorVersion")
implementation("io.ktor:ktor-server-default-headers:$ktorVersion")
implementation("io.ktor:ktor-server-forwarded-header:$ktorVersion")
implementation("io.ktor:ktor-server-partial-content:$ktorVersion")
implementation("io.ktor:ktor-serialization-gson:$ktorVersion")
2022-04-16 23:00:35 +02:00
implementation("io.ktor:ktor-client-java-jvm:$ktorVersion")
2022-01-31 13:24:56 +01:00
implementation("io.ktor:ktor-client-content-negotiation:$ktorVersion")
2021-02-10 14:27:06 +01:00
implementation("io.ktor:ktor-client-logging-jvm:$ktorVersion")
2022-04-16 23:00:35 +02:00
testImplementation("io.ktor:ktor-server-test-host-jvm:$ktorVersion")
implementation("com.auth0:java-jwt:4.4.0")
2020-08-15 23:02:35 +02:00
}
val run: JavaExec by tasks
run.standardInput = System.`in`
project.configurations.implementation.get().isCanBeResolved = true
tasks {
2022-10-09 17:30:39 +02:00
named<ShadowJar>("shadowJar") {
configurations = listOf(project.configurations.implementation.get())
2022-10-09 17:30:39 +02:00
transform(Log4j2PluginsCacheFileTransformer::class.java)
}
build {
dependsOn(shadowJar)
}
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()) {
2021-10-30 12:53:07 +02:00
companion object {
val minifier = JsMinifier(
minifierOptions = JsMinifierOptions(
originalFileNames = true,
languageOut = LanguageMode.ECMASCRIPT_2020,
rewritePolyfills = true
)
)
}
2021-05-08 13:51:58 +02:00
init {
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.version)
2021-05-04 22:15:06 +02:00
)
}
2021-05-08 13:51:58 +02:00
filesMatching("**/*.js") {
2021-10-30 12:53:07 +02:00
filter<JsMinifyFilter>()
2021-05-08 15:56:38 +02:00
}
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()
}
}