#Ensure CompositeName is set and has no trailing space
LENGTH=${#CompositeName}
if [ -z ${CompositeName} ] || [ "${CompositeName:$(($LENGTH-1)):1}" = " " ]; then
echo "CompositeName must be set and not contain trailing spaces"
false
fi
#Ensure CompositeSearchPoint is set and does not begin with a / and has no trailing space
LENGTH=${#CompositeSearchPoint}
if [ -z ${CompositeSearchPoint} ] || [ "${CompositeFolder:0:1}" = "/" ] || [ "${CompositeFolder:$(($LENGTH-1)):1}" = " " ]; then
echo "CompositeSearchPoint must be set and not start with a / character or containing trailing spaces."
false
fi
#Find the folder containing the composite.xml file for the specified CompositeName.
#Exclude versions of the file found in .svn folders or found in binary files like jars
#Trim the path to the last / to determine the folder name
#Trim the front of the path to remove the first folder name since it is relative to the start of the find
#Save the result in file for use in future build steps
$(find ${CompositeSearchPoint} -name composite.xml -exec grep -H -I -r name=\"${CompositeName} {} \; | sed '/.svn/d'| sed "s/\/[^\/]*$//" > ./compositesList)
#Raise Error if more than one folder found, for example from duplicate composites found in svn tree
if [ $(wc -l < ./compositesList) -gt 1 ]; then
echo "Error: more than one composite named ${CompositeName} found in source tree at:"
cat ./compositesList
false
fi