Skip to content

Commit 37f7765

Browse files
committed
HV-1931 Use maven-injection-plugin to set the version string
1 parent 7eacecb commit 37f7765

File tree

3 files changed

+32
-1
lines changed

3 files changed

+32
-1
lines changed

engine/pom.xml

+17
Original file line numberDiff line numberDiff line change
@@ -216,6 +216,23 @@
216216
</testResource>
217217
</testResources>
218218
<plugins>
219+
<plugin>
220+
<groupId>org.jboss.maven.plugins</groupId>
221+
<artifactId>maven-injection-plugin</artifactId>
222+
<configuration>
223+
<bytecodeInjections>
224+
<bytecodeInjection>
225+
<expression>${project.version}</expression>
226+
<targetMembers>
227+
<methodBodyReturn>
228+
<className>org.hibernate.validator.internal.util.Version</className>
229+
<methodName>getVersionString</methodName>
230+
</methodBodyReturn>
231+
</targetMembers>
232+
</bytecodeInjection>
233+
</bytecodeInjections>
234+
</configuration>
235+
</plugin>
219236
<plugin>
220237
<artifactId>maven-compiler-plugin</artifactId>
221238
<executions>

engine/src/main/java/org/hibernate/validator/internal/util/Version.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ public final class Version {
1919
}
2020

2121
public static String getVersionString() {
22-
return Version.class.getPackage().getImplementationVersion();
22+
return "UNKNOWN";
2323
}
2424

2525
public static void touch() {

pom.xml

+14
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@
269269
<version.spotless-maven-plugin>2.43.0</version.spotless-maven-plugin>
270270
<version.jacoco.plugin>0.8.12</version.jacoco.plugin>
271271
<version.sonar.plugin>5.0.0.4389</version.sonar.plugin>
272+
<version.maven.injection.plugin>1.0.2</version.maven.injection.plugin>
272273

273274
<!-- Forbidden API related properties -->
274275
<forbiddenapis-junit.path>forbidden-junit.txt</forbiddenapis-junit.path>
@@ -1587,6 +1588,19 @@
15871588
<artifactId>sonar-maven-plugin</artifactId>
15881589
<version>${version.sonar.plugin}</version>
15891590
</plugin>
1591+
<plugin>
1592+
<groupId>org.jboss.maven.plugins</groupId>
1593+
<artifactId>maven-injection-plugin</artifactId>
1594+
<version>${version.maven.injection.plugin}</version>
1595+
<executions>
1596+
<execution>
1597+
<phase>compile</phase>
1598+
<goals>
1599+
<goal>bytecode</goal>
1600+
</goals>
1601+
</execution>
1602+
</executions>
1603+
</plugin>
15901604
</plugins>
15911605
</pluginManagement>
15921606
</build>

0 commit comments

Comments
 (0)