Factor out config path
This commit is contained in:
parent
e559508507
commit
13355ce401
19
pom.xml
19
pom.xml
@ -126,6 +126,25 @@
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>io.github.git-commit-id</groupId>
|
||||
<artifactId>git-commit-id-maven-plugin</artifactId>
|
||||
<version>9.0.1</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>get-the-git-infos</id>
|
||||
<goals>
|
||||
<goal>revision</goal>
|
||||
</goals>
|
||||
<phase>initialize</phase>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<generateGitPropertiesFile>true</generateGitPropertiesFile>
|
||||
<generateGitPropertiesFilename>${project.build.outputDirectory}/git.properties</generateGitPropertiesFilename>
|
||||
<commitIdGenerationMode>full</commitIdGenerationMode>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
|
@ -52,8 +52,24 @@ public class Main extends Application {
|
||||
private static final Logger logger = Logger.getLogger(Main.class.getName());
|
||||
// TODO: get git info
|
||||
private static final String VERSION = "0.0.1";
|
||||
private static Path configPath = null;
|
||||
private static Path statePath = null;
|
||||
|
||||
public static Path getConfigPath() {
|
||||
if (configPath == null) {
|
||||
String configHome = System.getenv("XDG_CONFIG_HOME");
|
||||
|
||||
if (configHome != null && !configHome.isEmpty() && Paths.get(configHome).isAbsolute()) {
|
||||
configPath = Paths.get(configHome, "numbers-station");
|
||||
} else {
|
||||
String userHome = System.getProperty("user.home");
|
||||
configPath = Paths.get(userHome, ".config", "numbers-station");
|
||||
}
|
||||
}
|
||||
|
||||
return configPath;
|
||||
}
|
||||
|
||||
public static Path getStatePath() {
|
||||
if (statePath == null) {
|
||||
String stateHome = System.getenv("XDG_STATE_HOME");
|
||||
|
@ -31,17 +31,7 @@ public class MainSettings {
|
||||
}
|
||||
|
||||
public static Path getSettingsFilePath() {
|
||||
String configHome = System.getenv("XDG_CONFIG_HOME");
|
||||
Path directoryPath;
|
||||
|
||||
if (configHome != null && !configHome.isEmpty() && Paths.get(configHome).isAbsolute()) {
|
||||
directoryPath = Paths.get(configHome, "numbers-station");
|
||||
} else {
|
||||
String userHome = System.getProperty("user.home");
|
||||
directoryPath = Paths.get(userHome, ".config", "numbers-station");
|
||||
}
|
||||
|
||||
return directoryPath.resolve("main-settings.xml");
|
||||
return Main.getConfigPath().resolve("main-settings.xml");
|
||||
}
|
||||
|
||||
public ArrayList<StationSettings> getStations() {
|
||||
|
@ -128,22 +128,12 @@ public class StationSettings {
|
||||
}
|
||||
|
||||
public Path stationPath() {
|
||||
String configHome = System.getenv("XDG_CONFIG_HOME");
|
||||
Path directoryPath;
|
||||
|
||||
if (configHome != null && !configHome.isEmpty() && Paths.get(configHome).isAbsolute()) {
|
||||
directoryPath = Paths.get(configHome, "numbers-station");
|
||||
} else {
|
||||
String userHome = System.getProperty("user.home");
|
||||
directoryPath = Paths.get(userHome, ".config", "numbers-station");
|
||||
}
|
||||
|
||||
String stationDirName = null;
|
||||
try {
|
||||
stationDirName = java.net.URLEncoder.encode(name, "UTF-8");
|
||||
} catch(UnsupportedEncodingException e) {} // We know UTF-8 is supported
|
||||
|
||||
return directoryPath.resolve(stationDirName);
|
||||
return Main.getConfigPath().resolve(stationDirName);
|
||||
}
|
||||
|
||||
public String generateMessage(int generationAttempts) throws MessageGenerationException {
|
||||
|
Loading…
x
Reference in New Issue
Block a user