Skip to content

Commit c3b9bc6

Browse files
authored
build: script to set parent pom in each module (googleapis#8383)
* build: set_parent_pom.sh
1 parent a352332 commit c3b9bc6

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

generation/set_parent_pom.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/bash
2+
3+
set -ef
4+
5+
# For each library module in current working directory, this script
6+
# sets the parent to the root pom.xml
7+
8+
# Run this script at the root of google-cloud-java repository
9+
10+
# First, read the values from the root pom.xml
11+
parent_version=$(perl -nle 'print $1 if m|<version>(.+)</version>|' pom.xml |head -1)
12+
parent_group_id=$(perl -nle 'print $1 if m|<groupId>(.+)</groupId>|' pom.xml |head -1)
13+
parent_artifact_id=$(perl -nle 'print $1 if m|<artifactId>(.+)</artifactId>|' pom.xml |head -1)
14+
15+
# Then, apply the values as the parent pom of each module
16+
for module in $(find . -mindepth 2 -maxdepth 2 -name pom.xml |sort | xargs dirname); do
17+
# example value of module is "./java-accessapproval"
18+
if [[ "${module}" = *google-cloud-gapic-bom ]] || [[ "${module}" = *CoverageAggregator ]]; then
19+
continue
20+
fi
21+
echo "Processing module $module"
22+
pushd $module
23+
# Search for <parent> tag in module pom and replace the next three lines -- groupId, artifcatId, and version
24+
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
25+
rm pom.xml.bak
26+
popd
27+
done

0 commit comments

Comments
 (0)