diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 660e472b..7408a27b 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -2,7 +2,7 @@ name: Producer SDK Java CI with Maven
on:
push:
- branches:
+ branches:
- develop
- master
pull_request:
@@ -12,31 +12,39 @@ on:
jobs:
build:
+ strategy:
+ # Unit and integration tests are not thread safe as they all use the same stream names.
+ max-parallel: 1
+ matrix:
+ os: [ macos-14, ubuntu-22.04, windows-2022 ]
+ java: [ 8, 11, 17, 21 ]
+
runs-on: ${{ matrix.os }}
permissions:
id-token: write
contents: read
- strategy:
- matrix:
- os: [ macos-10.15, ubuntu-18.04, windows-2019]
- java: [ 8, 11, 16 ]
+
steps:
- name: Checkout the repository
- uses: actions/checkout@v2
+ uses: actions/checkout@v4
+
- name: Configure AWS Credentials
- uses: aws-actions/configure-aws-credentials@v1
+ uses: aws-actions/configure-aws-credentials@v4
with:
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
role-session-name: ${{ secrets.AWS_ROLE_SESSION_NAME }}
aws-region: ${{ secrets.AWS_REGION }}
+
- name: Set up JDK
uses: actions/setup-java@v2
with:
java-version: ${{ matrix.java }}
distribution: 'adopt'
cache: maven
+
- name: Build with Maven
run: mvn clean compile assembly:single
+
- name: Run tests
run: |
if [ "$RUNNER_OS" == "Linux" ]; then
diff --git a/pom.xml b/pom.xml
index e4b89894..6d723409 100644
--- a/pom.xml
+++ b/pom.xml
@@ -15,7 +15,7 @@
com.amazonaws
amazon-kinesis-video-streams-producer-sdk-java
Amazon Kinesis Video Streams Producer SDK Java
- 1.12.1
+ 1.12.2
The Amazon Kinesis Video Streams Producer SDK for Java enables Java developers to ingest data into
Amazon Kinesis Video.
@@ -133,7 +133,7 @@
commons-io
commons-io
- 2.11.0
+ 2.14.0
@@ -220,6 +220,15 @@
+
+
+ src/main/resources
+ true
+
+ **/pom.properties
+
+
+
diff --git a/src/main/java/com/amazonaws/kinesisvideo/util/VersionUtil.java b/src/main/java/com/amazonaws/kinesisvideo/util/VersionUtil.java
index ab692f65..9be6385f 100644
--- a/src/main/java/com/amazonaws/kinesisvideo/util/VersionUtil.java
+++ b/src/main/java/com/amazonaws/kinesisvideo/util/VersionUtil.java
@@ -3,10 +3,24 @@
import com.amazonaws.kinesisvideo.common.preconditions.Preconditions;
import javax.annotation.Nonnull;
+import java.io.IOException;
+import java.util.Properties;
public final class VersionUtil {
- public static final String AWS_SDK_KVS_PRODUCER_VERSION_STRING = "1.9.5";
+ private static final String POM_PROPERTIES_FILE = "pom.properties";
+ private static final String POM_PROPERTIES_VERSION_KEY = "version";
+ public static final String AWS_SDK_KVS_PRODUCER_VERSION_STRING;
+
+ static {
+ try {
+ final Properties properties = new Properties();
+ properties.load(VersionUtil.class.getClassLoader().getResourceAsStream(POM_PROPERTIES_FILE));
+ AWS_SDK_KVS_PRODUCER_VERSION_STRING = properties.getProperty(POM_PROPERTIES_VERSION_KEY);
+ } catch (IOException e) {
+ throw new ExceptionInInitializerError("Unable to get project version from pom.xml: " + e);
+ }
+ }
private static final String DEFAULT_USER_AGENT_NAME = "AWS-SDK-KVS";
diff --git a/src/main/resources/pom.properties b/src/main/resources/pom.properties
new file mode 100644
index 00000000..defbd482
--- /dev/null
+++ b/src/main/resources/pom.properties
@@ -0,0 +1 @@
+version=${project.version}
diff --git a/src/test/java/com/amazonaws/kinesisvideo/util/VersionUtilTest.java b/src/test/java/com/amazonaws/kinesisvideo/util/VersionUtilTest.java
new file mode 100644
index 00000000..2f8433a9
--- /dev/null
+++ b/src/test/java/com/amazonaws/kinesisvideo/util/VersionUtilTest.java
@@ -0,0 +1,60 @@
+package com.amazonaws.kinesisvideo.util;
+
+import org.junit.Test;
+
+import java.io.BufferedReader;
+import java.io.FileReader;
+import java.io.IOException;
+
+import static com.amazonaws.kinesisvideo.util.VersionUtil.AWS_SDK_KVS_PRODUCER_VERSION_STRING;
+import static com.amazonaws.kinesisvideo.util.VersionUtil.getUserAgent;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+
+public class VersionUtilTest {
+
+ private static final String POM_XML_LOCATION = "pom.xml";
+
+ @Test
+ public void test_versionString_isNotNullOrEmpty() {
+ final String producerVersionString = AWS_SDK_KVS_PRODUCER_VERSION_STRING;
+ assertNotNull(producerVersionString);
+ assertNotEquals("", producerVersionString);
+ }
+
+ @Test
+ public void test_versionString_isEqualToDeclaredInPomXML() throws IOException {
+ final String producerVersionString = extractVersionFromPomXML();
+
+ assertNotNull("project.version was not found in pom.xml!", producerVersionString);
+ assertNotEquals("", producerVersionString);
+ assertEquals(producerVersionString, AWS_SDK_KVS_PRODUCER_VERSION_STRING);
+ }
+
+ @Test
+ public void test_userAgent_containsProjectVersion() throws IOException {
+ final String userAgent = getUserAgent();
+ final String pomDefinedProjectVersion = extractVersionFromPomXML();
+
+ assertNotNull(userAgent);
+ assertNotEquals("", userAgent);
+
+ assertNotNull(pomDefinedProjectVersion);
+ assertNotEquals("", pomDefinedProjectVersion);
+
+ assertTrue(userAgent.contains(pomDefinedProjectVersion));
+ }
+
+ private String extractVersionFromPomXML() throws IOException {
+ try (final BufferedReader reader = new BufferedReader(new FileReader(POM_XML_LOCATION))) {
+ return reader.lines()
+ .filter(line -> line.contains(""))
+ .map(line -> line.replace("", "")
+ .replace("", "").trim())
+ .findFirst()
+ .orElseThrow(() -> new IllegalStateException("'projectVersion' is not found in " + POM_XML_LOCATION));
+ }
+ }
+}