Skip to content

Commit

Permalink
chore(build): move dependency declarations to version catalogs
Browse files Browse the repository at this point in the history
  • Loading branch information
zml2008 committed Jan 24, 2024
1 parent a20506c commit 78f1e5b
Show file tree
Hide file tree
Showing 8 changed files with 156 additions and 121 deletions.
63 changes: 27 additions & 36 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -6,27 +6,19 @@ plugins {
`java-library`
eclipse
id("org.spongepowered.gradle.vanilla")
id("com.github.johnrengelman.shadow")
id("org.spongepowered.gradle.sponge.dev") apply false // for version json generation
id("net.kyori.indra.licenser.spotless")
alias(libs.plugins.shadow)
alias(apiLibs.plugins.spongeGradle.convention) apply false // for version json generation
alias(libs.plugins.indra.licenserSpotless) version apiLibs.versions.indra.get()
id("implementation-structure")
id("org.jetbrains.gradle.plugin.idea-ext")
id("com.github.ben-manes.versions")
id(apiLibs.plugins.ideaExt.get().pluginId)
alias(libs.plugins.versions)
}

val commonProject = project
val apiVersion: String by project
val minecraftVersion: String by project
val recommendedVersion: String by project

val guavaVersion: String by project
val asmVersion: String by project
val log4jVersion: String by project
val modlauncherVersion: String by project
val mixinVersion: String by project
val junitVersion: String by project
val mockitoVersion: String by project

