Skip to content

Commit 6e7bc56

Browse files
authored
namespace scope properties file (#248)
needed to avoid collisions in shadow / fat JAR files
1 parent 9245733 commit 6e7bc56

5 files changed

Lines changed: 18 additions & 2 deletions

File tree

.github/workflows/test.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ jobs:
3838
steps:
3939
- name: Checkout code
4040
uses: actions/checkout@v4
41+
with:
42+
fetch-depth: 0 # fetch-depth 0 needed for version calculation
4143

4244
- name: Set up JDK ${{ matrix.jdk-distro }} ${{ matrix.jdk-version }}
4345
uses: actions/setup-java@v4

transact/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ dependencies {
4343
testImplementation("io.rest-assured:rest-assured:5.4.0")
4444
testImplementation("io.rest-assured:json-path:5.4.0")
4545
testImplementation("io.rest-assured:xml-path:5.4.0")
46+
testImplementation("org.apache.maven:maven-artifact:3.9.11")
4647
}
4748

4849
tasks.processResources {

transact/src/main/java/dev/dbos/transact/DBOS.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,14 @@ private DBOS() {}
4747
private static final String version = loadVersionFromResources();
4848

4949
private static String loadVersionFromResources() {
50-
final String PROPERTIES_FILE = "/app.properties";
50+
final String PROPERTIES_FILE = "/dev/dbos/transact/app.properties";
5151
final String VERSION_KEY = "app.version";
5252
Properties props = new Properties();
5353
try (InputStream input = DBOS.class.getResourceAsStream(PROPERTIES_FILE)) {
5454

5555
if (input == null) {
5656
logger.warn("Could not find {} resource file", PROPERTIES_FILE);
57-
return "unknown (resource missing)";
57+
return "<unknown (resource missing)>";
5858
}
5959

6060
// Load the properties from the file
File renamed without changes.

transact/src/test/java/dev/dbos/transact/config/ConfigTest.java

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import static org.junit.jupiter.api.Assertions.assertEquals;
55
import static org.junit.jupiter.api.Assertions.assertFalse;
66
import static org.junit.jupiter.api.Assertions.assertNotNull;
7+
import static org.junit.jupiter.api.Assertions.assertTrue;
78

89
import dev.dbos.transact.Constants;
910
import dev.dbos.transact.DBOS;
@@ -19,6 +20,7 @@
1920

2021
import com.zaxxer.hikari.HikariConfig;
2122
import com.zaxxer.hikari.HikariDataSource;
23+
import org.apache.maven.artifact.versioning.ComparableVersion;
2224
import org.junit.jupiter.api.Test;
2325
import org.junit.jupiter.api.extension.ExtendWith;
2426
import uk.org.webcompere.systemstubs.environment.EnvironmentVariables;
@@ -178,4 +180,15 @@ public void configDataSource() throws Exception {
178180
DBOS.shutdown();
179181
}
180182
}
183+
184+
@Test
185+
public void dbosVersion() throws Exception {
186+
assertNotNull(DBOS.version());
187+
assertFalse(DBOS.version().contains("unknown"));
188+
var version = assertDoesNotThrow(() -> new ComparableVersion(DBOS.version()));
189+
190+
// an invalid version string will be parsed as 0.0-qualifier, so make sure
191+
// the value provided is later 0.6 (the initial published version)
192+
assertTrue(version.compareTo(new ComparableVersion("0.6")) > 0);
193+
}
181194
}

0 commit comments

Comments
 (0)