forked from googleapis/google-cloud-java
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
build: script to set parent pom in each module (googleapis#8383)
* build: set_parent_pom.sh
- Loading branch information
Showing
1 changed file
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |