Skip to content

Commit ac3edf0

Browse files
committed
feat: integrate build metadata into project
- Add maven-antrun-plugin to generate build date and git commit hash during the build process. - Update BlueConstants to include buildCommit and buildDate properties. - Modify blueConstants.properties to inject build metadata. - Enhance branding Bundle.properties to display version, commit, and build date information. - Implement resource filtering in branding to include build metadata in final artifacts.
1 parent f61de99 commit ac3edf0

File tree

8 files changed

+159
-2
lines changed

8 files changed

+159
-2
lines changed

ChangeLog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ information.
2828

2929
* Updated Jython interpreter to 2.7.3
3030

31+
* Product Version information now includes commit hash and build date/time
32+
3133
### FIX
3234

3335
* Redid filechooser manager to hold on to Filechoosers so that they will

blue-core/pom.xml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,32 @@
1010
<packaging>nbm</packaging>
1111
<build>
1212
<plugins>
13+
<plugin>
14+
<groupId>org.apache.maven.plugins</groupId>
15+
<artifactId>maven-antrun-plugin</artifactId>
16+
</plugin>
17+
<plugin>
18+
<groupId>org.apache.maven.plugins</groupId>
19+
<artifactId>maven-resources-plugin</artifactId>
20+
<configuration>
21+
<resources>
22+
<resource>
23+
<directory>src/main/resources</directory>
24+
<filtering>true</filtering>
25+
<includes>
26+
<include>blue/blueConstants.properties</include>
27+
</includes>
28+
</resource>
29+
<resource>
30+
<directory>src/main/resources</directory>
31+
<filtering>false</filtering>
32+
<excludes>
33+
<exclude>blue/blueConstants.properties</exclude>
34+
</excludes>
35+
</resource>
36+
</resources>
37+
</configuration>
38+
</plugin>
1339
<plugin>
1440
<groupId>org.apache.netbeans.utilities</groupId>
1541
<artifactId>nbm-maven-plugin</artifactId>

