Skip to content

Migrate to Gradle version catalogs #2331

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 10 additions & 21 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,33 +3,15 @@ plugins {

id 'java-library'
id 'maven-publish'
id 'com.diffplug.spotless' version '6.25.0'
id 'org.asciidoctor.jvm.convert' version '4.0.2' apply false
id 'io.github.gradle-nexus.publish-plugin' version '1.3.0'
alias(libs.plugins.com.diffplug.spotless)
alias(libs.plugins.org.asciidoctor.jvm.convert) apply false
alias(libs.plugins.io.github.gradle.nexus.publish.plugin)
}

group = "org.hibernate.reactive"
// leverage the ProjectVersion which comes from the `local.versions` plugin
version = project.projectVersion.fullName

// Versions which need to be aligned across modules; this also
// allows overriding the build using a parameter, which can be
// useful to monitor compatibility for upcoming versions on CI:
//
// ./gradlew clean build -PhibernateOrmVersion=5.6.15-SNAPSHOT
ext {
// Mainly, to allow CI to test the latest versions of Vert.X
// Example:
// ./gradlew build -PvertxSqlClientVersion=4.0.0-SNAPSHOT
if ( !project.hasProperty( 'vertxSqlClientVersion' ) ) {
vertxSqlClientVersion = '5.0.0'
}

testcontainersVersion = '1.21.0'

logger.lifecycle "Vert.x SQL Client Version: " + project.vertxSqlClientVersion
}

subprojects {
apply plugin: 'java-library'
apply plugin: 'com.diffplug.spotless'
Expand Down Expand Up @@ -135,3 +117,10 @@ subprojects {
}
}

