blob: 9540ac5949a473adf4758754f26e6175eb24ea5c [file] [log] [blame]
Gary Wud04e4402017-07-28 12:26:54 -07001#!/bin/bash
2##############################################################################
3# Copyright (c) 2015, 2016 The Linux Foundation. All rights reserved.
4##############################################################################
5
6# autorelease root dir
7ROOT=`git rev-parse --show-toplevel`/autorelease
8
9BUILD_DIR=$ROOT/build
10
11mkdir -p $BUILD_DIR
12cd $BUILD_DIR
13
14# MAP of path to a parent pom from the perspective of hosting directory
15# starting from the autorelease repo root.
16#
17# Format: <groupId>:<artifactId>:<path>
18
19fix_name() {
20 pom=$1
21 echo -e "\nScanning $pom"
22 pomPath=`dirname $pom`
23
24 projectPath=${pomPath#*/} # Path to pom file from the perspective of hosting repo
25
26 relativePath="$projectPath" # Calculated relative path to parent pom
27
28 # Update any existing project names
29 xmlstarlet ed -P -N x=http://maven.apache.org/POM/4.0.0 \
30 -u "/x:project/x:name" -v "$relativePath" \
31 "$pom" > "${pom}.new"
32 mv "${pom}.new" "${pom}"
33
34 # Add missing ones
35 xmlstarlet ed -P -N x=http://maven.apache.org/POM/4.0.0 \
36 -s "/x:project[count(x:name)=0]" -t elem -n name -v "$relativePath" \
37 "$pom" > "${pom}.new"
38 mv "${pom}.new" "${pom}"
39}
40
41# Find all project poms ignoring the /src/ paths (We don't want to scan code)
42find . -name pom.xml -not -path "*/src/*" | xargs -I^ -P8 bash -c "$(declare -f fix_name); fix_name ^"