blue-core/src/main/java/blue/BlueConstants.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ public final class BlueConstants {
3737

3838
private static String versionDate = "VERSION_DATE";
3939

40+
private static String buildCommit = "";
41+
42+
private static String buildDate = "";
43+
4044
static {
4145
InputStream constants = BlueConstants.class
4246
.getResourceAsStream("blueConstants.properties");
@@ -45,6 +49,8 @@ public final class BlueConstants {
4549
props.load(constants);
4650
version = props.getProperty("blueVersion");
4751
versionDate = props.getProperty("blueReleaseDate");
52+
buildCommit = props.getProperty("blueBuildCommit", "");
53+
buildDate = props.getProperty("blueBuildDate", "");
4854
} catch (IOException e) {
4955
// TODO Auto-generated catch block
5056
e.printStackTrace();
@@ -82,4 +88,18 @@ public static String getVersionDate() {
8288
return versionDate;
8389
}
8490

91+
/**
92+
* @return Returns the git commit hash (abbreviated) at build time, or empty if unavailable.
93+
*/
94+
public static String getBuildCommit() {
95+
return buildCommit != null ? buildCommit : "";
96+
}
97+
98+
/**
99+
* @return Returns the build date/time at build time, or empty if unavailable.
100+
*/
101+
public static String getBuildDate() {
102+
return buildDate != null ? buildDate : "";
103+
}
104+
85105
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
blueReleaseDate=2024.xx.xx
22
blueVersion=2.9.2
3+
# Injected at build time by Maven resource filtering
4+
blueBuildCommit=${blue.build.commit}
5+
blueBuildDate=${blue.build.date}

branding/pom.xml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,75 @@
2727

2828
<build>
2929
<plugins>
30+
<plugin>
31+
<groupId>org.codehaus.mojo</groupId>
32+
<artifactId>properties-maven-plugin</artifactId>
33+
<version>1.0.0</version>
34+
<executions>
35+
<execution>
36+
<phase>initialize</phase>
37+
<goals>
38+
<goal>read-project-properties</goal>
39+
</goals>
40+
<configuration>
41+
<files>
42+
<file>${basedir}/../blue-core/src/main/resources/blue/blueConstants.properties</file>
43+
</files>
44+
</configuration>
45+
</execution>
46+
</executions>
47+
</plugin>
48+
<plugin>
49+
<groupId>org.apache.maven.plugins</groupId>
50+
<artifactId>maven-antrun-plugin</artifactId>
51+
</plugin>
52+
<plugin>
53+
<groupId>org.apache.maven.plugins</groupId>
54+
<artifactId>maven-resources-plugin</artifactId>
55+
<executions>
56+
<execution>
57+
<id>filter-nbm-branding</id>
58+
<phase>generate-resources</phase>
59+
<goals>
60+
<goal>copy-resources</goal>
61+
</goals>
62+
<configuration>
63+
<outputDirectory>${project.build.directory}/filtered-nbm-branding</outputDirectory>
64+
<resources>
65+
<resource>
66+
<directory>src/main/nbm-branding</directory>
67+
<filtering>false</filtering>
68+
<excludes>
69+
<exclude>modules/org-netbeans-core.jar/org/netbeans/core/ui/Bundle.properties</exclude>
70+
<exclude>core/core.jar/org/netbeans/core/startup/Bundle.properties</exclude>
71+
</excludes>
72+
</resource>
73+
<resource>
74+
<directory>src/main/nbm-branding/modules/org-netbeans-core.jar/org/netbeans/core/ui</directory>
75+
<filtering>true</filtering>
76+
<includes>
77+
<include>Bundle.properties</include>
78+
</includes>
79+
<targetPath>modules/org-netbeans-core.jar/org/netbeans/core/ui</targetPath>
80+
</resource>
81+
<resource>
82+
<directory>src/main/nbm-branding/core/core.jar/org/netbeans/core/startup</directory>
83+
<filtering>true</filtering>
84+
<includes>
85+
<include>Bundle.properties</include>
86+
</includes>
87+
<targetPath>core/core.jar/org/netbeans/core/startup</targetPath>
88+
</resource>
89+
</resources>
90+
</configuration>
91+
</execution>
92+
</executions>
93+
</plugin>
3094
<plugin>
3195
<groupId>org.apache.netbeans.utilities</groupId>
3296
<artifactId>nbm-maven-plugin</artifactId>
3397
<configuration>
98+
<brandingSources>${project.build.directory}/filtered-nbm-branding</brandingSources>
3499
<publicPackages>
35100
<publicPackage>blue.branding</publicPackage>
36101
<publicPackage>blue.branding.*</publicPackage>

branding/src/main/nbm-branding/core/core.jar/org/netbeans/core/startup/Bundle.properties

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
currentVersion=Blue {0}
1+
# No {0} — ProductInformationPanel still passes netbeans.buildnumber; MessageFormat ignores extra args.
2+
# Filtered at build: marketing version from blueConstants.properties, commit/date from antrun.
3+
currentVersion=Blue ${blueVersion} · commit ${blue.build.commit} · built ${blue.build.date}
24
LBL_splash_window_title=Starting Blue
35
SPLASH_WIDTH=500
46
SplashProgressBarBounds=0,240,500,6
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
LBL_Copyright=<div style\="color:#ffffff; font-size\: 12pt; font-family\: Verdana, 'Verdana CE', Arial, 'Arial CE', 'Lucida Grande CE', lucida, 'Helvetica CE', sans-serif; ">Copyright 2000-2022 Steven Yi. All Rights Reserved.</div>
1+
LBL_Copyright=<div style\="color:#ffffff; font-size\: 12pt; font-family\: Verdana, 'Verdana CE', Arial, 'Arial CE', 'Lucida Grande CE', lucida, 'Helvetica CE', sans-serif; ">Copyright 2000-2026 Steven Yi. All Rights Reserved.</div>
22
URL_ON_IMG=https://blue.kunstmusik.com

pom.xml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,45 @@
6464
<reuseForks>true</reuseForks>
6565
</configuration>
6666
</plugin>
67+
<plugin>
68+
<groupId>org.apache.maven.plugins</groupId>
69+
<artifactId>maven-antrun-plugin</artifactId>
70+
<version>3.2.0</version>
71+
<executions>
72+
<execution>
73+
<id>blue-git-short-hash</id>
74+
<phase>initialize</phase>
75+
<goals>
76+
<goal>run</goal>
77+
</goals>
78+
<configuration>
79+
<target>
80+
<tstamp>
81+
<format property="blue.build.date" pattern="yyyy-MM-dd HH:mm" locale="en,UK"/>
82+
</tstamp>
83+
<mkdir dir="${project.build.directory}"/>
84+
<touch file="${project.build.directory}/blue-git-head.txt"/>
85+
<exec executable="git" dir="${maven.multiModuleProjectDirectory}" failonerror="false" output="${project.build.directory}/blue-git-head.txt">
86+
<arg value="rev-parse"/>
87+
<arg value="--short"/>
88+
<arg value="HEAD"/>
89+
</exec>
90+
<loadfile property="blue.git.head.trim" srcFile="${project.build.directory}/blue-git-head.txt">
91+
<filterchain>
92+
<striplinebreaks/>
93+
</filterchain>
94+
</loadfile>
95+
<condition property="blue.build.commit" value="${blue.git.head.trim}" else="unknown">
96+
<not>
97+
<equals arg1="${blue.git.head.trim}" arg2=""/>
98+
</not>
99+
</condition>
100+
</target>
101+
<exportAntProperties>true</exportAntProperties>
102+
</configuration>
103+
</execution>
104+
</executions>
105+
</plugin>
67106
</plugins>
68107
</pluginManagement>
69108
</build>

0 commit comments

Comments
 (0)