@@ -21,6 +21,55 @@ set -eo pipefail
21
21
# Display commands being run.
22
22
set -x
23
23
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
+
24
73
if [[ $# -ne 2 ]];
25
74
then
26
75
echo " Usage: $0 <repo-name> <job-type>"
@@ -42,13 +91,26 @@ mvn install -DskipTests=true -Dmaven.javadoc.skip=true -Dgcloud.download.skip=tr
42
91
# Read the current version of this BOM in the POM. Example version: '0.116.1-alpha-SNAPSHOT'
43
92
VERSION_POM=java-shared-config/pom.xml
44
93
# 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()' -`
46
95
47
- if [ -z " ${VERSION } " ]; then
96
+ if [ -z " ${JAVA_SHARED_CONFIG_VERSION } " ]; then
48
97
echo " Version is not found in ${VERSION_POM} "
49
98
exit 1
50
99
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
52
114
53
115
# Check this BOM against a few java client libraries
54
116
# java-bigquery
60
122
61
123
pushd ${REPO}
62
124
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
71
132
72
133
case ${JOB_TYPE} in
73
134
dependencies)
0 commit comments