File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 140140 </configuration >
141141 </plugin >
142142
143+ <plugin >
144+ <groupId >pl.project13.maven</groupId >
145+ <artifactId >git-commit-id-plugin</artifactId >
146+ <version >2.2.4</version >
147+ <executions >
148+ <execution >
149+ <phase >initialize</phase >
150+ <goals >
151+ <goal >revision</goal >
152+ </goals >
153+ </execution >
154+ </executions >
155+ <configuration >
156+ <failOnNoGitDirectory >false</failOnNoGitDirectory >
157+ <failOnUnableToExtractRepoInfo >false</failOnUnableToExtractRepoInfo >
158+ </configuration >
159+ </plugin >
160+
143161 <!-- Read from main.properties the DB configuration -->
144162 <plugin >
145163 <groupId >org.codehaus.mojo</groupId >
Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ public enum SteveConfiguration {
3131
3232 private final String contextPath ;
3333 private final String steveVersion ;
34+ private final String gitDescribe ;
3435 private final ApplicationProfile profile ;
3536 private final Ocpp ocpp ;
3637 private final Auth auth ;
@@ -42,6 +43,7 @@ public enum SteveConfiguration {
4243
4344 contextPath = sanitizeContextPath (p .getOptionalString ("context.path" ));
4445 steveVersion = p .getString ("steve.version" );
46+ gitDescribe = useFallbackIfNotSet (p .getOptionalString ("git.describe" ), null );
4547 profile = ApplicationProfile .fromName (p .getString ("profile" ));
4648
4749 jetty = Jetty .builder ()
@@ -78,6 +80,26 @@ public enum SteveConfiguration {
7880 validate ();
7981 }
8082
83+ public String getSteveCompositeVersion () {
84+ if (gitDescribe == null ) {
85+ return steveVersion ;
86+ } else {
87+ return steveVersion + "-g" + gitDescribe ;
88+ }
89+ }
90+
91+ private static String useFallbackIfNotSet (String value , String fallback ) {
92+ if (value == null ) {
93+ // if the property is optional, value will be null
94+ return fallback ;
95+ } else if (value .startsWith ("${" )) {
96+ // property value variables start with "${" (if maven is not used, the value will not be set)
97+ return fallback ;
98+ } else {
99+ return value ;
100+ }
101+ }
102+
81103 private String sanitizeContextPath (String s ) {
82104 if (s == null || "/" .equals (s )) {
83105 return "" ;
Original file line number Diff line number Diff line change @@ -29,7 +29,7 @@ private InternetChecker() { }
2929 );
3030
3131 static {
32- System .setProperty ("http.agent" , "SteVe/" + SteveConfiguration .CONFIG .getSteveVersion ());
32+ System .setProperty ("http.agent" , "SteVe/" + SteveConfiguration .CONFIG .getSteveCompositeVersion ());
3333 }
3434
3535 /**
Original file line number Diff line number Diff line change @@ -52,5 +52,6 @@ auto.register.unknown.stations = false
5252
5353# ## DO NOT MODIFY ###
5454steve.version = ${project.version}
55+ git.describe = ${git.commit.id.describe}
5556db.sql.logging = true
5657profile = dev
Original file line number Diff line number Diff line change @@ -52,5 +52,6 @@ auto.register.unknown.stations = false
5252
5353# ## DO NOT MODIFY ###
5454steve.version = ${project.version}
55+ git.describe = ${git.commit.id.describe}
5556db.sql.logging = false
5657profile = prod
Original file line number Diff line number Diff line change @@ -52,5 +52,6 @@ auto.register.unknown.stations = false
5252
5353# ## DO NOT MODIFY ###
5454steve.version = ${project.version}
55+ git.describe = ${git.commit.id.describe}
5556db.sql.logging = true
5657profile = test
You can’t perform that action at this time.
0 commit comments