This project uses Gradle Version Catalogs for centralized dependency version management across all modules. This prevents version conflicts and makes it easy to update dependencies consistently.
The version catalog is located at: gradle/libs.versions.toml
All dependency versions are defined once in the [versions] section:
[versions]
jda = "6.0.0"
lombok = "1.18.34"
logback = "1.5.13"
# ... etcIndividual dependencies reference versions using version.ref:
[libraries]
jda = { module = "net.dv8tion:JDA", version.ref = "jda" }
lombok = { module = "org.projectlombok:lombok", version.ref = "lombok" }Related dependencies can be grouped into bundles:
[bundles]
logging = ["logback-classic", "logback-core", "slf4j-api"]
database = ["jooq", "jooq-meta", "jooq-codegen", "postgresql", "hikaricp"]Build plugins are also managed centrally:
[plugins]
spotless = { id = "com.diffplug.spotless", version.ref = "spotless" }
shadow = { id = "com.github.johnrengelman.shadow", version.ref = "shadowPlugin" }dependencies {
implementation(libs.jda)
compileOnly(libs.lombok)
implementation(libs.okhttp)
}dependencies {
implementation(libs.bundles.logging)
implementation(libs.bundles.database)
implementation(libs.bundles.google)
}plugins {
id("java")
alias(libs.plugins.spotless)
alias(libs.plugins.shadow)
}- Use hyphens for multi-word keys:
google-sheets-api,sysout-over-slf4j - Version refs use camelCase:
version.ref = "googleSheetsApi"
- Access with dots:
libs.google.sheets.api - Hyphens become dots:
google-sheets-api→libs.google.sheets.api - Underscores also become dots:
sysout_over_slf4j→libs.sysout.over.slf4j
All versions are defined in one place (libs.versions.toml), making it easy to:
- See all dependencies and their versions at a glance
- Update a version once and have it apply everywhere
- Prevent version conflicts between modules
Gradle generates type-safe accessors, providing:
- IDE auto-completion
- Compile-time validation
- Refactoring support
Build plugins are also versioned centrally, ensuring consistency across:
- Root project
- All submodules
To update a dependency:
- Edit the version in
libs.versions.toml - Sync Gradle
- All modules automatically use the new version
- JDA and Discord-related dependencies
- Database (jOOQ, PostgreSQL, HikariCP)
- Google APIs
- Logging
- System monitoring (Oshi)
- Google Sheets API
- Web scraping (OkHttp, Jsoup, Jackson)
- Logging
- JDA (for Discord embeds)
- Web framework (Spark)
- Authentication (JWT, Bouncycastle)
- Database
- Testing frameworks
- No external dependencies (only standard library)
- Open
gradle/libs.versions.toml - Find the version in the
[versions]section - Update the version number
- Save and sync Gradle
Example:
[versions]
jda = "6.0.0" # Change to "6.1.0"- Add the version in
[versions]:
[versions]
newLib = "1.0.0"- Add the library in
[libraries]:
[libraries]
new-lib = { module = "com.example:new-lib", version.ref = "newLib" }- Use in build.gradle.kts:
dependencies {
implementation(libs.new.lib)
}- Add to
[bundles]section:
[bundles]
my-bundle = ["lib1", "lib2", "lib3"]- Use in build.gradle.kts:
dependencies {
implementation(libs.bundles.my.bundle)
}- Click "Sync Gradle" in your IDE
- Invalidate caches and restart IDE if needed
- Ensure
gradle/libs.versions.tomlexists and is properly formatted
If you see a version conflict:
- Check all modules are using the version catalog
- Search for any hardcoded versions (e.g.,
"1.0.0"strings) - Update the centralized version in
libs.versions.toml
- Check the changelog of the updated dependency
- Look for breaking changes
- Update code if necessary
- Ensure all related dependencies are compatible
- Always use the version catalog - Never hardcode versions in build.gradle.kts files
- Group related dependencies - Use bundles for dependencies that are always used together
- Keep versions up-to-date - Regularly check for updates to dependencies
- Test after updates - Always run tests after updating dependencies
- Document breaking changes - Add notes in CHANGELOG.md when updating major versions
If you find hardcoded versions in build.gradle.kts files:
- Extract the version to
libs.versions.toml - Replace the hardcoded dependency with the catalog reference
- Sync Gradle and verify the build works
- Commit the changes
Example:
// Before
implementation("net.dv8tion:JDA:6.0.0")
// After
implementation(libs.jda)- Java 21
- JDA 6.0.0
- Lombok 1.18.34
- jOOQ 3.19.8
- PostgreSQL 42.7.3
- HikariCP 5.1.0
- Logback 1.5.13
- SLF4J 2.0.7
- Sheets API v4-rev20220927-2.0.0
- API Client 2.2.0
- OAuth Client 1.34.1
- Auth Library 1.20.0
- Spotless 6.22.0
- jOOQ Plugin 8.1
- Shadow Plugin 8.1.1
For a complete list, see gradle/libs.versions.toml.