Skip to content

Commit

Permalink
parent version set to project version.
Browse files Browse the repository at this point in the history
  • Loading branch information
zhumin8 committed Nov 22, 2022
1 parent 1fd4a73 commit 9fd06ed
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
7 changes: 6 additions & 1 deletion generator/generate-all.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

WORKING_DIR=`pwd`

cd ../
# Compute the project version.
PROJECT_VERSION=$(./mvnw help:evaluate -Dexpression=project.version -q -DforceStdout)
cd generator

# runs generate-one.sh for each entry in library_list.txt
# repos are downloaded once before all generation jobs and then removed

Expand All @@ -12,7 +17,7 @@ while IFS=, read -r library_name googleapis_location coordinates_version; do
group_id=$(echo $coordinates_version | cut -f1 -d:)
artifact_id=$(echo $coordinates_version | cut -f2 -d:)
version=$(echo $coordinates_version | cut -f3 -d:)
bash $WORKING_DIR/generate-one.sh -c $library_name -v $version -i $artifact_id -g $group_id
bash $WORKING_DIR/generate-one.sh -c $library_name -v $version -i $artifact_id -g $group_id -p $PROJECT_VERSION
done <<< $libraries

rm -rf googleapis
Expand Down
5 changes: 4 additions & 1 deletion generator/generate-one.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,22 @@

# by default, do not download repos
download_repos=0
while getopts c:v:i:g:d: flag
while getopts c:v:i:g:d:p: flag
do
case "${flag}" in
c) client_lib_name=${OPTARG};;
v) version=${OPTARG};;
i) client_lib_artifactid=${OPTARG};;
g) client_lib_groupid=${OPTARG};;
p) parent_version=${OPTARG};;
d) download_repos=1;;
esac
done
echo "Client Library Name: $client_lib_name";
echo "Client Library Version: $version";
echo "Client Library GroupId: $client_lib_groupid";
echo "Client Library ArtifactId: $client_lib_artifactid";
echo "Parent Pom Version: $parent_version";

starter_artifactid="$client_lib_artifactid-spring-starter"

Expand Down Expand Up @@ -60,6 +62,7 @@ cat "$client_lib_name"/pom.xml
sed -i 's/{{client-library-group-id}}/'"$client_lib_groupid"'/' "$client_lib_name"/pom.xml
sed -i 's/{{client-library-artifact-id}}/'"$client_lib_artifactid"'/' "$client_lib_name"/pom.xml
sed -i 's/{{client-library-version}}/'"$version"'/' "$client_lib_name"/pom.xml
sed -i 's/{{parent-version}}/'"$parent_version"'/' "$client_lib_name"/pom.xml

# add module to parent, adds after the `<modules>` line, checks for existence
xmllint --debug --nsclean --xpath "//*[local-name()='module']/text()" pom.xml | sort | uniq | grep -q $client_lib_name
Expand Down

0 comments on commit 9fd06ed

Please sign in to comment.