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

Conversation

exoego
Copy link

@exoego exoego commented Jul 4, 2025

Closes #1989

  • Definition of versions is centralized in version catalogs
  • Some core lib versions can still be overridden in the same manner. See below:
# default (no override)
❯ ./gradlew compileJava                                                                
Java versions for main code: [compiler:21, release:17]
Java versions for tests: [compiler:21, release:21, launcher:21]

> Configure project :
Project version: 4.0.0-SNAPSHOT (4.0)
Release version: n/a
Development version: n/a
ORM version: 7.0.2.Final
ORM Gradle plugin version: 7.0.2.Final
Vert.x SQL Client version: 5.0.0
# core libs version override 
❯ ./gradlew compileJava -PhibernateOrmVersion=7.0.4.Final -PvertxSqlClientVersion=5.0.1
Java versions for main code: [compiler:21, release:17]
Java versions for tests: [compiler:21, release:21, launcher:21]

> Configure project :
Project version: 4.0.0-SNAPSHOT (4.0)
Release version: n/a
Development version: n/a
ORM version: 7.0.4.Final    <--- ✅ override
ORM Gradle plugin version: 7.0.2.Final
Vert.x SQL Client version: 5.0.1  <--- ✅ override

Mostly auto-transformed by gradle-version-catalog-cli which I wrote.

@DavideD
Copy link
Member

DavideD commented Jul 4, 2025

Thanks, I will have a look at this soon

Copy link
Member

@DavideD DavideD left a comment

Choose a reason for hiding this comment

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

Thanks a lot, looks great!
But I think something got lost in the changes.

When I run a test in the main branch, it prints:

> Configure project :
Project version: 4.0.0-SNAPSHOT (4.0)
Release version: n/a
Development version: n/a
ORM version: 7.0.2.Final
ORM Gradle plugin version: 7.0.2.Final
Vert.x SQL Client Version: 5.0.0

But after your changes, I see:

> Configure project :
Project version: 4.0.0-SNAPSHOT (4.0)
Release version: n/a
Development version: n/a

This information is quite because we tend to run Hibernate Reactive with different configurations.

Also, very nitpicky, but could you also add the issue number before the commit message? It makes my life easier when I need to track down changes.
I usually add it like this:

[#2331] Migrate to Gradle version catalogs

@sebersole Could you also have a look if this is what you had in mind when you created the issue? The approach looks good to me overall, but I don't have a lot of experience with catalogs.

Thanks a lot exoego!


# 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 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.

@exoego exoego force-pushed the version-catalogs branch from 5d793ec to 15b9ff9 Compare July 5, 2025 06:19
@exoego
Copy link
Author

exoego commented Jul 5, 2025

This information is quite because we tend to run Hibernate Reactive with different configurations.

I see.
Brought back the same feature here:
https://github.com/hibernate/hibernate-reactive/pull/2331/files#diff-49a96e7eea8a94af862798a45174e6ac43eb4f8b4bd40759b5da63ba31ec3ef7R120-R126

❯ ./gradlew compileJava -PhibernateOrmVersion=7.0.4.Final -PvertxSqlClientVersion=5.0.1
Java versions for main code: [compiler:21, release:17]
Java versions for tests: [compiler:21, release:21, launcher:21]

> Configure project :
Project version: 4.0.0-SNAPSHOT (4.0)
Release version: n/a
Development version: n/a
ORM version: 7.0.4.Final    <--- ✅ 
ORM Gradle plugin version: 7.0.2.Final
Vert.x SQL Client version: 5.0.1  <--- ✅

If no override, it shows default versions defined in libs.versions.toml (version catalogs).

I initially thought it should be implemented near the place where version override is implemented.
However, realized that settings.gradle is evaluated before build.gradle hence before VersionsPlugin.
So I used rootProject.afterEvaluate in build.gradle, so the versions are shown as same as before.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Consider using Gradle version catalogs
2 participants