Skip to content

Commit

Permalink
build: script to set parent pom in each module (googleapis#8383)
Browse files Browse the repository at this point in the history
* build: set_parent_pom.sh
  • Loading branch information
suztomo authored Sep 13, 2022
1 parent a352332 commit c3b9bc6
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions generation/set_parent_pom.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash

set -ef

# For each library module in current working directory, this script
# sets the parent to the root pom.xml

# Run this script at the root of google-cloud-java repository

# First, read the values from the root pom.xml
parent_version=$(perl -nle 'print $1 if m|<version>(.+)</version>|' pom.xml |head -1)
parent_group_id=$(perl -nle 'print $1 if m|<groupId>(.+)</groupId>|' pom.xml |head -1)
parent_artifact_id=$(perl -nle 'print $1 if m|<artifactId>(.+)</artifactId>|' pom.xml |head -1)

# Then, apply the values as the parent pom of each module
for module in $(find . -mindepth 2 -maxdepth 2 -name pom.xml |sort | xargs dirname); do
# example value of module is "./java-accessapproval"
if [[ "${module}" = *google-cloud-gapic-bom ]] || [[ "${module}" = *CoverageAggregator ]]; then
continue
fi
echo "Processing module $module"
pushd $module
# Search for <parent> tag in module pom and replace the next three lines -- groupId, artifcatId, and version
sed -i.bak -e "/<parent>/{N;s|<groupId>.*</groupId>|<groupId>${parent_group_id}</groupId>|;N;s|<artifactId>.*</artifactId>|<artifactId>${parent_artifact_id}</artifactId>|;N;s|<version>.*</version>|<version>${parent_version}</version>|}" pom.xml
rm pom.xml.bak
popd
done

0 comments on commit c3b9bc6

Please sign in to comment.