diff --git a/api/build.gradle.kts b/api/build.gradle.kts index 3ab8bfe94..1e448d0c2 100644 --- a/api/build.gradle.kts +++ b/api/build.gradle.kts @@ -10,45 +10,32 @@ java { sourceSets["main"].java { srcDir("src/ap/java") } - + sourceSets["main"].resources { srcDir("src/ap/resources") } } -val gsonVersion: String by project.extra -val guiceVersion: String by project.extra -val guavaVersion: String by project.extra -val adventureVersion: String by project.extra -val slf4jVersion: String by project.extra -val checkerFrameworkVersion: String by project.extra -val configurateVersion: String by project.extra -val caffeineVersion: String by project.extra - dependencies { - api("com.google.code.gson:gson:$gsonVersion") - api("com.google.guava:guava:$guavaVersion") + api(libs.gson) + api(libs.guava) // DEPRECATED: Will be removed in Velocity Polymer api("com.moandjiezana.toml:toml4j:0.7.2") - api(platform("net.kyori:adventure-bom:${adventureVersion}")) + api(platform(libs.adventure.bom)) api("net.kyori:adventure-api") api("net.kyori:adventure-text-serializer-gson") api("net.kyori:adventure-text-serializer-legacy") api("net.kyori:adventure-text-serializer-plain") api("net.kyori:adventure-text-minimessage") - api("org.slf4j:slf4j-api:$slf4jVersion") - api("com.google.inject:guice:$guiceVersion") - api("org.checkerframework:checker-qual:${checkerFrameworkVersion}") - api("com.velocitypowered:velocity-brigadier:1.0.0-SNAPSHOT") - - api("org.spongepowered:configurate-hocon:${configurateVersion}") - api("org.spongepowered:configurate-yaml:${configurateVersion}") - api("org.spongepowered:configurate-gson:${configurateVersion}") - - api("com.github.ben-manes.caffeine:caffeine:$caffeineVersion") + api(libs.slf4j) + api(libs.guice) + api(libs.checker.qual) + api(libs.brigadier) + api(libs.bundles.configurate) + api(libs.caffeine) } tasks { @@ -65,12 +52,12 @@ tasks { o.source = "8" o.links( - "https://www.slf4j.org/apidocs/", - "https://guava.dev/releases/$guavaVersion/api/docs/", - "https://google.github.io/guice/api-docs/$guiceVersion/javadoc/", - "https://docs.oracle.com/en/java/javase/11/docs/api/", - "https://jd.advntr.dev/api/$adventureVersion/", - "https://javadoc.io/doc/com.github.ben-manes.caffeine/caffeine" + "https://www.slf4j.org/apidocs/", + "https://guava.dev/releases/${libs.guava.get().version}/api/docs/", + "https://google.github.io/guice/api-docs/${libs.guice.get().version}/javadoc/", + "https://docs.oracle.com/en/java/javase/11/docs/api/", + "https://jd.advntr.dev/api/${libs.adventure.bom.get().version}/", + "https://javadoc.io/doc/com.github.ben-manes.caffeine/caffeine" ) // Disable the crazy super-strict doclint tool in Java 8 diff --git a/build.gradle.kts b/build.gradle.kts index 8b6870d55..f1a64c850 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -6,13 +6,6 @@ plugins { `java-library` } -val junitVersion: String by project.extra - -allprojects { - group = "com.velocitypowered" - version = "3.2.0-SNAPSHOT" -} - subprojects { apply() @@ -31,8 +24,9 @@ subprojects { maven("https://s01.oss.sonatype.org/content/repositories/snapshots/") // adventure maven("https://repo.papermc.io/repository/maven-public/") } + dependencies { - testImplementation("org.junit.jupiter:junit-jupiter:$junitVersion") + testImplementation(rootProject.libs.junit) } tasks { diff --git a/buildSrc/build.gradle.kts b/buildSrc/build.gradle.kts index 50f06b205..95806a655 100644 --- a/buildSrc/build.gradle.kts +++ b/buildSrc/build.gradle.kts @@ -1,17 +1,13 @@ +@Suppress("DSL_SCOPE_VIOLATION") // fixed in Gradle 8.1 plugins { `kotlin-dsl` checkstyle - id("net.kyori.indra.publishing") version "2.0.6" - id("com.diffplug.spotless") version "6.12.0" -} - -repositories { - mavenCentral() - maven("https://plugins.gradle.org/m2") + alias(libs.plugins.indra.publishing) + alias(libs.plugins.spotless) } dependencies { - implementation("com.diffplug.spotless:spotless-plugin-gradle:6.12.0") + implementation("com.diffplug.spotless:spotless-plugin-gradle:${libs.plugins.spotless.get().version}") } gradlePlugin { diff --git a/buildSrc/settings.gradle.kts b/buildSrc/settings.gradle.kts new file mode 100644 index 000000000..0ecd59401 --- /dev/null +++ b/buildSrc/settings.gradle.kts @@ -0,0 +1,11 @@ +dependencyResolutionManagement { + repositories { + mavenCentral() + gradlePluginPortal() + } + versionCatalogs { + register("libs") { + from(files("../gradle/libs.versions.toml")) // include from parent project + } + } +} diff --git a/gradle.properties b/gradle.properties index 395b8d797..0f76ae151 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,26 +1,2 @@ -# API dependencies. -gsonVersion=2.10.1 -junitVersion=5.9.0 -slf4jVersion=1.7.30 -adventureVersion=4.12.0 -guavaVersion=25.1-jre -checkerFrameworkVersion=3.28.0 -configurateVersion=3.7.3 -guiceVersion=5.1.0 - -# Proxy dependencies. -log4jVersion=2.20.0 -nettyVersion=4.1.90.Final -flareVersion=2.0.1 -asyncHttpClientVersion=2.12.3 -bstatsVersion=3.0.1 -caffeineVersion=3.1.5 -lmbdaVersion=2.0.0 -nightConfigVersion=3.6.6 -completableFuturesVersion=0.3.5 -adventureFacetVersion=4.2.0 -fastutilVersion=8.5.12 -disruptorVersion=3.4.4 -jlineVersion=3.23.0 -terminalConsoleAppenderVersion=1.3.0 -joptSimpleVersion=5.0.4 +group=com.velocitypowered +version=3.2.0-SNAPSHOT diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml new file mode 100644 index 000000000..1d3ff2154 --- /dev/null +++ b/gradle/libs.versions.toml @@ -0,0 +1,54 @@ +[versions] +configurate = "3.7.3" +flare = "2.0.1" +log4j = "2.20.0" +netty = "4.1.90.Final" + +[plugins] +indra-publishing = "net.kyori.indra.publishing:2.0.6" +shadow = "com.github.johnrengelman.shadow:8.1.0" +spotless = "com.diffplug.spotless:6.12.0" + +[libraries] +adventure-bom = "net.kyori:adventure-bom:4.12.0" +adventure-facet = "net.kyori:adventure-platform-facet:4.2.0" +asynchttpclient = "org.asynchttpclient:async-http-client:2.12.3" +brigadier = "com.velocitypowered:velocity-brigadier:1.0.0-SNAPSHOT" +bstats = "org.bstats:bstats-base:3.0.1" +caffeine = "com.github.ben-manes.caffeine:caffeine:3.1.5" +checker-qual = "org.checkerframework:checker-qual:3.28.0" +completablefutures = "com.spotify:completable-futures:0.3.5" +configurate-hocon = { module = "org.spongepowered:configurate-hocon", version.ref = "configurate" } +configurate-yaml = { module = "org.spongepowered:configurate-yaml", version.ref = "configurate" } +configurate-gson = { module = "org.spongepowered:configurate-gson", version.ref = "configurate" } +disruptor = "com.lmax:disruptor:3.4.4" +fastutil = "it.unimi.dsi:fastutil:8.5.12" +flare-core = { module = "space.vectrix.flare:flare", version.ref = "flare" } +flare-fastutil = { module = "space.vectrix.flare:flare-fastutil", version.ref = "flare" } +jline = "org.jline:jline-terminal-jansi:3.23.0" +jopt = "net.sf.jopt-simple:jopt-simple:5.0.4" +junit = "org.junit.jupiter:junit-jupiter:5.9.0" +guava = "com.google.guava:guava:25.1-jre" +gson = "com.google.code.gson:gson:2.10.1" +guice = "com.google.inject:guice:5.1.0" +lmbda = "org.lanternpowered:lmbda:2.0.0" +log4j-api = { module = "org.apache.logging.log4j:log4j-api", version.ref = "log4j" } +log4j-core = { module = "org.apache.logging.log4j:log4j-core", version.ref = "log4j" } +log4j-slf4j-impl = { module = "org.apache.logging.log4j:log4j-slf4j-impl", version.ref = "log4j" } +log4j-iostreams = { module = "org.apache.logging.log4j:log4j-iostreams", version.ref = "log4j" } +log4j-jul = { module = "org.apache.logging.log4j:log4j-jul", version.ref = "log4j" } +mockito = "org.mockito:mockito-core:5.2.0" +netty-codec = { module = "io.netty:netty-codec", version.ref = "netty" } +netty-codec-haproxy = { module = "io.netty:netty-codec-haproxy", version.ref = "netty" } +netty-codec-http = { module = "io.netty:netty-codec-http", version.ref = "netty" } +netty-handler = { module = "io.netty:netty-handler", version.ref = "netty" } +netty-transport-native-epoll = { module = "io.netty:netty-transport-native-epoll", version.ref = "netty" } +nightconfig = "com.electronwill.night-config:toml:3.6.6" +slf4j = "org.slf4j:slf4j-api:1.7.30" +spotbugs-annotations = "com.github.spotbugs:spotbugs-annotations:4.7.3" +terminalconsoleappender = "net.minecrell:terminalconsoleappender:1.3.0" + +[bundles] +configurate = ["configurate-hocon", "configurate-yaml", "configurate-gson"] +flare = ["flare-core", "flare-fastutil"] +log4j = ["log4j-api", "log4j-core", "log4j-slf4j-impl", "log4j-iostreams", "log4j-jul"] diff --git a/native/build.gradle.kts b/native/build.gradle.kts index eb381692d..165cb30f9 100644 --- a/native/build.gradle.kts +++ b/native/build.gradle.kts @@ -3,12 +3,8 @@ plugins { `maven-publish` } -val guavaVersion: String by project.extra -val nettyVersion: String by project.extra -val checkerFrameworkVersion: String by project.extra - dependencies { - implementation("com.google.guava:guava:${guavaVersion}") - implementation("io.netty:netty-handler:${nettyVersion}") - implementation("org.checkerframework:checker-qual:${checkerFrameworkVersion}") -} \ No newline at end of file + implementation(libs.guava) + implementation(libs.netty.handler) + implementation(libs.checker.qual) +} diff --git a/proxy/build.gradle.kts b/proxy/build.gradle.kts index 6d94c5675..486e1f7bd 100644 --- a/proxy/build.gradle.kts +++ b/proxy/build.gradle.kts @@ -1,9 +1,10 @@ import com.github.jengelman.gradle.plugins.shadow.transformers.Log4j2PluginsCacheFileTransformer +@Suppress("DSL_SCOPE_VIOLATION") // fixed in Gradle 8.1 plugins { application `set-manifest-impl-version` - id("com.github.johnrengelman.shadow") version "8.1.0" + alias(libs.plugins.shadow) } application { @@ -88,65 +89,33 @@ tasks { } } -val adventureVersion: String by project.extra -val adventureFacetVersion: String by project.extra -val asyncHttpClientVersion: String by project.extra -val bstatsVersion: String by project.extra -val completableFuturesVersion: String by project.extra -val disruptorVersion: String by project.extra -val fastutilVersion: String by project.extra -val flareVersion: String by project.extra -val jlineVersion: String by project.extra -val joptSimpleVersion: String by project.extra -val lmbdaVersion: String by project.extra -val log4jVersion: String by project.extra -val nettyVersion: String by project.extra -val nightConfigVersion: String by project.extra -val semver4jVersion: String by project.extra -val terminalConsoleAppenderVersion: String by project.extra - dependencies { implementation(project(":velocity-api")) implementation(project(":velocity-native")) - implementation("io.netty:netty-codec:${nettyVersion}") - implementation("io.netty:netty-codec-haproxy:${nettyVersion}") - implementation("io.netty:netty-codec-http:${nettyVersion}") - implementation("io.netty:netty-handler:${nettyVersion}") - implementation("io.netty:netty-transport-native-epoll:${nettyVersion}") - implementation("io.netty:netty-transport-native-epoll:${nettyVersion}:linux-x86_64") - implementation("io.netty:netty-transport-native-epoll:${nettyVersion}:linux-aarch_64") + implementation(libs.bundles.log4j) + implementation(libs.netty.codec) + implementation(libs.netty.codec.haproxy) + implementation(libs.netty.codec.http) + implementation(libs.netty.handler) + implementation(libs.netty.transport.native.epoll) + implementation(variantOf(libs.netty.transport.native.epoll) { classifier("linux-x86_64") }) + implementation(variantOf(libs.netty.transport.native.epoll) { classifier("linux-aarch_64") }) - implementation("org.apache.logging.log4j:log4j-api:${log4jVersion}") - implementation("org.apache.logging.log4j:log4j-core:${log4jVersion}") - implementation("org.apache.logging.log4j:log4j-slf4j-impl:${log4jVersion}") - implementation("org.apache.logging.log4j:log4j-iostreams:${log4jVersion}") - implementation("org.apache.logging.log4j:log4j-jul:${log4jVersion}") - - implementation("net.sf.jopt-simple:jopt-simple:$joptSimpleVersion") // command-line options - implementation("net.minecrell:terminalconsoleappender:$terminalConsoleAppenderVersion") - runtimeOnly("org.jline:jline-terminal-jansi:$jlineVersion") // Needed for JLine - runtimeOnly("com.lmax:disruptor:$disruptorVersion") // Async loggers - - implementation("it.unimi.dsi:fastutil-core:$fastutilVersion") - - implementation(platform("net.kyori:adventure-bom:$adventureVersion")) + implementation(libs.jopt) + implementation(libs.terminalconsoleappender) + runtimeOnly(libs.jline) + runtimeOnly(libs.disruptor) + implementation(libs.fastutil) + implementation(platform(libs.adventure.bom)) implementation("net.kyori:adventure-nbt") - implementation("net.kyori:adventure-platform-facet:$adventureFacetVersion") - - implementation("org.asynchttpclient:async-http-client:$asyncHttpClientVersion") - - implementation("com.spotify:completable-futures:$completableFuturesVersion") - - implementation("com.electronwill.night-config:toml:$nightConfigVersion") - - implementation("org.bstats:bstats-base:$bstatsVersion") - implementation("org.lanternpowered:lmbda:$lmbdaVersion") - - implementation("space.vectrix.flare:flare:$flareVersion") - implementation("space.vectrix.flare:flare-fastutil:$flareVersion") - - compileOnly("com.github.spotbugs:spotbugs-annotations:4.7.3") - - testImplementation("org.mockito:mockito-core:3.+") + implementation(libs.adventure.facet) + implementation(libs.asynchttpclient) + implementation(libs.completablefutures) + implementation(libs.nightconfig) + implementation(libs.bstats) + implementation(libs.lmbda) + implementation(libs.bundles.flare) + compileOnly(libs.spotbugs.annotations) + testImplementation(libs.mockito) } diff --git a/settings.gradle.kts b/settings.gradle.kts index d93eda7a7..b8d700802 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -1,19 +1,15 @@ -pluginManagement { - repositories { - gradlePluginPortal() - } -} - plugins { id("org.gradle.toolchains.foojay-resolver-convention") version "0.4.0" } rootProject.name = "velocity" -include( - "api", - "proxy", - "native" -) -findProject(":api")?.name = "velocity-api" -findProject(":proxy")?.name = "velocity-proxy" -findProject(":native")?.name = "velocity-native" \ No newline at end of file + +sequenceOf( + "api", + "proxy", + "native", +).forEach { + val project = ":velocity-$it" + include(project) + project(project).projectDir = file(it) +}