diff --git a/build.gradle b/build.gradle index c661531e733f..542c0702a76f 100644 --- a/build.gradle +++ b/build.gradle @@ -19,7 +19,7 @@ buildscript { plugins { id "local.module" - id "org.hibernate.build.version-injection" version "2.0.0" apply false + id "org.hibernate.build.version-injection" version "2.1.0" apply false id 'org.hibernate.orm.database-service' apply false id 'biz.aQute.bnd' version '7.1.0' apply false diff --git a/hibernate-core/hibernate-core.gradle b/hibernate-core/hibernate-core.gradle index 5bf78ff4e2d9..51b0672b2a2f 100644 --- a/hibernate-core/hibernate-core.gradle +++ b/hibernate-core/hibernate-core.gradle @@ -8,6 +8,7 @@ plugins { id "local.publishing-java-module" id "local.publishing-group-relocation" + id "org.hibernate.build.version-injection" id "org.hibernate.orm.antlr" id "local-xjc-plugin" } @@ -132,6 +133,10 @@ xjc { } } +versionInjection { + into( 'org.hibernate.Version', 'initVersion' ) +} + task copyBundleResourcesXml (type: Copy) { inputs.property( "db", db ) inputs.property( "dbHost", dbHost ) diff --git a/tooling/metamodel-generator/hibernate-processor.gradle b/tooling/metamodel-generator/hibernate-processor.gradle index ff49cbb4dcbb..78ce0fde9b79 100644 --- a/tooling/metamodel-generator/hibernate-processor.gradle +++ b/tooling/metamodel-generator/hibernate-processor.gradle @@ -6,7 +6,7 @@ plugins { id "local.publishing-java-module" id "local.publishing-group-relocation" - id "org.hibernate.build.version-injection" + id "org.hibernate.build.version-injection" } description = 'Hibernate compile-time tooling' @@ -77,6 +77,10 @@ configurations { jakartaDataCompileOnly.extendsFrom(testCompileOnly) } +versionInjection { + into( 'org.hibernate.processor.Version', 'initVersion' ) +} + def quarkusOrmPanacheTestTask = tasks.register( 'quarkusOrmPanacheTest', Test ) { description = 'Runs the Quarkus ORM Panache tests.' group = 'verification' diff --git a/tooling/metamodel-generator/src/main/java/org/hibernate/processor/Version.java b/tooling/metamodel-generator/src/main/java/org/hibernate/processor/Version.java index a0f0f5676e36..0f0fcc0df208 100644 --- a/tooling/metamodel-generator/src/main/java/org/hibernate/processor/Version.java +++ b/tooling/metamodel-generator/src/main/java/org/hibernate/processor/Version.java @@ -6,26 +6,23 @@ import org.hibernate.processor.util.NullnessUtil; -import org.checkerframework.checker.nullness.qual.Nullable; - /** * Information about the Meta Model Generator version. * * @author Hardy Ferentschik */ public final class Version { - private static @Nullable String version; + private static final String VERSION = initVersion(); + + private static String initVersion() { + final String version = NullnessUtil.castNonNull( Version.class.getPackage() ).getImplementationVersion(); + return version != null ? version : "[WORKING]"; + } private Version() { } public static String getVersionString() { - if ( version == null ) { - version = NullnessUtil.castNonNull( Version.class.getPackage() ).getImplementationVersion(); - if ( version == null ) { - version = "[WORKING]"; - } - } - return version; + return VERSION; } }