Skip to content

Commit

Permalink
Indent build.sh properly; enhance comments culture.
Browse files Browse the repository at this point in the history
  • Loading branch information
OndraZizka committed Oct 27, 2011
1 parent 9f85699 commit 36ba6b8
Showing 1 changed file with 79 additions and 80 deletions.
159 changes: 79 additions & 80 deletions build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,20 +22,20 @@ MAVEN_HOME=""
MAVEN_OPTS="$MAVEN_OPTS -Xmx512M"
export MAVEN_OPTS

# the default search path for maven
# Default search path for maven.
MAVEN_SEARCH_PATH="\
tools
tools/maven \
tools/apache/maven \
maven"

# the default arguments
# Default arguments
MVN_OPTIONS="-s tools/maven/conf/settings.xml"

# Use the maximum available, or set MAX_FD != -1 to use that
# Use the maximum available, or set MAX_FD != -1 to use that
MAX_FD="maximum"

# OS specific support (must be 'true' or 'false').
# OS specific support (must be 'true' or 'false').
cygwin=false;
darwin=false;
case "`uname`" in
Expand All @@ -49,146 +49,145 @@ case "`uname`" in
esac

#
# Helper to complain.
# Helper to complain.
#
die() {
echo "${PROGNAME}: $*"
exit 1
}

#
# Helper to complain.
# Helper to complain.
#
warn() {
echo "${PROGNAME}: $*"
}

#
# Helper to source a file if it exists.
# Helper to source a file if it exists.
#
maybe_source() {
source_if_exists() {
for file in $*; do
if [ -f "$file" ]; then
. $file
fi
if [ -f "$file" ]; then
. $file
fi
done
}

search() {
find_maven() {
search="$*"
for d in $search; do
MAVEN_HOME="`pwd`/$d"
MVN="$MAVEN_HOME/bin/mvn"
if [ -x "$MVN" ]; then
# found one
echo $MAVEN_HOME
break
fi
MAVEN_HOME="`pwd`/$d"
MVN="$MAVEN_HOME/bin/mvn"
if [ -x "$MVN" ]; then
# Found.
echo $MAVEN_HOME
break
fi
done
}

#
# Main function.
# Main function.
#
main() {
# if there is a build config file. then source it
maybe_source "$DIRNAME/build.conf" "$HOME/.build.conf"
# If there is a build config file, source it.
source_if_exists "$DIRNAME/build.conf" "$HOME/.build.conf"

# Increase the maximum file descriptors if we can
# Increase the maximum file descriptors if we can.
if [ $cygwin = "false" ]; then
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ]; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ]; then
# use the system max
MAX_FD="$MAX_FD_LIMIT"
fi

ulimit -n $MAX_FD
if [ $? -ne 0 ]; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query system maximum file descriptor limit: $MAX_FD_LIMIT"
fi
MAX_FD_LIMIT=`ulimit -H -n`
if [ $? -eq 0 ]; then
if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ]; then
# Use system's max.
MAX_FD="$MAX_FD_LIMIT"
fi

ulimit -n $MAX_FD
if [ $? -ne 0 ]; then
warn "Could not set maximum file descriptor limit: $MAX_FD"
fi
else
warn "Could not query system maximum file descriptor limit: $MAX_FD_LIMIT"
fi
fi

# try the search path
MAVEN_HOME=`search $MAVEN_SEARCH_PATH`
# Try the search path.
MAVEN_HOME=`find_maven $MAVEN_SEARCH_PATH`

# try looking up to root
# Try looking up to root.
if [ "x$MAVEN_HOME" = "x" ]; then
target="build"
_cwd=`pwd`

while [ "x$MAVEN_HOME" = "x" ] && [ "$cwd" != "$ROOT" ]; do
cd ..
cwd=`pwd`
MAVEN_HOME=`search $MAVEN_SEARCH_PATH`
done

# make sure we get back
cd $_cwd

if [ "$cwd" != "$ROOT" ]; then
found="true"
fi

# complain if we did not find anything
if [ "$found" != "true" ]; then
die "Could not locate Maven; check \$MVN or \$MAVEN_HOME."
fi
target="build"
_cwd=`pwd`

while [ "x$MAVEN_HOME" = "x" ] && [ "$cwd" != "$ROOT" ]; do
cd ..
cwd=`pwd`
MAVEN_HOME=`find_maven $MAVEN_SEARCH_PATH`
done

# Make sure we get back.
cd $_cwd

if [ "$cwd" != "$ROOT" ]; then
found="true"
fi

# Complain if we did not find anything.
if [ "$found" != "true" ]; then
die "Could not locate Maven; check \$MVN or \$MAVEN_HOME."
fi
fi

# make sure we have one
# Make sure we have one.
MVN=$MAVEN_HOME/bin/mvn
if [ ! -x "$MVN" ]; then
die "Maven file is not executable: $MVN"
die "Maven file is not executable: $MVN"
fi

# need to specify planet57/buildmagic protocol handler package
# Need to specify planet57/buildmagic protocol handler package.
MVN_OPTS="-Djava.protocol.handler.pkgs=org.jboss.net.protocol"

# setup some build properties
# Setup some build properties
MVN_OPTS="$MVN_OPTS -Dbuild.script=$0"

# change to the directory where the script lives so users are not forced
# to be in the same directory as build.xml
# Change to the directory where the script lives, so users are not forced
# to be in the same directory as build.xml.
cd $DIRNAME

MVN_GOAL=$@
if [ -z "$MVN_GOAL" ]; then
MVN_GOAL="install"
MVN_GOAL="install"
fi

. testsuite/groupDefs.sh

# add smoke integration test directives before calling maven
# Add smoke integration test directives before calling maven.
TESTS=$SMOKE_TESTS
# for each parameter, check for testsuite directives
# For each parameter, check for testsuite directives.
for param in $@ ; do
case $param in
-DallTests)
TESTS=$ALL_TESTS ;;
esac
case $param in
-DallTests)
TESTS=$ALL_TESTS ;;
esac
done

MVN_GOAL="$MVN_GOAL $TESTS"

# export some stuff for maven
# Export some stuff for maven.
export MVN MAVEN_HOME MVN_OPTS MVN_GOAL

echo "$MVN $MVN_OPTIONS $MVN_GOAL"

# execute in debug mode, or simply execute
# Execute in debug mode, or simply execute.
if [ "x$MVN_DEBUG" != "x" ]; then
/bin/sh -x $MVN $MVN_OPTIONS $MVN_GOAL
/bin/sh -x $MVN $MVN_OPTIONS $MVN_GOAL
else
exec $MVN $MVN_OPTIONS $MVN_GOAL
exec $MVN $MVN_OPTIONS $MVN_GOAL
fi
}

##
## Bootstrap
## Bootstrap
##

main "$@"

0 comments on commit 36ba6b8

Please sign in to comment.