Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dynamically creates a version number #18

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,30 @@
<project name="ESPSFlashTool" default="default" basedir=".">
<description>Builds, tests, and runs the project ESPSFlashTool.</description>
<import file="nbproject/build-impl.xml"/>

<target name="-pre-compile">
<tstamp>
<format property="build.date" pattern="yyyyMMdd" />
</tstamp>

<exec executable="git" outputproperty="git.revision">
<arg value="log" />
<arg value="-1" />
<arg value="--pretty=format:%h" />
</exec>

<property name="application.version" value="${build.date}-${git.revision}"/>

<manifest file="MANIFEST.MF">
<attribute name="Version" value="${application.version}" />
</manifest>

<propertyfile file="src/com/forkineye/espsflashtool/espsflashtool.properties">
<entry key="build.date" value="${build.date}" />
<entry key="git.revision" value="${git.revision}" />
<entry key="application.version" value="${application.version}" />
</propertyfile>
</target>

<!-- Copy data contents to dist =-->
<target name="-post-compile">
Expand Down
13 changes: 12 additions & 1 deletion src/com/forkineye/espsflashtool/ESPSFlashToolUI.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.nio.charset.StandardCharsets;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Properties;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import javax.swing.DefaultComboBoxModel;
Expand Down Expand Up @@ -51,6 +52,8 @@ public class ESPSFlashToolUI extends javax.swing.JFrame

private SerialPort lastPort;

private Properties properties = new Properties();

/**
* Creates new form ESPSFlashToolUI
*/
Expand All @@ -66,6 +69,13 @@ public void init()
} catch( Exception ex ) {
System.err.println( "Failed to initialize LaF" );
}

try {
properties.load( Thread.currentThread().getContextClassLoader().getResourceAsStream( "com/forkineye/espsflashtool/espsflashtool.properties" ) );
System.out.println(" Version: " + properties.get( "application.version" ) );
} catch( Exception ex ) {
System.err.println( "Failed to load properties" );
}

// Netbeans init routine
initComponents();
Expand Down Expand Up @@ -375,7 +385,7 @@ private void initComponents() {
);

setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("ESPixelStick Flash Tool");
setTitle("ESPixelStick Flash Tool - " + properties.get( "application.version" ) );
setIconImage(Toolkit.getDefaultToolkit().getImage(ESPSFlashToolUI.class.getResource("Forkineye-icon32.png")));

lblRelease.setFont(new java.awt.Font("Tahoma", 1, 12)); // NOI18N
Expand Down Expand Up @@ -876,6 +886,7 @@ private void jButtonSaveLogsActionPerformed(java.awt.event.ActionEvent evt)//GEN
File LogFilePath = LogFileChooser.getSelectedFile();
try ( FileWriter LogFileWriter = new FileWriter(LogFilePath, false))
{
LogFileWriter.write("ESPSFlashTool Version: " + properties.get( "application.version" ) + "\n\n" );
LogFileWriter.write("System Output: \n\n");
LogFileWriter.write(txtSystemOutput.getText());
LogFileWriter.write("\n\nSerial Output: \n\n");
Expand Down
19 changes: 19 additions & 0 deletions src/com/forkineye/espsflashtool/espsflashtool.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#Sun, 05 Feb 2023 08:42:05 -0500
# Copyright 2023 smore.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.


build.date=20230205
git.revision=efbffab
application.version=20230205-efbffab