Skip to content

Commit 84952bc

Browse files
committed
chore: Simplify script
1 parent 9ad46dd commit 84952bc

File tree

2 files changed

+12
-16
lines changed

2 files changed

+12
-16
lines changed

.github/scripts/test_dependency_compatibility.sh

Lines changed: 8 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,6 @@ function print_help() {
2929
echo "Use -l {deps_list} for a comma-separated list of dependencies to test (Format: dep1=1.0,dep2=2.0)"
3030
}
3131

32-
# Function to parse a dependency string and append it to the Maven command
33-
function add_dependency_to_maven_command() {
34-
local dep_pair=$1
35-
if [[ ! "${dep_pair}" =~ .*:.*:.* ]]; then
36-
echo "Malformed dependency string: ${dep_pair}. Expected format: {GroupID}:{ArtifactID}:{Version}:{MavenPropertyName}"
37-
exit 1
38-
fi
39-
local full_dependency=$(echo "${dep_pair}" | rev | cut -d':' -f2- | rev)
40-
local dependency=$(echo "${dep_pair}" | rev | cut -d':' -f1 | rev)
41-
local version=$(echo "${full_dependency}" | awk -F':' '{print $NF}')
42-
MAVEN_COMMAND+=" -D${dependency}.version=${version}"
43-
}
44-
4532
# Default to the upper bounds file in the root of the repo
4633
file='dependencies.txt'
4734
dependency_list=''
@@ -78,7 +65,10 @@ if [ -z "${dependency_list}" ]; then
7865
if [[ "${line}" =~ ^[[:space:]]*# ]] || [[ -z "${line}" ]]; then
7966
continue
8067
fi
81-
add_dependency_to_maven_command "${line}"
68+
# Format from `dependencies.txt`: {GroupID}:{ArtifactID}:{Version}:{MavenPropertyName}
69+
dependency=$(echo "${line}" | cut -d':' -f4)
70+
version=$(echo "${line}" | cut -d':' -f3)
71+
MAVEN_COMMAND+=" -D${dependency}.version=${version}"
8272
done < "${UPPER_BOUND_DEPENDENCY_FILE}"
8373
else # This else block means that a list of dependencies was inputted
8474
# Set the Internal Field Separator (IFS) to a comma.
@@ -92,7 +82,10 @@ else # This else block means that a list of dependencies was inputted
9282
if [ -z "${DEP_PAIR}" ]; then
9383
continue
9484
fi
95-
add_dependency_to_maven_command "${DEP_PAIR}"
85+
# Format: {MavenPropertyName}:{Version}
86+
dependency=$(echo "${DEP_PAIR}" | cut -d':' -f1)
87+
version=$(echo "${DEP_PAIR}" | cut -d':' -f2)
88+
MAVEN_COMMAND+=" -D${dependency}.version=${version}"
9689
done
9790
fi
9891

dependencies.txt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
# This file contains a list of dependencies and their versions to be tested for compatibility.
2-
# The format is `{GroupID}:{ArtifactID}:{Version}:{MavenPropertyName}`. The
2+
# The format is `{GroupID}:{ArtifactID}:{Version}:{MavenPropertyName}`. The GAV coordinates
3+
# (specifically the GroupID and ArtifactID are parsed by renovate to find the artifact from Maven
4+
# Central. Version stores the currently known upper bound. MavenPropertyName corresponds to the
5+
# Maven property value in the pom.xml (it is not a 1:1 mapping to the GAV).
36
# "1P" refers to First-Party dependencies (owned by Google).
47
# "3P" refers to Third-Party dependencies.
58

0 commit comments

Comments
 (0)