Skip to content

Commit df13e59

Browse files
committed
HBX-2962: Inject the version string during the build
Signed-off-by: Koen Aers <[email protected]>
1 parent ba56986 commit df13e59

File tree

2 files changed

+32
-1
lines changed

2 files changed

+32
-1
lines changed

orm/pom.xml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,26 @@
8282
</dependency>
8383
</dependencies>
8484

85+
<build>
86+
<plugins>
87+
<plugin>
88+
<groupId>org.jboss.maven.plugins</groupId>
89+
<artifactId>maven-injection-plugin</artifactId>
90+
<configuration>
91+
<bytecodeInjections>
92+
<bytecodeInjection>
93+
<expression>${project.version}</expression>
94+
<targetMembers>
95+
<methodBodyReturn>
96+
<className>org.hibernate.tool.api.version.Version</className>
97+
<methodName>versionString</methodName>
98+
</methodBodyReturn>
99+
</targetMembers>
100+
</bytecodeInjection>
101+
</bytecodeInjections>
102+
</configuration>
103+
</plugin>
104+
</plugins>
105+
</build>
106+
85107
</project>

orm/src/main/java/org/hibernate/tool/api/version/Version.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,15 @@
22

33
public interface Version {
44

5-
final static String CURRENT_VERSION = "6.3.3-SNAPSHOT";
5+
/**
6+
* @deprecated Use {@link #versionString()} instead.
7+
*/
8+
@Deprecated
9+
final static String CURRENT_VERSION = versionString();
10+
11+
static String versionString() {
12+
// This implementation is replaced during the build with another one that returns the correct value.
13+
return "UNKNOWN";
14+
}
615

716
}

0 commit comments

Comments
 (0)