Skip to content

Commit 62be7f7

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

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

pom.xml

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -200,6 +200,23 @@
200200
</testResource>
201201
</testResources>
202202
<plugins>
203+
<plugin>
204+
<groupId>org.jboss.maven.plugins</groupId>
205+
<artifactId>maven-injection-plugin</artifactId>
206+
<configuration>
207+
<bytecodeInjections>
208+
<bytecodeInjection>
209+
<expression>${project.version}</expression>
210+
<targetMembers>
211+
<methodBodyReturn>
212+
<className>org.hibernate.tool.Version</className>
213+
<methodName>versionString</methodName>
214+
</methodBodyReturn>
215+
</targetMembers>
216+
</bytecodeInjection>
217+
</bytecodeInjections>
218+
</configuration>
219+
</plugin>
203220
<plugin>
204221
<groupId>org.apache.maven.plugins</groupId>
205222
<artifactId>maven-surefire-plugin</artifactId>

src/java/org/hibernate/tool/Version.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55

66
final public class Version {
77

8-
public static final String VERSION = "3.5.4-SNAPSHOT";
9-
108
private static final Version instance = new Version();
9+
10+
public static final String VERSION = instance.versionString();
1111

1212
private static Log log = LogFactory.getLog( Version.class );
1313

@@ -22,6 +22,11 @@ private Version() {
2222
public String getVersion() {
2323
return VERSION;
2424
}
25+
26+
public String versionString() {
27+
// This implementation is replaced during the build with another one that returns the correct value.
28+
return "UNKNOWN";
29+
}
2530

2631
public static Version getDefault() {
2732
return instance;

0 commit comments

Comments
 (0)