rootProject.afterEvaluate {
// Workaround since "libs.versions.NAME" notation cannot be used here
def libs = project.extensions.getByType(VersionCatalogsExtension).named('libs')
logger.lifecycle "ORM version: ${libs.findVersion('hibernateOrm').get().requiredVersion}"
logger.lifecycle "ORM Gradle plugin version: ${libs.findVersion('hibernateOrmGradlePlugin').get().requiredVersion}"
logger.lifecycle "Vert.x SQL Client version: ${libs.findVersion('vertxSqlClient').get().requiredVersion}"
}
2 changes: 1 addition & 1 deletion documentation/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ def aggregateJavadocsTask = tasks.register( 'aggregateJavadocs', Javadoc ) {
use = true
options.encoding = 'UTF-8'

def matcher = hibernateOrmVersion =~ /\d+\.\d+/
def matcher = libs.versions.hibernateOrm =~ /\d+\.\d+/
def ormMinorVersion = matcher.find() ? matcher.group() : "5.6";

links = [
Expand Down
14 changes: 7 additions & 7 deletions examples/native-sql-example/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ buildscript {

plugins {
// Optional: Hibernate Gradle plugin to enable bytecode enhancements
id "org.hibernate.orm" version "${hibernateOrmGradlePluginVersion}"
alias(libs.plugins.org.hibernate.orm)
}

description = 'Hibernate Reactive native SQL Example'
Expand All @@ -27,20 +27,20 @@ dependencies {
implementation project( ':hibernate-reactive-core' )

// Hibernate Validator (optional)
implementation 'org.hibernate.validator:hibernate-validator:8.0.2.Final'
runtimeOnly 'org.glassfish.expressly:expressly:5.0.0'
implementation(libs.org.hibernate.validator.hibernate.validator)
runtimeOnly(libs.org.glassfish.expressly.expressly)

// JPA metamodel generation for criteria queries (optional)
annotationProcessor "org.hibernate.orm:hibernate-jpamodelgen:${hibernateOrmVersion}"
annotationProcessor(libs.org.hibernate.orm.hibernate.jpamodelgen)

// database driver for PostgreSQL
runtimeOnly "io.vertx:vertx-pg-client:${vertxSqlClientVersion}"
runtimeOnly(libs.io.vertx.vertx.pg.client)

// logging (optional)
runtimeOnly "org.apache.logging.log4j:log4j-core:2.20.0"
runtimeOnly(libs.org.apache.logging.log4j.log4j.core)

// Allow authentication to PostgreSQL using SCRAM:
runtimeOnly 'com.ongres.scram:scram-client:3.1'
runtimeOnly(libs.com.ongres.scram.scram.client)
}

// Optional: enable the bytecode enhancements
Expand Down
16 changes: 8 additions & 8 deletions examples/session-example/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ buildscript {

plugins {
// Optional: Hibernate Gradle plugin to enable bytecode enhancements
id "org.hibernate.orm" version "${hibernateOrmGradlePluginVersion}"
alias(libs.plugins.org.hibernate.orm)
}

description = 'Hibernate Reactive Session Examples'
Expand All @@ -27,21 +27,21 @@ dependencies {
implementation project( ':hibernate-reactive-core' )

// Hibernate Validator (optional)
implementation 'org.hibernate.validator:hibernate-validator:8.0.2.Final'
runtimeOnly 'org.glassfish.expressly:expressly:5.0.0'
implementation(libs.org.hibernate.validator.hibernate.validator)
runtimeOnly(libs.org.glassfish.expressly.expressly)

// JPA metamodel generation for criteria queries (optional)
annotationProcessor "org.hibernate.orm:hibernate-jpamodelgen:${hibernateOrmVersion}"
annotationProcessor(libs.org.hibernate.orm.hibernate.jpamodelgen)

// database drivers for PostgreSQL and MySQL
runtimeOnly "io.vertx:vertx-pg-client:${vertxSqlClientVersion}"
runtimeOnly "io.vertx:vertx-mysql-client:${vertxSqlClientVersion}"
runtimeOnly(libs.io.vertx.vertx.pg.client)
runtimeOnly(libs.io.vertx.vertx.mysql.client)

// logging (optional)
runtimeOnly "org.apache.logging.log4j:log4j-core:2.20.0"
runtimeOnly(libs.org.apache.logging.log4j.log4j.core)

// Allow authentication to PostgreSQL using SCRAM:
runtimeOnly 'com.ongres.scram:scram-client:3.1'
runtimeOnly(libs.com.ongres.scram.scram.client)
}

// Optional: enable the bytecode enhancements
Expand Down
20 changes: 0 additions & 20 deletions gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,3 @@ org.gradle.java.installations.auto-download=false

# Enable the maven local repository (for local development when needed) when present (value ignored)
#enableMavenLocalRepo = true

# The default Hibernate ORM version (override using `-PhibernateOrmVersion=the.version.you.want`)
hibernateOrmVersion = 7.0.2.Final

# Override default Hibernate ORM Gradle plugin version
# Using the stable version because I don't know how to configure the build to download the snapshot version from
# a remote repository
#hibernateOrmGradlePluginVersion = 7.0.2.Final

# If set to true, skip Hibernate ORM version parsing (default is true, if set to null)
# this is required when using intervals or weird versions or the build will fail
#skipOrmVersionParsing = true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't see this property mentioned anywhere anymore

Copy link
Author

@exoego exoego Jul 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it still needed?
IIUC, if skipOrmVersionParsing is false, hibernateOrmVersion is parsed and may raise if version has no . in it.

try {
final String[] hibernateVersionComponents = fullName.split( "\\." );
major = hibernateVersionComponents[0];
minor = hibernateVersionComponents[1];
}
catch (Exception e) {
throw new IllegalArgumentException( "Invalid version number: " + fullName + "." );
}

When one wants to test "weird versions", why not simply use that version ? 🤔

❯ ./gradlew compileJava -PhibernateOrmVersion=1234weiredversion


# Override default Vert.x Sql client version
#vertxSqlClientVersion = 5.0.0-SNAPSHOT

# Override default Vert.x Web client and server versions. For integration tests, both default to vertxSqlClientVersion
#vertxWebVersion = 5.0.0
#vertxWebtClientVersion = 5.0.0
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's quite helpful to have all these properties in one place, will they still work if we keep them here?

Copy link
Author

@exoego exoego Jul 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will they still work if we keep them here?

No, keeping versions in gradle.properties does not make sense, since there is no way to refer these gradle properties within libs.versions.toml.
All versions are now managed in one place, version catalog gradle/libs.versions.toml.

Please refer [versions] section in the catalog.
The section defines version variables like before in gradle.properties.


57 changes: 57 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
[versions]
assertj = "3.27.3"
hibernateOrmGradlePlugin = "7.0.2.Final"
hibernateOrm = "7.0.2.Final"
jacksonDatabind = "2.15.2"
jbossLoggingAnnotation = "3.0.4.Final"
jbossLogging = "3.5.0.Final"
junit = "5.11.3"
log4j = "2.20.0"
testcontainers = "1.21.0"
vertxSqlClient = "5.0.0"

[libraries]
com-fasterxml-jackson-core-jackson-databind = { group = "com.fasterxml.jackson.core", name = "jackson-databind", version.ref = "jacksonDatabind" }
com-ibm-db2-jcc = { group = "com.ibm.db2", name = "jcc", version = "12.1.0.0" }
com-microsoft-sqlserver-mssql-jdbc = { group = "com.microsoft.sqlserver", name = "mssql-jdbc", version = "12.10.0.jre11" }
com-mysql-mysql-connector-j = { group = "com.mysql", name = "mysql-connector-j", version = "9.3.0" }
com-ongres-scram-scram-client = { group = "com.ongres.scram", name = "scram-client", version = "3.1" }
io-smallrye-reactive-mutiny = { group = "io.smallrye.reactive", name = "mutiny", version = "2.9.0" }
io-vertx-vertx-db2-client = { group = "io.vertx", name = "vertx-db2-client", version.ref = "vertxSqlClient" }
io-vertx-vertx-junit5 = { group = "io.vertx", name = "vertx-junit5", version.ref = "vertxSqlClient" }
io-vertx-vertx-micrometer-metrics = { group = "io.vertx", name = "vertx-micrometer-metrics", version.ref = "vertxSqlClient" }
io-vertx-vertx-mssql-client = { group = "io.vertx", name = "vertx-mssql-client", version.ref = "vertxSqlClient" }
io-vertx-vertx-mysql-client = { group = "io.vertx", name = "vertx-mysql-client", version.ref = "vertxSqlClient" }
io-vertx-vertx-oracle-client = { group = "io.vertx", name = "vertx-oracle-client", version.ref = "vertxSqlClient" }
io-vertx-vertx-pg-client = { group = "io.vertx", name = "vertx-pg-client", version.ref = "vertxSqlClient" }
io-vertx-vertx-sql-client = { group = "io.vertx", name = "vertx-sql-client", version.ref = "vertxSqlClient" }
io-vertx-vertx-web = { group = "io.vertx", name = "vertx-web", version.ref = "vertxSqlClient" }
io-vertx-vertx-web-client = { group = "io.vertx", name = "vertx-web-client", version.ref = "vertxSqlClient" }
org-apache-logging-log4j-log4j-core = { group = "org.apache.logging.log4j", name = "log4j-core", version.ref = "log4j" }
org-assertj-assertj-core = { group = "org.assertj", name = "assertj-core", version.ref = "assertj" }
org-ehcache-ehcache = { group = "org.ehcache", name = "ehcache", version = "3.10.8" }
org-glassfish-expressly-expressly = { group = "org.glassfish.expressly", name = "expressly", version = "5.0.0" }
org-hibernate-orm-hibernate-core = { group = "org.hibernate.orm", name = "hibernate-core", version.ref = "hibernateOrm" }
org-hibernate-orm-hibernate-jcache = { group = "org.hibernate.orm", name = "hibernate-jcache", version.ref = "hibernateOrm" }
org-hibernate-orm-hibernate-jpamodelgen = { group = "org.hibernate.orm", name = "hibernate-jpamodelgen", version.ref = "hibernateOrm" }
org-hibernate-validator-hibernate-validator = { group = "org.hibernate.validator", name = "hibernate-validator", version = "8.0.2.Final" }
org-jboss-logging-jboss-logging = { group = "org.jboss.logging", name = "jboss-logging", version.ref = "jbossLogging" }
org-jboss-logging-jboss-logging-annotations = { group = "org.jboss.logging", name = "jboss-logging-annotations", version.ref = "jbossLoggingAnnotation" }
org-jboss-logging-jboss-logging-processor = { group = "org.jboss.logging", name = "jboss-logging-processor", version.ref = "jbossLoggingAnnotation" }
org-junit-jupiter-junit-jupiter-api = { group = "org.junit.jupiter", name = "junit-jupiter-api", version.ref = "junit" }
org-junit-jupiter-junit-jupiter-engine = { group = "org.junit.jupiter", name = "junit-jupiter-engine", version.ref = "junit" }
org-mariadb-jdbc-mariadb-java-client = { group = "org.mariadb.jdbc", name = "mariadb-java-client", version = "3.5.3" }
org-postgresql-postgresql = { group = "org.postgresql", name = "postgresql", version = "42.7.5" }
org-testcontainers-cockroachdb = { group = "org.testcontainers", name = "cockroachdb", version.ref = "testcontainers" }
org-testcontainers-db2 = { group = "org.testcontainers", name = "db2", version.ref = "testcontainers" }
org-testcontainers-mariadb = { group = "org.testcontainers", name = "mariadb", version.ref = "testcontainers" }
org-testcontainers-mssqlserver = { group = "org.testcontainers", name = "mssqlserver", version.ref = "testcontainers" }
org-testcontainers-mysql = { group = "org.testcontainers", name = "mysql", version.ref = "testcontainers" }
org-testcontainers-oracle-xe = { group = "org.testcontainers", name = "oracle-xe", version.ref = "testcontainers" }
org-testcontainers-postgresql = { group = "org.testcontainers", name = "postgresql", version.ref = "testcontainers" }

[plugins]
com-diffplug-spotless = { id = "com.diffplug.spotless", version = "6.25.0" }
io-github-gradle-nexus-publish-plugin = { id = "io.github.gradle-nexus.publish-plugin", version = "1.3.0" }
org-asciidoctor-jvm-convert = { id = "org.asciidoctor.jvm.convert", version = "4.0.2" }
org-hibernate-orm = { id = "org.hibernate.orm", version.ref = "hibernateOrmGradlePlugin" }
68 changes: 34 additions & 34 deletions hibernate-reactive-core/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,77 +8,77 @@ apply from: publishScript

dependencies {

api "org.hibernate.orm:hibernate-core:${hibernateOrmVersion}"
api(libs.org.hibernate.orm.hibernate.core)

api 'io.smallrye.reactive:mutiny:2.9.0'
api(libs.io.smallrye.reactive.mutiny)

//Logging
implementation 'org.jboss.logging:jboss-logging:3.6.1.Final'
annotationProcessor 'org.jboss.logging:jboss-logging:3.6.1.Final'
implementation(libs.org.jboss.logging.jboss.logging)
annotationProcessor(libs.org.jboss.logging.jboss.logging)

compileOnly 'org.jboss.logging:jboss-logging-annotations:3.0.4.Final'
annotationProcessor 'org.jboss.logging:jboss-logging-annotations:3.0.4.Final'
annotationProcessor 'org.jboss.logging:jboss-logging-processor:3.0.4.Final'
compileOnly(libs.org.jboss.logging.jboss.logging.annotations)
annotationProcessor(libs.org.jboss.logging.jboss.logging.annotations)
annotationProcessor(libs.org.jboss.logging.jboss.logging.processor)


//Specific implementation details of Hibernate Reactive:
implementation "io.vertx:vertx-sql-client:${vertxSqlClientVersion}"
implementation(libs.io.vertx.vertx.sql.client)

// Testing
testImplementation 'org.assertj:assertj-core:3.27.3'
testImplementation "io.vertx:vertx-junit5:${vertxSqlClientVersion}"
testImplementation(libs.org.assertj.assertj.core)
testImplementation(libs.io.vertx.vertx.junit5)

// Drivers
testImplementation "io.vertx:vertx-pg-client:${vertxSqlClientVersion}"
testImplementation "io.vertx:vertx-mysql-client:${vertxSqlClientVersion}"
testImplementation "io.vertx:vertx-db2-client:${vertxSqlClientVersion}"
testImplementation "io.vertx:vertx-mssql-client:${vertxSqlClientVersion}"
testImplementation "io.vertx:vertx-oracle-client:${vertxSqlClientVersion}"
testImplementation(libs.io.vertx.vertx.pg.client)
testImplementation(libs.io.vertx.vertx.mysql.client)
testImplementation(libs.io.vertx.vertx.db2.client)
testImplementation(libs.io.vertx.vertx.mssql.client)
testImplementation(libs.io.vertx.vertx.oracle.client)

// Metrics
testImplementation "io.vertx:vertx-micrometer-metrics:${vertxSqlClientVersion}"
testImplementation(libs.io.vertx.vertx.micrometer.metrics)

// Optional dependency of vertx-pg-client, essential when connecting via SASL SCRAM
testImplementation 'com.ongres.scram:scram-client:3.1'
testImplementation(libs.com.ongres.scram.scram.client)

// JUnit Jupiter
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.11.3'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.11.3'
testImplementation(libs.org.junit.jupiter.junit.jupiter.api)
testRuntimeOnly(libs.org.junit.jupiter.junit.jupiter.engine)

// JDBC driver to test with ORM and PostgreSQL
testRuntimeOnly "org.postgresql:postgresql:42.7.5"
testRuntimeOnly(libs.org.postgresql.postgresql)

// JDBC driver for Testcontainers with MS SQL Server
testRuntimeOnly "com.microsoft.sqlserver:mssql-jdbc:12.10.0.jre11"
testRuntimeOnly(libs.com.microsoft.sqlserver.mssql.jdbc)

// JDBC driver for Testcontainers with MariaDB Server
testRuntimeOnly "org.mariadb.jdbc:mariadb-java-client:3.5.3"
testRuntimeOnly(libs.org.mariadb.jdbc.mariadb.java.client)

// JDBC driver for Testcontainers with MYSQL Server
testRuntimeOnly "com.mysql:mysql-connector-j:9.3.0"
testRuntimeOnly(libs.com.mysql.mysql.connector.j)

// JDBC driver for Db2 server, for testing
testRuntimeOnly "com.ibm.db2:jcc:12.1.0.0"
testRuntimeOnly(libs.com.ibm.db2.jcc)

// EHCache
testRuntimeOnly ("org.ehcache:ehcache:3.10.8") {
testRuntimeOnly(libs.org.ehcache.ehcache) {
capabilities {
requireCapability 'org.ehcache.modules:ehcache-xml-jakarta'
}
}
testRuntimeOnly ("org.hibernate.orm:hibernate-jcache:${hibernateOrmVersion}")
testRuntimeOnly(libs.org.hibernate.orm.hibernate.jcache)

// log4j
testRuntimeOnly 'org.apache.logging.log4j:log4j-core:2.20.0'
testRuntimeOnly(libs.org.apache.logging.log4j.log4j.core)

// Testcontainers
testImplementation "org.testcontainers:postgresql:${testcontainersVersion}"
testImplementation "org.testcontainers:mysql:${testcontainersVersion}"
testImplementation "org.testcontainers:mariadb:${testcontainersVersion}"
testImplementation "org.testcontainers:db2:${testcontainersVersion}"
testImplementation "org.testcontainers:cockroachdb:${testcontainersVersion}"
testImplementation "org.testcontainers:mssqlserver:${testcontainersVersion}"
testImplementation "org.testcontainers:oracle-xe:${testcontainersVersion}"
testImplementation(libs.org.testcontainers.postgresql)
testImplementation(libs.org.testcontainers.mysql)
testImplementation(libs.org.testcontainers.mariadb)
testImplementation(libs.org.testcontainers.db2)
testImplementation(libs.org.testcontainers.cockroachdb)
testImplementation(libs.org.testcontainers.mssqlserver)
testImplementation(libs.org.testcontainers.oracle.xe)
}

// Reproducible Builds
Expand Down
21 changes: 8 additions & 13 deletions integration-tests/bytecode-enhancements-it/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -10,37 +10,32 @@ buildscript {
}

plugins {
id "org.hibernate.orm" version "${hibernateOrmGradlePluginVersion}"
alias(libs.plugins.org.hibernate.orm)
}

description = 'Bytecode enhancements integration tests'

ext {
log4jVersion = '2.20.0'
assertjVersion = '3.27.3'
}

dependencies {
implementation project(':hibernate-reactive-core')

// JPA metamodel generation for criteria queries (optional)
annotationProcessor "org.hibernate.orm:hibernate-jpamodelgen:${hibernateOrmVersion}"
annotationProcessor(libs.org.hibernate.orm.hibernate.jpamodelgen)

// Testing on one database should be enough
runtimeOnly "io.vertx:vertx-pg-client:${vertxSqlClientVersion}"
runtimeOnly(libs.io.vertx.vertx.pg.client)

// Allow authentication to PostgreSQL using SCRAM:
runtimeOnly 'com.ongres.scram:scram-client:3.1'
runtimeOnly(libs.com.ongres.scram.scram.client)

// logging
runtimeOnly "org.apache.logging.log4j:log4j-core:${log4jVersion}"
runtimeOnly(libs.org.apache.logging.log4j.log4j.core)

// Testcontainers
testImplementation "org.testcontainers:postgresql:${testcontainersVersion}"
testImplementation(libs.org.testcontainers.postgresql)

// Testing
testImplementation "org.assertj:assertj-core:${assertjVersion}"
testImplementation "io.vertx:vertx-junit5:${vertxSqlClientVersion}"
testImplementation(libs.org.assertj.assertj.core)
testImplementation(libs.io.vertx.vertx.junit5)
}

// Optional: enable the bytecode enhancements
Expand Down
Loading