Skip to content

Commit 649e50d

Browse files
exoegoDavideD
authored andcommitted
[hibernate#2331] Migrate to Gradle version catalogs
1 parent 52b5b1f commit 649e50d

File tree

14 files changed

+289
-150
lines changed

14 files changed

+289
-150
lines changed

build.gradle

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,15 @@ plugins {
33

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

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

15-
// Versions which need to be aligned across modules; this also
16-
// allows overriding the build using a parameter, which can be
17-
// useful to monitor compatibility for upcoming versions on CI:
18-
//
19-
// ./gradlew clean build -PhibernateOrmVersion=5.6.15-SNAPSHOT
20-
ext {
21-
// Mainly, to allow CI to test the latest versions of Vert.X
22-
// Example:
23-
// ./gradlew build -PvertxSqlClientVersion=4.0.0-SNAPSHOT
24-
if ( !project.hasProperty( 'vertxSqlClientVersion' ) ) {
25-
vertxSqlClientVersion = '5.0.0'
26-
}
27-
28-
testcontainersVersion = '1.21.0'
29-
30-
logger.lifecycle "Vert.x SQL Client Version: " + project.vertxSqlClientVersion
31-
}
32-
3315
subprojects {
3416
apply plugin: 'java-library'
3517
apply plugin: 'com.diffplug.spotless'
@@ -135,3 +117,10 @@ subprojects {
135117
}
136118
}
137119

120+
rootProject.afterEvaluate {
121+
// Workaround since "libs.versions.NAME" notation cannot be used here
122+
def libs = project.extensions.getByType(VersionCatalogsExtension).named('libs')
123+
logger.lifecycle "ORM version: ${libs.findVersion('hibernateOrmVersion').get().requiredVersion}"
124+
logger.lifecycle "ORM Gradle plugin version: ${libs.findVersion('hibernateOrmGradlePluginVersion').get().requiredVersion}"
125+
logger.lifecycle "Vert.x SQL Client version: ${libs.findVersion('vertxSqlClientVersion').get().requiredVersion}"
126+
}

documentation/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ def aggregateJavadocsTask = tasks.register( 'aggregateJavadocs', Javadoc ) {
5252
use = true
5353
options.encoding = 'UTF-8'
5454

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

5858
links = [

examples/native-sql-example/build.gradle

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ buildscript {
1818

1919
plugins {
2020
// Optional: Hibernate Gradle plugin to enable bytecode enhancements
21-
id "org.hibernate.orm" version "${hibernateOrmGradlePluginVersion}"
21+
alias(libs.plugins.org.hibernate.orm)
2222
}
2323

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

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

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

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

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

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

4646
// Optional: enable the bytecode enhancements

examples/session-example/build.gradle

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ buildscript {
1818

1919
plugins {
2020
// Optional: Hibernate Gradle plugin to enable bytecode enhancements
21-
id "org.hibernate.orm" version "${hibernateOrmGradlePluginVersion}"
21+
alias(libs.plugins.org.hibernate.orm)
2222
}
2323

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

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

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

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

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

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

4747
// Optional: enable the bytecode enhancements

gradle.properties

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ org.gradle.java.installations.auto-download=false
1818

1919
#########################################################################
2020
# Additional custom gradle build properties.
21-
# Please, leave these properties commented upstream
21+
# Please, leave these properties commented upstream.
22+
# They are meant to be used for local builds or WIP branches.
23+
# The same properties can be set from the command line.
2224
##########################################################################
2325

2426
# Enable Testcontainers + Docker when present (value ignored)
@@ -34,12 +36,12 @@ org.gradle.java.installations.auto-download=false
3436
# Enable the maven local repository (for local development when needed) when present (value ignored)
3537
#enableMavenLocalRepo = true
3638

39+
### Settings the following properties will override the version defined in gradle/libs.versions.toml
40+
3741
# The default Hibernate ORM version (override using `-PhibernateOrmVersion=the.version.you.want`)
38-
hibernateOrmVersion = 7.0.2.Final
42+
hibernateOrmVersion = 7.0.3.Final
3943

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

4547
# If set to true, skip Hibernate ORM version parsing (default is true, if set to null)

gradle/libs.versions.toml

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
[versions]
2+
assertjVersion = "3.27.3"
3+
hibernateOrmVersion = "7.0.2.Final"
4+
hibernateOrmGradlePluginVersion = "7.0.2.Final"
5+
jacksonDatabindVersion = "2.15.2"
6+
jbossLoggingAnnotationVersion = "3.0.4.Final"
7+
jbossLoggingVersion = "3.5.0.Final"
8+
junitVersion = "5.11.3"
9+
log4jVersion = "2.20.0"
10+
testcontainersVersion = "1.21.0"
11+
vertxSqlClientVersion = "5.0.0"
12+
vertxWebVersion= "5.0.0"
13+
vertxWebClientVersion = "5.0.0"
14+
15+
[libraries]
16+
com-fasterxml-jackson-core-jackson-databind = { group = "com.fasterxml.jackson.core", name = "jackson-databind", version.ref = "jacksonDatabindVersion" }
17+
com-ibm-db2-jcc = { group = "com.ibm.db2", name = "jcc", version = "12.1.0.0" }
18+
com-microsoft-sqlserver-mssql-jdbc = { group = "com.microsoft.sqlserver", name = "mssql-jdbc", version = "12.10.0.jre11" }
19+
com-mysql-mysql-connector-j = { group = "com.mysql", name = "mysql-connector-j", version = "9.3.0" }
20+
com-ongres-scram-scram-client = { group = "com.ongres.scram", name = "scram-client", version = "3.1" }
21+
io-smallrye-reactive-mutiny = { group = "io.smallrye.reactive", name = "mutiny", version = "2.9.0" }
22+
io-vertx-vertx-db2-client = { group = "io.vertx", name = "vertx-db2-client", version.ref = "vertxSqlClientVersion" }
23+
io-vertx-vertx-junit5 = { group = "io.vertx", name = "vertx-junit5", version.ref = "vertxSqlClientVersion" }
24+
io-vertx-vertx-micrometer-metrics = { group = "io.vertx", name = "vertx-micrometer-metrics", version.ref = "vertxSqlClientVersion" }
25+
io-vertx-vertx-mssql-client = { group = "io.vertx", name = "vertx-mssql-client", version.ref = "vertxSqlClientVersion" }
26+
io-vertx-vertx-mysql-client = { group = "io.vertx", name = "vertx-mysql-client", version.ref = "vertxSqlClientVersion" }
27+
io-vertx-vertx-oracle-client = { group = "io.vertx", name = "vertx-oracle-client", version.ref = "vertxSqlClientVersion" }
28+
io-vertx-vertx-pg-client = { group = "io.vertx", name = "vertx-pg-client", version.ref = "vertxSqlClientVersion" }
29+
io-vertx-vertx-sql-client = { group = "io.vertx", name = "vertx-sql-client", version.ref = "vertxSqlClientVersion" }
30+
io-vertx-vertx-web = { group = "io.vertx", name = "vertx-web", version.ref = "vertxWebVersion" }
31+
io-vertx-vertx-web-client = { group = "io.vertx", name = "vertx-web-client", version.ref = "vertxWebClientVersion" }
32+
org-apache-logging-log4j-log4j-core = { group = "org.apache.logging.log4j", name = "log4j-core", version.ref = "log4jVersion" }
33+
org-assertj-assertj-core = { group = "org.assertj", name = "assertj-core", version.ref = "assertjVersion" }
34+
org-ehcache-ehcache = { group = "org.ehcache", name = "ehcache", version = "3.10.8" }
35+
org-glassfish-expressly-expressly = { group = "org.glassfish.expressly", name = "expressly", version = "5.0.0" }
36+
org-hibernate-orm-hibernate-core = { group = "org.hibernate.orm", name = "hibernate-core", version.ref = "hibernateOrmVersion" }
37+
org-hibernate-orm-hibernate-jcache = { group = "org.hibernate.orm", name = "hibernate-jcache", version.ref = "hibernateOrmVersion" }
38+
org-hibernate-orm-hibernate-jpamodelgen = { group = "org.hibernate.orm", name = "hibernate-jpamodelgen", version.ref = "hibernateOrmVersion" }
39+
org-hibernate-validator-hibernate-validator = { group = "org.hibernate.validator", name = "hibernate-validator", version = "8.0.2.Final" }
40+
org-jboss-logging-jboss-logging = { group = "org.jboss.logging", name = "jboss-logging", version.ref = "jbossLoggingVersion" }
41+
org-jboss-logging-jboss-logging-annotations = { group = "org.jboss.logging", name = "jboss-logging-annotations", version.ref = "jbossLoggingAnnotationVersion" }
42+
org-jboss-logging-jboss-logging-processor = { group = "org.jboss.logging", name = "jboss-logging-processor", version.ref = "jbossLoggingAnnotationVersion" }
43+
org-junit-jupiter-junit-jupiter-api = { group = "org.junit.jupiter", name = "junit-jupiter-api", version.ref = "junitVersion" }
44+
org-junit-jupiter-junit-jupiter-engine = { group = "org.junit.jupiter", name = "junit-jupiter-engine", version.ref = "junitVersion" }
45+
org-mariadb-jdbc-mariadb-java-client = { group = "org.mariadb.jdbc", name = "mariadb-java-client", version = "3.5.3" }
46+
org-postgresql-postgresql = { group = "org.postgresql", name = "postgresql", version = "42.7.5" }
47+
org-testcontainers-cockroachdb = { group = "org.testcontainers", name = "cockroachdb", version.ref = "testcontainersVersion" }
48+
org-testcontainers-db2 = { group = "org.testcontainers", name = "db2", version.ref = "testcontainersVersion" }
49+
org-testcontainers-mariadb = { group = "org.testcontainers", name = "mariadb", version.ref = "testcontainersVersion" }
50+
org-testcontainers-mssqlserver = { group = "org.testcontainers", name = "mssqlserver", version.ref = "testcontainersVersion" }
51+
org-testcontainers-mysql = { group = "org.testcontainers", name = "mysql", version.ref = "testcontainersVersion" }
52+
org-testcontainers-oracle-xe = { group = "org.testcontainers", name = "oracle-xe", version.ref = "testcontainersVersion" }
53+
org-testcontainers-postgresql = { group = "org.testcontainers", name = "postgresql", version.ref = "testcontainersVersion" }
54+
55+
[plugins]
56+
com-diffplug-spotless = { id = "com.diffplug.spotless", version = "6.25.0" }
57+
io-github-gradle-nexus-publish-plugin = { id = "io.github.gradle-nexus.publish-plugin", version = "1.3.0" }
58+
org-asciidoctor-jvm-convert = { id = "org.asciidoctor.jvm.convert", version = "4.0.2" }
59+
org-hibernate-orm = { id = "org.hibernate.orm", version.ref = "hibernateOrmGradlePluginVersion" }

hibernate-reactive-core/build.gradle

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -8,77 +8,77 @@ apply from: publishScript
88

99
dependencies {
1010

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

13-
api 'io.smallrye.reactive:mutiny:2.9.0'
13+
api(libs.io.smallrye.reactive.mutiny)
1414

1515
//Logging
16-
implementation 'org.jboss.logging:jboss-logging:3.6.1.Final'
17-
annotationProcessor 'org.jboss.logging:jboss-logging:3.6.1.Final'
16+
implementation(libs.org.jboss.logging.jboss.logging)
17+
annotationProcessor(libs.org.jboss.logging.jboss.logging)
1818

19-
compileOnly 'org.jboss.logging:jboss-logging-annotations:3.0.4.Final'
20-
annotationProcessor 'org.jboss.logging:jboss-logging-annotations:3.0.4.Final'
21-
annotationProcessor 'org.jboss.logging:jboss-logging-processor:3.0.4.Final'
19+
compileOnly(libs.org.jboss.logging.jboss.logging.annotations)
20+
annotationProcessor(libs.org.jboss.logging.jboss.logging.annotations)
21+
annotationProcessor(libs.org.jboss.logging.jboss.logging.processor)
2222

2323

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

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

3131
// Drivers
32-
testImplementation "io.vertx:vertx-pg-client:${vertxSqlClientVersion}"
33-
testImplementation "io.vertx:vertx-mysql-client:${vertxSqlClientVersion}"
34-
testImplementation "io.vertx:vertx-db2-client:${vertxSqlClientVersion}"
35-
testImplementation "io.vertx:vertx-mssql-client:${vertxSqlClientVersion}"
36-
testImplementation "io.vertx:vertx-oracle-client:${vertxSqlClientVersion}"
32+
testImplementation(libs.io.vertx.vertx.pg.client)
33+
testImplementation(libs.io.vertx.vertx.mysql.client)
34+
testImplementation(libs.io.vertx.vertx.db2.client)
35+
testImplementation(libs.io.vertx.vertx.mssql.client)
36+
testImplementation(libs.io.vertx.vertx.oracle.client)
3737

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

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

4444
// JUnit Jupiter
45-
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.11.3'
46-
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine:5.11.3'
45+
testImplementation(libs.org.junit.jupiter.junit.jupiter.api)
46+
testRuntimeOnly(libs.org.junit.jupiter.junit.jupiter.engine)
4747

4848
// JDBC driver to test with ORM and PostgreSQL
49-
testRuntimeOnly "org.postgresql:postgresql:42.7.5"
49+
testRuntimeOnly(libs.org.postgresql.postgresql)
5050

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

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

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

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

6363
// EHCache
64-
testRuntimeOnly ("org.ehcache:ehcache:3.10.8") {
64+
testRuntimeOnly(libs.org.ehcache.ehcache) {
6565
capabilities {
6666
requireCapability 'org.ehcache.modules:ehcache-xml-jakarta'
6767
}
6868
}
69-
testRuntimeOnly ("org.hibernate.orm:hibernate-jcache:${hibernateOrmVersion}")
69+
testRuntimeOnly(libs.org.hibernate.orm.hibernate.jcache)
7070

7171
// log4j
72-
testRuntimeOnly 'org.apache.logging.log4j:log4j-core:2.20.0'
72+
testRuntimeOnly(libs.org.apache.logging.log4j.log4j.core)
7373

7474
// Testcontainers
75-
testImplementation "org.testcontainers:postgresql:${testcontainersVersion}"
76-
testImplementation "org.testcontainers:mysql:${testcontainersVersion}"
77-
testImplementation "org.testcontainers:mariadb:${testcontainersVersion}"
78-
testImplementation "org.testcontainers:db2:${testcontainersVersion}"
79-
testImplementation "org.testcontainers:cockroachdb:${testcontainersVersion}"
80-
testImplementation "org.testcontainers:mssqlserver:${testcontainersVersion}"
81-
testImplementation "org.testcontainers:oracle-xe:${testcontainersVersion}"
75+
testImplementation(libs.org.testcontainers.postgresql)
76+
testImplementation(libs.org.testcontainers.mysql)
77+
testImplementation(libs.org.testcontainers.mariadb)
78+
testImplementation(libs.org.testcontainers.db2)
79+
testImplementation(libs.org.testcontainers.cockroachdb)
80+
testImplementation(libs.org.testcontainers.mssqlserver)
81+
testImplementation(libs.org.testcontainers.oracle.xe)
8282
}
8383

8484
// Reproducible Builds

integration-tests/bytecode-enhancements-it/build.gradle

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -10,37 +10,32 @@ buildscript {
1010
}
1111

1212
plugins {
13-
id "org.hibernate.orm" version "${hibernateOrmGradlePluginVersion}"
13+
alias(libs.plugins.org.hibernate.orm)
1414
}
1515

1616
description = 'Bytecode enhancements integration tests'
1717

18-
ext {
19-
log4jVersion = '2.20.0'
20-
assertjVersion = '3.27.3'
21-
}
22-
2318
dependencies {
2419
implementation project(':hibernate-reactive-core')
2520

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

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

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

3530
// logging
36-
runtimeOnly "org.apache.logging.log4j:log4j-core:${log4jVersion}"
31+
runtimeOnly(libs.org.apache.logging.log4j.log4j.core)
3732

3833
// Testcontainers
39-
testImplementation "org.testcontainers:postgresql:${testcontainersVersion}"
34+
testImplementation(libs.org.testcontainers.postgresql)
4035

4136
// Testing
42-
testImplementation "org.assertj:assertj-core:${assertjVersion}"
43-
testImplementation "io.vertx:vertx-junit5:${vertxSqlClientVersion}"
37+
testImplementation(libs.org.assertj.assertj.core)
38+
testImplementation(libs.io.vertx.vertx.junit5)
4439
}
4540

4641
// Optional: enable the bytecode enhancements

0 commit comments

Comments
 (0)