Skip to content

HHH-14082 Hibernate cannot determine its core version in modular configuration #10726

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
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
5 changes: 3 additions & 2 deletions hibernate-core/src/main/java/org/hibernate/Version.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import org.hibernate.internal.build.AllowSysOut;

import java.lang.invoke.MethodHandles;
import java.lang.module.ModuleDescriptor;

import static org.jboss.logging.Logger.getMessageLogger;

Expand All @@ -21,8 +22,8 @@ public final class Version {
private static final String VERSION = initVersion();

private static String initVersion() {
final String version = Version.class.getPackage().getImplementationVersion();
return version != null ? version : "[WORKING]";
ModuleDescriptor moduleDescriptor = Version.class.getModule().getDescriptor() ;
return moduleDescriptor != null ? (moduleDescriptor.version().isPresent() ? moduleDescriptor.version().toString() : "[WORKING]") : "[WORKING]";
Comment on lines -24 to +26
Copy link
Member

Choose a reason for hiding this comment

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

Should there be a fallback to getPackage().getImplementationVersion() somewhere here?

Copy link
Member

Choose a reason for hiding this comment

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

I was going to suggest that maybe we could do something similar to this version injection into bytecode as it's done for Search e.g. here:

https://github.com/hibernate/hibernate-search/blob/6490598a0ee5895520a5915e53fe4d7af52abed7/engine/pom.xml#L44-L60

But then I notice that there already seems to be an injection gradle plugin:

id "org.hibernate.build.version-injection" version "2.0.0" apply false

Maybe we should just make sure that the plugin is used in this case?

(cc7c7d7 this commit might be related as it seems it "removes" the injection part?)

Copy link
Author

Choose a reason for hiding this comment

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

Should there be a fallback to getPackage().getImplementationVersion() somewhere here?

Hello Gavin,

Ok, I will look through. Thanks.

}

private Version() {
Expand Down