Skip to content

Commit

Permalink
version info in app
Browse files Browse the repository at this point in the history
  • Loading branch information
Ogefest committed Feb 20, 2021
1 parent 34e09ce commit 71344af
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 2 deletions.
18 changes: 17 additions & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ plugins {
}

group = 'notepack'
version = '0.9.10'
description 'Privacy oriented, without vendor lock in note organizer desktop application.'

sourceCompatibility = 1.9
Expand All @@ -15,6 +14,11 @@ tasks.withType(JavaCompile) {
options.encoding = 'UTF-8'
}

def getCurrentGitTag() {
return 'git describe --tags --abbrev=0'.execute().text.substring(1).trim()
}
version = getCurrentGitTag()


repositories {

Expand Down Expand Up @@ -110,4 +114,16 @@ jpackage {
}
}

processResources {
doFirst {
def date = new Date()
def formattedDate = date.format('yyyyMMddHHmmss')

def resourcesDir = sourceSets.main.output.resourcesDir
resourcesDir.mkdirs()
def contents = "name=$project.name\nversion=" + getCurrentGitTag() + "\nbuild=" + formattedDate + "\n"
new File(resourcesDir, "build-info.properties").text = contents
}
}

mainClassName = 'notepack.Main'
7 changes: 6 additions & 1 deletion src/main/java/notepack/AboutDialogController.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
import javafx.fxml.FXML;
import javafx.fxml.Initializable;
import javafx.scene.control.Button;
import javafx.scene.control.Label;
import notepack.app.domain.PopupController;
import notepack.app.domain.Version;

import java.net.URL;
import java.util.ResourceBundle;
Expand All @@ -18,14 +20,17 @@ public class AboutDialogController extends PopupController implements Initializa
@FXML
private Button btnCancel;

@FXML
private Label versionLabel;

public HostServices hostServices;

/**
* Initializes the controller class.
*/
@Override
public void initialize(URL url, ResourceBundle rb) {
// TODO
versionLabel.setText("Version: " + Version.app());
}

@FXML
Expand Down
1 change: 1 addition & 0 deletions src/main/java/notepack/app/domain/TodoWrapper.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import net.fortuna.ical4j.model.component.CalendarComponent;
import net.fortuna.ical4j.model.component.VTimeZone;
import net.fortuna.ical4j.model.component.VToDo;
import net.fortuna.ical4j.model.property.Version;
import net.fortuna.ical4j.model.property.*;
import notepack.app.domain.exception.MessageError;

Expand Down
20 changes: 20 additions & 0 deletions src/main/java/notepack/app/domain/Version.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package notepack.app.domain;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

public class Version {
public static String app() {
InputStream in = Version.class.getClassLoader().getResourceAsStream("build-info.properties");
Properties props = new Properties();
String version = "unknown";
try {
props.load(in);
version = (String) props.get("version");
} catch (IOException e) {
e.printStackTrace();
}
return version;
}
}
4 changes: 4 additions & 0 deletions src/main/resources/build-info.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
name=Notepack-dev
version=dev
build=1

1 change: 1 addition & 0 deletions src/main/resources/notepack/AboutPopup.fxml
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,6 @@
<Hyperlink layoutX="195.0" layoutY="161.0" onAction="#openBrowser" text="github.com/Ogefest/Notepack"/>
<Button fx:id="btnCancel" cancelButton="true" layoutX="519.0" layoutY="215.0" mnemonicParsing="false"
onAction="#onCancel" text="Close"/>
<Label fx:id="versionLabel" layoutX="265.0" layoutY="133.0" text="Version: 1"/>
</children>
</AnchorPane>

0 comments on commit 71344af

Please sign in to comment.