Add git version to log and --version output
This commit is contained in:
		| @@ -36,6 +36,7 @@ import java.util.logging.FileHandler; | ||||
| import java.util.logging.Logger; | ||||
| import java.util.logging.Level; | ||||
| import java.util.Optional; | ||||
| import java.util.Properties; | ||||
| import javafx.application.Application; | ||||
| import javafx.application.Platform; | ||||
| import javafx.fxml.FXMLLoader; | ||||
| @@ -50,8 +51,6 @@ public class Main extends Application { | ||||
|     public record StartParameters (Optional<NotificationController.NotificationParameters> notification) {} | ||||
|  | ||||
|     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; | ||||
|  | ||||
| @@ -130,6 +129,14 @@ public class Main extends Application { | ||||
|                 primaryStage.titleProperty().bindBidirectional(controller.windowTitle); | ||||
|                 primaryStage.show(); | ||||
|                 logger.info("Application started"); | ||||
|  | ||||
|                 Properties properties = new Properties(); | ||||
|                 try { | ||||
|                     properties.load(getClass().getClassLoader().getResourceAsStream("git.properties")); | ||||
|                     logger.info("Application version: " + String.valueOf(properties.get("git.commit.id.full"))); | ||||
|                 } catch (IOException e) { | ||||
|                     logger.log(Level.SEVERE, "Failed to load git information", e); | ||||
|                 } | ||||
|             } | ||||
|         } catch (IOException e) { | ||||
|             logger.log(Level.SEVERE, "Failed to load main view", e); | ||||
| @@ -167,7 +174,13 @@ public class Main extends Application { | ||||
|         } | ||||
|  | ||||
|         if (parsedArgs.getVersionFlag()) { | ||||
|             System.out.println("Numbers Station version " + VERSION); | ||||
|             Properties properties = new Properties(); | ||||
|             try { | ||||
|                 properties.load(Main.class.getClassLoader().getResourceAsStream("git.properties")); | ||||
|                 System.out.println(String.valueOf(properties.get("git.commit.id.full"))); | ||||
|             } catch (IOException e) { | ||||
|                 System.out.println("Failed to get git information"); | ||||
|             } | ||||
|             System.exit(0); | ||||
|         } | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user