Skip to content

Commit 9ba3191

Browse files
hari-haran-ssfrancisf
authored andcommitted
Instrument CLI versions upon every release
1 parent ddef867 commit 9ba3191

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

pom.xml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,12 @@
107107
</executions>
108108
</plugin>
109109
</plugins>
110+
<resources>
111+
<resource>
112+
<directory>src/main/resources</directory>
113+
<filtering>true</filtering>
114+
</resource>
115+
</resources>
110116
</build>
111117

112118
<dependencies>

src/main/java/com/browserstack/client/BrowserStackRequest.java

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,8 @@
1919

2020
public class BrowserStackRequest {
2121

22-
private static final String USER_AGENT = "browserstack-automate-java/1.0";
22+
private static final String releaseVersion = (getReleaseProperties("release.version") != null) ? getReleaseProperties("release.version") : "1.0";
23+
private static final String USER_AGENT = "browserstack-automate-java/"+releaseVersion;
2324
private final HttpRequest httpRequest;
2425

2526
public BrowserStackRequest(HttpRequest httpRequest) {
@@ -42,6 +43,23 @@ private static String getRawBody(InputStream inputStream) throws IOException {
4243
return result.toString("UTF-8");
4344
}
4445

46+
private static String getReleaseProperties(String key) {
47+
Properties properties = new Properties();
48+
try (InputStream input = BrowserStackRequest.class.getClassLoader().getResourceAsStream("release.properties")) {
49+
if (input != null) {
50+
properties.load(input);
51+
String releaseVersion = properties.getProperty("release.version");
52+
System.out.println("HARI DEBUG Release Version: " + releaseVersion);
53+
return releaseVersion;
54+
} else {
55+
System.err.println("HARI DEBUG version.properties not found");
56+
}
57+
} catch (IOException e) {
58+
e.printStackTrace();
59+
}
60+
return null;
61+
}
62+
4563
public BrowserStackRequest header(String name, String value) {
4664
httpRequest.getHeaders().put(name, value);
4765
return this;
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
release.version[email protected]@

0 commit comments

Comments
 (0)