Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
プロジェクトごとにローカルリポジトリを切り替えられることができるようにしたmvn
#!/bin/sh
export repo_path=
export ancestor=.
while [ "/" != "`cd $ancestor;pwd`" -a ! -d $ancestor/.m2/repository ]; do
export ancestor=../${ancestor}
done
if [ -d $ancestor/.m2/repository ]; then
export repo_path=`cd $ancestor/.m2/repository;pwd`
else
if [ -d ~/.m2/repository ]; then
export repo_path=`cd ~/.m2/repository;pwd`
else
echo Not found .m2/repository
exit 1
fi
fi
export esc_path=${repo_path////\\/}
export repo_change_exp="s/<localRepository>.*<\\/localRepository>/<localRepository>${esc_path}<\\/localRepository>/"
#echo $repo_change_exp
sed -i".org" -E $repo_change_exp ~/.m2/settings.xml
/usr/local/bin/mvn $@
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment