From 9fd06ed1fda81864f212d583b032795ea2f99215 Mon Sep 17 00:00:00 2001 From: Min Zhu Date: Tue, 22 Nov 2022 15:06:33 +0000 Subject: [PATCH] parent version set to project version. --- generator/generate-all.sh | 7 ++++++- generator/generate-one.sh | 5 ++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/generator/generate-all.sh b/generator/generate-all.sh index 457b203a34..ab9be3419c 100644 --- a/generator/generate-all.sh +++ b/generator/generate-all.sh @@ -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 @@ -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 diff --git a/generator/generate-one.sh b/generator/generate-one.sh index 8cb691b670..c1cee19ea5 100755 --- a/generator/generate-one.sh +++ b/generator/generate-one.sh @@ -9,13 +9,14 @@ # 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 @@ -23,6 +24,7 @@ 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" @@ -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 `` line, checks for existence xmllint --debug --nsclean --xpath "//*[local-name()='module']/text()" pom.xml | sort | uniq | grep -q $client_lib_name