Skip to content

Commit f45428b

Browse files
Release v1.12.2 (#201)
* Fix the CI (#198) * Fix the CI * Limit number of concurrent jobs * Bump commons-io:commons-io from 2.11.0 to 2.14.0 (#200) Bumps commons-io:commons-io from 2.11.0 to 2.14.0. --- updated-dependencies: - dependency-name: commons-io:commons-io dependency-type: direct:production ... Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> * Bump the version from 1.12.1 to 1.12.2 (#202) * Bump the version from 1.12.1 to 1.12.2 * Bump the version for the user agent, make it dynamic, add test to check it matches the value from pom * Adjust variable name and cleanup test * Extract constants --------- Signed-off-by: dependabot[bot] <[email protected]> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
1 parent a1953f1 commit f45428b

File tree

5 files changed

+102
-10
lines changed

5 files changed

+102
-10
lines changed

.github/workflows/ci.yml

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Producer SDK Java CI with Maven
22

33
on:
44
push:
5-
branches:
5+
branches:
66
- develop
77
- master
88
pull_request:
@@ -12,31 +12,39 @@ on:
1212

1313
jobs:
1414
build:
15+
strategy:
16+
# Unit and integration tests are not thread safe as they all use the same stream names.
17+
max-parallel: 1
18+
matrix:
19+
os: [ macos-14, ubuntu-22.04, windows-2022 ]
20+
java: [ 8, 11, 17, 21 ]
21+
1522
runs-on: ${{ matrix.os }}
1623
permissions:
1724
id-token: write
1825
contents: read
19-
strategy:
20-
matrix:
21-
os: [ macos-10.15, ubuntu-18.04, windows-2019]
22-
java: [ 8, 11, 16 ]
26+
2327
steps:
2428
- name: Checkout the repository
25-
uses: actions/checkout@v2
29+
uses: actions/checkout@v4
30+
2631
- name: Configure AWS Credentials
27-
uses: aws-actions/configure-aws-credentials@v1
32+
uses: aws-actions/configure-aws-credentials@v4
2833
with:
2934
role-to-assume: ${{ secrets.AWS_ROLE_TO_ASSUME }}
3035
role-session-name: ${{ secrets.AWS_ROLE_SESSION_NAME }}
3136
aws-region: ${{ secrets.AWS_REGION }}
37+
3238
- name: Set up JDK
3339
uses: actions/setup-java@v2
3440
with:
3541
java-version: ${{ matrix.java }}
3642
distribution: 'adopt'
3743
cache: maven
44+
3845
- name: Build with Maven
3946
run: mvn clean compile assembly:single
47+
4048
- name: Run tests
4149
run: |
4250
if [ "$RUNNER_OS" == "Linux" ]; then

pom.xml

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<groupId>com.amazonaws</groupId>
1616
<artifactId>amazon-kinesis-video-streams-producer-sdk-java</artifactId>
1717
<name>Amazon Kinesis Video Streams Producer SDK Java</name>
18-
<version>1.12.1</version>
18+
<version>1.12.2</version>
1919
<description>The Amazon Kinesis Video Streams Producer SDK for Java enables Java developers to ingest data into
2020
Amazon Kinesis Video.
2121
</description>
@@ -133,7 +133,7 @@
133133
<dependency>
134134
<groupId>commons-io</groupId>
135135
<artifactId>commons-io</artifactId>
136-
<version>2.11.0</version>
136+
<version>2.14.0</version>
137137
</dependency>
138138
<!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpasyncclient -->
139139
<dependency>
@@ -220,6 +220,15 @@
220220
</configuration>
221221
</plugin>
222222
</plugins>
223+
<resources>
224+
<resource>
225+
<directory>src/main/resources</directory>
226+
<filtering>true</filtering>
227+
<includes>
228+
<include>**/pom.properties</include>
229+
</includes>
230+
</resource>
231+
</resources>
223232
</build>
224233
</project>
225234

src/main/java/com/amazonaws/kinesisvideo/util/VersionUtil.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,24 @@
33
import com.amazonaws.kinesisvideo.common.preconditions.Preconditions;
44

55
import javax.annotation.Nonnull;
6+
import java.io.IOException;
7+
import java.util.Properties;
68

79
public final class VersionUtil {
810

9-
public static final String AWS_SDK_KVS_PRODUCER_VERSION_STRING = "1.9.5";
11+
private static final String POM_PROPERTIES_FILE = "pom.properties";
12+
private static final String POM_PROPERTIES_VERSION_KEY = "version";
13+
public static final String AWS_SDK_KVS_PRODUCER_VERSION_STRING;
14+
15+
static {
16+
try {
17+
final Properties properties = new Properties();
18+
properties.load(VersionUtil.class.getClassLoader().getResourceAsStream(POM_PROPERTIES_FILE));
19+
AWS_SDK_KVS_PRODUCER_VERSION_STRING = properties.getProperty(POM_PROPERTIES_VERSION_KEY);
20+
} catch (IOException e) {
21+
throw new ExceptionInInitializerError("Unable to get project version from pom.xml: " + e);
22+
}
23+
}
1024

1125
private static final String DEFAULT_USER_AGENT_NAME = "AWS-SDK-KVS";
1226

src/main/resources/pom.properties

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
version=${project.version}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
package com.amazonaws.kinesisvideo.util;
2+
3+
import org.junit.Test;
4+
5+
import java.io.BufferedReader;
6+
import java.io.FileReader;
7+
import java.io.IOException;
8+
9+
import static com.amazonaws.kinesisvideo.util.VersionUtil.AWS_SDK_KVS_PRODUCER_VERSION_STRING;
10+
import static com.amazonaws.kinesisvideo.util.VersionUtil.getUserAgent;
11+
import static org.junit.Assert.assertEquals;
12+
import static org.junit.Assert.assertNotEquals;
13+
import static org.junit.Assert.assertNotNull;
14+
import static org.junit.Assert.assertTrue;
15+
16+
public class VersionUtilTest {
17+
18+
private static final String POM_XML_LOCATION = "pom.xml";
19+
20+
@Test
21+
public void test_versionString_isNotNullOrEmpty() {
22+
final String producerVersionString = AWS_SDK_KVS_PRODUCER_VERSION_STRING;
23+
assertNotNull(producerVersionString);
24+
assertNotEquals("", producerVersionString);
25+
}
26+
27+
@Test
28+
public void test_versionString_isEqualToDeclaredInPomXML() throws IOException {
29+
final String producerVersionString = extractVersionFromPomXML();
30+
31+
assertNotNull("project.version was not found in pom.xml!", producerVersionString);
32+
assertNotEquals("", producerVersionString);
33+
assertEquals(producerVersionString, AWS_SDK_KVS_PRODUCER_VERSION_STRING);
34+
}
35+
36+
@Test
37+
public void test_userAgent_containsProjectVersion() throws IOException {
38+
final String userAgent = getUserAgent();
39+
final String pomDefinedProjectVersion = extractVersionFromPomXML();
40+
41+
assertNotNull(userAgent);
42+
assertNotEquals("", userAgent);
43+
44+
assertNotNull(pomDefinedProjectVersion);
45+
assertNotEquals("", pomDefinedProjectVersion);
46+
47+
assertTrue(userAgent.contains(pomDefinedProjectVersion));
48+
}
49+
50+
private String extractVersionFromPomXML() throws IOException {
51+
try (final BufferedReader reader = new BufferedReader(new FileReader(POM_XML_LOCATION))) {
52+
return reader.lines()
53+
.filter(line -> line.contains("<version>"))
54+
.map(line -> line.replace("<version>", "")
55+
.replace("</version>", "").trim())
56+
.findFirst()
57+
.orElseThrow(() -> new IllegalStateException("'<version>projectVersion</version>' is not found in " + POM_XML_LOCATION));
58+
}
59+
}
60+
}

0 commit comments

Comments
 (0)