Skip to content

Instantly share code, notes, and snippets.

@tkatochin
Created October 8, 2015 07:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tkatochin/e3e44e5bfc276b7e302e to your computer and use it in GitHub Desktop.
Save tkatochin/e3e44e5bfc276b7e302e to your computer and use it in GitHub Desktop.
プロジェクトごとにローカルリポジトリを切り替えられることができるようにした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