I have a similar script that I use:
#!/bin/ksh
until [ -f pom.xml -o . -ef / -o . -ef "$HOME" ]
do
cd ..
done
exec /opt/maven/bin/mvn "$@"
To get the effect of your script, modify the last line to:
exec /opt/maven/bin/mvn -Dmaven.repo.local="$PWD" "$@"
(Oh, and everyone should learn the critical difference between $* and "$@".)
The only problem with that is that it doesn't really work well for
nested projects. Each project in the hierarchy gets its own repository,
which doesn't work if they need to share artifacts in the local
repository. My approach works at the level of a "workspace" instead of
a maven project.