Skip to content

Commit 2b6e931

Browse files
authored
chore: use sdk-platform-java-config in downstream checks for spanner and pubsub; update junit-vintage to 5.10.2 (#746)
* chore: use sdk-platform-java-config in downstream checks for spanner and pubsub
1 parent 28b2c77 commit 2b6e931

File tree

2 files changed

+74
-13
lines changed

2 files changed

+74
-13
lines changed

.kokoro/client-library-check.sh

Lines changed: 72 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,55 @@ set -eo pipefail
2121
# Display commands being run.
2222
set -x
2323

24+
function get_current_version_from_versions_txt() {
25+
versions=$1
26+
key=$2
27+
version=$(grep "$key:" "${versions}" | cut -d: -f3) # 3rd field is current
28+
echo "${version}"
29+
}
30+
31+
function get_released_version_from_versions_txt() {
32+
versions=$1
33+
key=$2
34+
version=$(grep "$key:" "${versions}" | cut -d: -f2) # 2nd field is release
35+
echo "${version}"
36+
}
37+
38+
function replace_java_shared_config_version() {
39+
version=$1
40+
# replace version
41+
xmllint --shell <(cat pom.xml) << EOF
42+
setns x=http://maven.apache.org/POM/4.0.0
43+
cd .//x:artifactId[text()="google-cloud-shared-config"]
44+
cd ../x:version
45+
set ${version}
46+
save pom.xml
47+
EOF
48+
}
49+
50+
function replace_java_shared_dependencies_version() {
51+
version=$1
52+
# replace version
53+
xmllint --shell <(cat pom.xml) << EOF
54+
setns x=http://maven.apache.org/POM/4.0.0
55+
cd .//x:properties/x:google-cloud-shared-dependencies.version
56+
set ${version}
57+
save pom.xml
58+
EOF
59+
}
60+
61+
function replace_sdk_platform_java_config_version() {
62+
version=$1
63+
# replace version
64+
xmllint --shell <(cat pom.xml) << EOF
65+
setns x=http://maven.apache.org/POM/4.0.0
66+
cd .//x:artifactId[text()="sdk-platform-java-config"]
67+
cd ../x:version
68+
set ${version}
69+
save pom.xml
70+
EOF
71+
}
72+
2473
if [[ $# -ne 2 ]];
2574
then
2675
echo "Usage: $0 <repo-name> <job-type>"
@@ -42,13 +91,26 @@ mvn install -DskipTests=true -Dmaven.javadoc.skip=true -Dgcloud.download.skip=tr
4291
# Read the current version of this BOM in the POM. Example version: '0.116.1-alpha-SNAPSHOT'
4392
VERSION_POM=java-shared-config/pom.xml
4493
# Namespace (xmlns) prevents xmllint from specifying tag names in XPath
45-
VERSION=`sed -e 's/xmlns=".*"//' ${VERSION_POM} | xmllint --xpath '/project/version/text()' -`
94+
JAVA_SHARED_CONFIG_VERSION=`sed -e 's/xmlns=".*"//' ${VERSION_POM} | xmllint --xpath '/project/version/text()' -`
4695

47-
if [ -z "${VERSION}" ]; then
96+
if [ -z "${JAVA_SHARED_CONFIG_VERSION}" ]; then
4897
echo "Version is not found in ${VERSION_POM}"
4998
exit 1
5099
fi
51-
echo "Version: ${VERSION}"
100+
echo "Version: ${JAVA_SHARED_CONFIG_VERSION}"
101+
102+
# Update java-shared-config in sdk-platform-java-config
103+
git clone "https://github.com/googleapis/sdk-platform-java.git" --depth=1
104+
pushd sdk-platform-java
105+
SDK_PLATFORM_JAVA_CONFIG_VERSION=$(get_current_version_from_versions_txt versions.txt "google-cloud-shared-dependencies")
106+
RELEASED_SHARED_DEPENDENCIES_VERSION=$(get_released_version_from_versions_txt versions.txt "google-cloud-shared-dependencies")
107+
pushd sdk-platform-java-config
108+
109+
# Use released version of google-cloud-shared-dependencies to avoid verifying SNAPSHOT changes.
110+
replace_java_shared_config_version "${JAVA_SHARED_CONFIG_VERSION}"
111+
replace_java_shared_dependencies_version "${RELEASED_SHARED_DEPENDENCIES_VERSION}"
112+
mvn install -DskipTests=true -Dmaven.javadoc.skip=true -Dgcloud.download.skip=true -B -V -q
113+
popd
52114

53115
# Check this BOM against a few java client libraries
54116
# java-bigquery
@@ -60,14 +122,13 @@ fi
60122

61123
pushd ${REPO}
62124

63-
# replace version
64-
xmllint --shell <(cat pom.xml) << EOF
65-
setns x=http://maven.apache.org/POM/4.0.0
66-
cd .//x:artifactId[text()="google-cloud-shared-config"]
67-
cd ../x:version
68-
set ${VERSION}
69-
save pom.xml
70-
EOF
125+
# TODO(#748): Replace the version of sdk-platform-java-config for all libraries. This logic will no longer
126+
# be needed after the rest of the handwritten libraries are migrated to use this artifact.
127+
if [ "$REPO" == "java-spanner" ] || [ "$REPO" == "java-pubsub" ]; then
128+
replace_sdk_platform_java_config_version "${SDK_PLATFORM_JAVA_CONFIG_VERSION}"
129+
else
130+
replace_java_shared_config_version "${JAVA_SHARED_CONFIG_VERSION}"
131+
fi
71132

72133
case ${JOB_TYPE} in
73134
dependencies)

native-image-shared-config/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@
171171
<dependency>
172172
<groupId>org.junit.vintage</groupId>
173173
<artifactId>junit-vintage-engine</artifactId>
174-
<version>5.9.3</version>
174+
<version>5.10.2</version>
175175
<scope>test</scope>
176176
</dependency>
177177
</dependencies>
@@ -185,7 +185,7 @@
185185
<dependency>
186186
<groupId>org.junit.vintage</groupId>
187187
<artifactId>junit-vintage-engine</artifactId>
188-
<version>5.9.3</version>
188+
<version>5.10.2</version>
189189
</dependency>
190190
</dependencies>
191191
<configuration>

0 commit comments

Comments
 (0)