Skip to content

Commit

Permalink
Configuration file.
Browse files Browse the repository at this point in the history
  • Loading branch information
albertus82 committed May 19, 2024
1 parent d61dbb6 commit e8e99ad
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,22 @@

public class ApplicationConfig extends Configuration {

private static final String DIRECTORY_NAME = Util.isLinux() ? '.' + BuildInfo.getProperty("project.artifactId") : BuildInfo.getProperty("project.name");
private static final String DIRECTORY_NAME;
private static final String CFG_FILE_NAME = BuildInfo.getProperty("project.groupId") + '.' + BuildInfo.getProperty("project.artifactId") + ".cfg";

public static final String APPDATA_DIRECTORY = SystemUtils.getOsSpecificLocalAppDataDir() + File.separator + DIRECTORY_NAME;
static {
if (Util.isLinux()) {
DIRECTORY_NAME = '.' + BuildInfo.getProperty("project.artifactId");
}
else if (Util.isMac()) {
DIRECTORY_NAME = "";
}
else {
DIRECTORY_NAME = BuildInfo.getProperty("project.name");
}
}

private static final String CFG_FILE_NAME = (Util.isLinux() ? BuildInfo.getProperty("project.artifactId") : BuildInfo.getProperty("project.name").replace(" ", "")) + ".cfg";
public static final String APPDATA_DIRECTORY = SystemUtils.getOsSpecificLocalAppDataDir() + File.separator + DIRECTORY_NAME;

private static volatile ApplicationConfig instance; // NOSONAR Use a thread-safe type; adding "volatile" is not enough to make this field thread-safe. Use a thread-safe type; adding "volatile" is not enough to make this field thread-safe.
private static volatile IPreferencesConfiguration wrapper; // NOSONAR Use a thread-safe type; adding "volatile" is not enough to make this field thread-safe. Use a thread-safe type; adding "volatile" is not enough to make this field thread-safe.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
project.groupId=${project.groupId}
project.artifactId=${project.artifactId}
project.name=${project.name}
project.version=${project.version}
project.name=${project.name}
version.timestamp=${git.commit.time}
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@

class BuildInfoTest {

private static final Collection<String> expectedPropertyNames = Arrays.asList("project.artifactId", "project.name", "project.version", "version.timestamp");
private static final Collection<String> expectedPropertyNames = Arrays.asList("project.groupId", "project.artifactId", "project.version", "project.name", "version.timestamp");

@Test
void testApi() {
Expand Down

0 comments on commit e8e99ad

Please sign in to comment.