diff --git a/operator-framework-core/pom.xml b/operator-framework-core/pom.xml
index a7d06ebdc1..e0c6031670 100644
--- a/operator-framework-core/pom.xml
+++ b/operator-framework-core/pom.xml
@@ -128,7 +128,7 @@
${git-commit-id-maven-plugin.version}
true
- ${project.build.outputDirectory}/version.properties
+ ${project.build.outputDirectory}/operator-sdk-version.properties
^git.build.time$
^git.commit.id.(abbrev|full)$
diff --git a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/config/Utils.java b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/config/Utils.java
index 6ad4928c86..4613d9645d 100644
--- a/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/config/Utils.java
+++ b/operator-framework-core/src/main/java/io/javaoperatorsdk/operator/api/config/Utils.java
@@ -42,6 +42,8 @@ public class Utils {
public static final String GENERIC_PARAMETER_TYPE_ERROR_PREFIX =
"Couldn't retrieve generic parameter type from ";
+ public static final String VERSION_PROPERTIES_FILE_NAME = "operator-sdk-version.properties";
+
public static final Version VERSION = loadFromProperties();
/**
@@ -52,7 +54,9 @@ public class Utils {
*/
private static Version loadFromProperties() {
final var is =
- Thread.currentThread().getContextClassLoader().getResourceAsStream("version.properties");
+ Thread.currentThread()
+ .getContextClassLoader()
+ .getResourceAsStream(VERSION_PROPERTIES_FILE_NAME);
final var properties = new Properties();
if (is != null) {
@@ -62,7 +66,9 @@ private static Version loadFromProperties() {
log.warn("Couldn't load version information: {}", e.getMessage());
}
} else {
- log.warn("Couldn't find version.properties file. Default version information will be used.");
+ log.warn(
+ "Couldn't find {} file. Default version information will be used.",
+ VERSION_PROPERTIES_FILE_NAME);
}
Date builtTime;
diff --git a/operator-framework-core/src/test/java/io/javaoperatorsdk/operator/api/config/VersionTest.java b/operator-framework-core/src/test/java/io/javaoperatorsdk/operator/api/config/VersionTest.java
index a8202dd0b3..7fff961ff7 100644
--- a/operator-framework-core/src/test/java/io/javaoperatorsdk/operator/api/config/VersionTest.java
+++ b/operator-framework-core/src/test/java/io/javaoperatorsdk/operator/api/config/VersionTest.java
@@ -18,6 +18,8 @@
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
class VersionTest {
@@ -28,4 +30,13 @@ void versionShouldReturnTheSameResultFromMavenAndProperties() {
assertEquals(versionFromProperties, versionFromMaven);
}
+
+ @Test
+ void versionShouldBeLoadedFromTheGeneratedPropertiesFile() {
+ assertNotNull(
+ Thread.currentThread()
+ .getContextClassLoader()
+ .getResource(Utils.VERSION_PROPERTIES_FILE_NAME));
+ assertNotEquals(Version.UNKNOWN.getCommit(), Utils.VERSION.getCommit());
+ }
}