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

Aps 7938 cli version logging #64

Merged
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
6 changes: 6 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,12 @@
</executions>
</plugin>
</plugins>
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
</build>

<dependencies>
Expand Down
18 changes: 17 additions & 1 deletion src/main/java/com/browserstack/client/BrowserStackRequest.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@
import java.io.InputStream;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.regex.Matcher;
import java.util.regex.Pattern;


public class BrowserStackRequest {

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

public BrowserStackRequest(HttpRequest httpRequest) {
Expand All @@ -42,6 +44,20 @@ private static String getRawBody(InputStream inputStream) throws IOException {
return result.toString("UTF-8");
}

private static String getReleaseProperties(String key) {
Properties properties = new Properties();
try (InputStream input = BrowserStackRequest.class.getClassLoader().getResourceAsStream("release.properties")) {
if (input != null) {
properties.load(input);
String releaseVersion = properties.getProperty("release.version");
return releaseVersion;
}
} catch (IOException e) {
e.printStackTrace();
}
return null;
}

public BrowserStackRequest header(String name, String value) {
httpRequest.getHeaders().put(name, value);
return this;
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/release.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
release.version=@project.version@