val commonManifest = java.manifest {
attributes(
"Specification-Title" to "Sponge",
Expand Down Expand Up @@ -158,21 +150,21 @@ dependencies {
api("org.spongepowered:spongeapi:$apiVersion")

// Database stuffs... likely needs to be looked at
implementation("com.zaxxer:HikariCP:2.6.3") {
implementation(libs.db.hikariCp) {
exclude(group = "org.slf4j", module = "slf4j-api")
}
implementation("org.mariadb.jdbc:mariadb-java-client:2.0.3")
implementation("com.h2database:h2:1.4.196")
implementation("org.xerial:sqlite-jdbc:3.20.0")
implementation("javax.inject:javax.inject:1")
implementation(libs.db.maria)
implementation(libs.db.h2)
implementation(libs.db.sqlite)
implementation(libs.javaxInject)

// ASM - required for generating event listeners
implementation("org.ow2.asm:asm-util:$asmVersion")
implementation("org.ow2.asm:asm-tree:$asmVersion")
implementation(libs.asm.util)
implementation(libs.asm.tree)

// Implementation-only Adventure
implementation(platform(apiLibs.adventure.bom))
implementation("net.kyori:adventure-serializer-configurate4") {
implementation(libs.adventure.serializerConfigurate4) {
exclude(group = "org.jetbrains", module = "annotations")
exclude(group = "org.checkerframework", module = "checker-qual")
}
Expand All @@ -184,23 +176,23 @@ dependencies {
exclude(group = "com.google.code.gson", module = "gson")
exclude(group = "org.apache.logging.log4j", module = "log4j-api")
}
launchConfig("org.spongepowered:mixin:$mixinVersion")
launchConfig(libs.mixin)
launchConfig(apiLibs.checkerQual)
launchConfig("com.google.guava:guava:$guavaVersion") {
launchConfig(libs.guava) {
exclude(group = "com.google.code.findbugs", module = "jsr305") // We don't want to use jsr305, use checkerframework
exclude(group = "org.checkerframework", module = "checker-qual") // We use our own version
exclude(group = "com.google.j2objc", module = "j2objc-annotations")
exclude(group = "org.codehaus.mojo", module = "animal-sniffer-annotations")
exclude(group = "com.google.errorprone", module = "error_prone_annotations")
}
launchConfig(apiLibs.gson)
launchConfig("org.ow2.asm:asm-tree:$asmVersion")
launchConfig("org.ow2.asm:asm-util:$asmVersion")
launchConfig(libs.asm.tree)
launchConfig(libs.asm.util)

// Applaunch -- initialization that needs to occur without game access
applaunchConfig(apiLibs.checkerQual)
applaunchConfig("org.apache.logging.log4j:log4j-api:$log4jVersion")
applaunchConfig("com.google.guava:guava:$guavaVersion"){
applaunchConfig(libs.log4j.api)
applaunchConfig(libs.guava){
exclude(group = "com.google.errorprone", module = "error_prone_annotations")
exclude(group = "org.checkerframework", module = "checker-qual")
}
Expand All @@ -212,14 +204,14 @@ dependencies {
exclude(group = "org.spongepowered", module = "configurate-core")
exclude(group = "org.checkerframework", module = "checker-qual") // We use our own version
}
applaunchConfig("org.spongepowered:configurate-jackson") {
applaunchConfig(libs.configurate.jackson) {
exclude(group = "org.spongepowered", module = "configurate-core")
exclude(group = "org.checkerframework", module = "checker-qual") // We use our own version
}
applaunchConfig("org.apache.logging.log4j:log4j-core:$log4jVersion")
applaunchConfig("org.apache.logging.log4j:log4j-jpl:$log4jVersion")
applaunchConfig(libs.log4j.core)
applaunchConfig(libs.log4j.jpl)

mixinsConfig(sourceSets.named("main").map { it.output })
mixinsConfig(sourceSets.main.map { it.output })
add(mixins.get().implementationConfigurationName, "org.spongepowered:spongeapi:$apiVersion")

// Tests
Expand All @@ -229,11 +221,11 @@ dependencies {
testRuntimeOnly(apiLibs.junit.engine)
testRuntimeOnly(apiLibs.junit.launcher)

testImplementation("org.mockito:mockito-core:$mockitoVersion")
testImplementation("org.mockito:mockito-junit-jupiter:$mockitoVersion") {
testImplementation(libs.mockito.core)
testImplementation(libs.mockito.junitJupiter) {
exclude(group = "org.junit.jupiter", module = "junit-jupiter-api")
}
testImplementation("org.mockito:mockito-inline:$mockitoVersion")
testImplementation(libs.mockito.inline)
}

val organization: String by project
Expand Down Expand Up @@ -277,7 +269,6 @@ allprojects {
}

plugins.withId("org.spongepowered.gradle.vanilla") {
val vineflowerVersion: String by project
minecraft {
version(minecraftVersion)
injectRepositories(false)
Expand All @@ -291,7 +282,7 @@ allprojects {
}

dependencies {
decompiler("org.vineflower:vineflower:$vineflowerVersion")
decompiler(libs.vineflower)
}

tasks.named("decompile", DecompileJarTask::class) {
Expand Down
25 changes: 10 additions & 15 deletions forge/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ buildscript {
}

plugins {
id("com.github.johnrengelman.shadow")
alias(libs.plugins.shadow)
id("implementation-structure")
id("templated-resources")
id("net.smoofyuniverse.loom") version "1.1-SNAPSHOT"
Expand Down Expand Up @@ -210,11 +210,6 @@ dependencies {
}
})

val apiAdventureVersion: String by project
val apiConfigurateVersion: String by project
val apiPluginSpiVersion: String by project
val log4jVersion: String by project

api(project(":", configuration = "launch")) {
exclude(group = "org.spongepowered", module = "mixin")
}
Expand All @@ -228,27 +223,27 @@ dependencies {
forgeMixins.implementationConfigurationName(project(commonProject.path))

val serviceLibraries = serviceLibrariesConfig.name
serviceLibraries("org.spongepowered:plugin-spi:$apiPluginSpiVersion")
serviceLibraries(apiLibs.pluginSpi)
serviceLibraries(project(transformersProject.path))
serviceLibraries(platform("org.spongepowered:configurate-bom:$apiConfigurateVersion"))
serviceLibraries("org.spongepowered:configurate-core") {
serviceLibraries(platform(apiLibs.configurate.bom))
serviceLibraries(apiLibs.configurate.core) {
exclude(group = "org.checkerframework", module = "checker-qual")
}
serviceLibraries("org.spongepowered:configurate-hocon") {
serviceLibraries(apiLibs.configurate.hocon) {
exclude(group = "org.spongepowered", module = "configurate-core")
exclude(group = "org.checkerframework", module = "checker-qual")
}
serviceLibraries("org.spongepowered:configurate-jackson") {
serviceLibraries(libs.configurate.jackson) {
exclude(group = "org.spongepowered", module = "configurate-core")
exclude(group = "org.checkerframework", module = "checker-qual")
}

val gameLibraries = gameLibrariesConfig.name
gameLibraries("org.spongepowered:spongeapi:$apiVersion")
gameLibraries("javax.inject:javax.inject:1")
gameLibraries("com.zaxxer:HikariCP:2.7.8")
gameLibraries(platform("net.kyori:adventure-bom:$apiAdventureVersion"))
gameLibraries("net.kyori:adventure-serializer-configurate4")
gameLibraries(libs.javaxInject)
gameLibraries(libs.db.hikariCp)
gameLibraries(platform(apiLibs.adventure.bom))
gameLibraries(libs.adventure.serializerConfigurate4)

val serviceShadedLibraries = serviceShadedLibrariesConfig.name
serviceShadedLibraries(project(transformersProject.path)) { isTransitive = false }
Expand Down
14 changes: 7 additions & 7 deletions generator/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,16 +18,16 @@ minecraft {
}

configurations.configureEach {
exclude(group = "org.apache.logging.log4j", module = "log4j-slf4j2-impl")
val dep = libs.log4j.slf4j2.get()
exclude(group = dep.group, module = dep.name)
}

dependencies {
val tinyLogVersion: String by project
implementation("com.squareup:javapoet:1.13.0")
implementation("com.github.javaparser:javaparser-core:3.24.4")
implementation("org.tinylog:tinylog-api:$tinyLogVersion")
runtimeOnly("org.tinylog:tinylog-impl:$tinyLogVersion")
runtimeOnly("org.tinylog:slf4j-tinylog:$tinyLogVersion")
implementation(libs.javapoet)
implementation(libs.javaparser)
implementation(libs.tinylog.api)
runtimeOnly(libs.tinylog.impl)
runtimeOnly(libs.tinylog.slf4j)
}

indraSpotlessLicenser {
Expand Down
10 changes: 0 additions & 10 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,6 @@ superClassChanges=common.superclasschange

minecraftVersion=1.20.2
recommendedVersion=0-SNAPSHOT
asmVersion=9.6
log4jVersion=2.19.0
forgeAutoRenamingToolVersion=1.0.6
mixinVersion=0.8.5
modlauncherVersion=8.1.3
guavaVersion=32.1.2-jre
mockitoVersion=4.8.0
jlineVersion=3.25.1
tinyLogVersion=2.6.2
vineflowerVersion=1.9.3

org.gradle.jvmargs=-Xss4m
org.gradle.parallel=true
Expand Down
72 changes: 72 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
[metadata]
format = { version = "1.1" }

# Implementation-only dependencies, or dependencies that use a different version than in API
# See SpongeAPI's gradle/libs.versions.toml for many dependency declarations that Sponge also uses
[versions]
asm = "9.6"
log4j = "2.19.0"
forgeAutoRenamingTool = "1.0.6"
mixin = "0.8.5"
modlauncher = "8.1.3"
guava = "32.1.2-jre"
mockito = "4.8.0"
jline = "3.25.1"
tinylog = "2.6.2"
vineflower = "1.9.3"

[libraries]
# common
asm = { module = "org.ow2.asm:asm", version.ref = "asm" }
asm-analysis = { module = "org.ow2.asm:asm-analysis", version.ref = "asm" }
asm-commons = { module = "org.ow2.asm:asm-commons", version.ref = "asm" }
asm-util = { module = "org.ow2.asm:asm-util", version.ref = "asm" }
asm-tree = { module = "org.ow2.asm:asm-tree", version.ref = "asm" }
grossJava9Hacks = { module = "cpw.mods:grossjava9hacks", version = "1.3.3" }
joptSimple = { module = "net.sf.jopt-simple:jopt-simple", version = "5.0.4" }
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-jpl = { module = "org.apache.logging.log4j:log4j-jpl", version.ref = "log4j" }
log4j-slf4j2 = { module = "org.apache.logging.log4j:log4j-slf4j2-impl", version.ref = "log4j" }
modlauncher = { module = "cpw.mods:modlauncher", version.ref = "modlauncher" }
tinylog-api = { module = "org.tinylog:tinylog-api", version.ref = "tinylog" }
tinylog-impl = { module = "org.tinylog:tinylog-impl", version.ref = "tinylog" }
tinylog-slf4j = { module = "org.tinylog:slf4j-tinylog", version.ref = "tinylog" }

# generator
javaparser = { module = "com.github.javaparser:javaparser-core", version = "3.24.4" }
javapoet = { module = "com.squareup:javapoet", version = "1.13.0" }

# modlauncher-transformers
accessWidener = { module = "net.fabricmc:access-widener", version = "2.1.0" }

# Sponge
adventure-serializerConfigurate4 = { module = "net.kyori:adventure-serializer-configurate4" }
configurate-jackson = { module = "org.spongepowered:configurate-jackson" }
db-h2 = { module = "com.h2database:h2", version = "1.4.196" }
db-hikariCp = { module = "com.zaxxer:HikariCP", version = "2.6.3" }
db-maria = { module = "org.mariadb.jdbc:mariadb-java-client", version = "2.0.3" }
db-sqlite = { module = "org.xerial:sqlite-jdbc", version = "3.20.0" }
guava = { module = "com.google.guava:guava", version.ref = "guava" }
javaxInject = { module = "javax.inject:javax.inject", version = "1" }
mixin = { module = "org.spongepowered:mixin", version.ref = "mixin" }
mockito-core = { module = "org.mockito:mockito-core", version.ref = "mockito" }
mockito-inline = { module = "org.mockito:mockito-inline", version.ref = "mockito" }
mockito-junitJupiter = { module = "org.mockito:mockito-junit-jupiter", version.ref = "mockito" }

# vanilla
forgeAutoRenamingTool = { module = "net.minecraftforge:ForgeAutoRenamingTool", version.ref = "forgeAutoRenamingTool" }
jline-reader = { module = "org.jline:jline-reader", version.ref = "jline" }
jline-terminal = { module = "org.jline:jline-terminal", version.ref = "jline" }
jline-terminalJansi = { module = "org.jline:jline-terminal-jansi", version.ref = "jline" }
lmaxDisruptor = { module = "com.lmax:disruptor", version = "3.4.4" }
terminalConsoleAppender = { module = "net.minecrell:terminalconsoleappender", version = "1.3.0" }

# buildtime-only
vineflower = { module = "org.vineflower:vineflower", version.ref = "vineflower" }

[plugins]
vanillaGradle = { id = "org.spongepowered.gradle.vanilla" }
shadow = { id = "com.github.johnrengelman.shadow", version = "8.1.1" }
indra-licenserSpotless = { id = "net.kyori.indra.licenser.spotless", version = "3.1.3" }
versions = { id = "com.github.ben-manes.versions", version = "0.51.0" }
2 changes: 1 addition & 1 deletion modlauncher-patcher/build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
dependencies {
implementation "org.ow2.asm:asm:$asmVersion"
implementation libs.asm
}

// Make sure jar is present for other projects
Expand Down
17 changes: 7 additions & 10 deletions modlauncher-transformers/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -19,26 +19,23 @@ indraSpotlessLicenser {
property("url", projectUrl)
}

val asmVersion: String by project
val log4jVersion: String by project
val modlauncherVersion: String by project

dependencies {
// AccessWidener transformer
implementation("net.fabricmc:access-widener:2.1.0") {
implementation(libs.accessWidener) {
exclude(group="org.apache.logging.log4j")
}
// ModLauncher inherited dependencies - strictly should be provided by
// the platform making use of this project
compileOnly("org.apache.logging.log4j:log4j-api:$log4jVersion")
compileOnly("cpw.mods:modlauncher:$modlauncherVersion") {
compileOnly(libs.log4j.api)
compileOnly(libs.modlauncher) {
exclude(group = "org.apache.logging.log4j")
exclude(group = "net.sf.jopt-simple") // uses a newer version than MC
}

compileOnly("net.sf.jopt-simple:jopt-simple:5.0.4")
compileOnly("org.ow2.asm:asm-commons:$asmVersion")
compileOnly("cpw.mods:grossjava9hacks:1.3.3") {
compileOnly(libs.joptSimple)
compileOnly(libs.asm.commons)
compileOnly(libs.grossJava9Hacks) {
exclude(group="org.apache.logging.log4j")
}
// Configurate dependencies, also to be provided by the platform
Expand All @@ -47,7 +44,7 @@ dependencies {
compileOnly(apiLibs.configurate.core) {
exclude(group = "org.checkerframework", module="checker-qual") // We use our own version
}
compileOnly("org.spongepowered:configurate-jackson") {
compileOnly(libs.configurate.jackson) {
exclude(group="org.spongepowered", module="configurate-core")
exclude(group="org.checkerframework", module="checker-qual") // We use our own version
}
Expand Down
Loading

0 comments on commit 78f1e5b

Please sign in to comment.