2012-06-11 19:10:55 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2011-02-10 10:57:07 +00:00
|
|
|
if [ -f /usr/share/java-utils/java-functions ] ; then
|
|
|
|
. /usr/share/java-utils/java-functions
|
|
|
|
set_jvm
|
|
|
|
set_javacmd
|
|
|
|
fi
|
|
|
|
|
|
|
|
function install_metadata()
|
|
|
|
{
|
|
|
|
mkdir -p "$1"
|
|
|
|
tar xf /usr/share/maven/repo-metadata.tar.xz -C "$1"
|
|
|
|
}
|
|
|
|
|
2011-06-06 08:34:24 +00:00
|
|
|
function help()
|
|
|
|
{
|
|
|
|
echo "mvn-rpmbuild [options] [<goal(s)>] [<phase(s)>]"
|
|
|
|
echo
|
|
|
|
echo "mvn-rpmbuild is custom Fedora maven used for building maven projects"
|
|
|
|
echo "using only jar files provided by rpms installed on your system. It will"
|
|
|
|
echo "never download artifacts from remote repositories. You can modify its"
|
|
|
|
echo "behaviour using several environment variables:"
|
|
|
|
echo
|
|
|
|
echo "-Dmaven.repo.local [default:$(pwd)/.m2] - custom location of maven repository"
|
|
|
|
echo "-Dmaven.local.depmap.file - file containing custom dependency mapping between"
|
|
|
|
echo " groupId:artifactId and jar file. File format see:"
|
|
|
|
echo " http://fedoraproject.org/wiki/Java/JPPMavenReadme"
|
|
|
|
echo "-Dmaven.local.debug - if set maven will print additional resolving information"
|
|
|
|
echo " that can be useful for debugging resolver problems"
|
|
|
|
}
|
|
|
|
|
2011-02-10 10:57:07 +00:00
|
|
|
|
|
|
|
# add maven.repo.local if it's not defined already
|
|
|
|
local_add="-Dmaven.repo.local=$(pwd)/.m2/"
|
|
|
|
|
2012-06-11 19:10:55 +00:00
|
|
|
log_file="$(umask 2 && mktemp -t mvn-rpmbuild.$$.XXXXXXXXXX)"
|
|
|
|
logfile_add="-Dmaven.resolver.logfile=$log_file"
|
|
|
|
|
2011-02-10 10:57:07 +00:00
|
|
|
function process_args()
|
|
|
|
{
|
|
|
|
while [ $# != 0 ]; do
|
|
|
|
flag="$1"
|
|
|
|
case "$flag" in
|
2011-06-06 08:34:24 +00:00
|
|
|
-h|--help)
|
|
|
|
help
|
|
|
|
;;
|
2011-02-10 10:57:07 +00:00
|
|
|
*) ind=`expr match "$flag" -Dmaven.repo.local=`
|
|
|
|
if [[ $ind != 0 ]];then
|
|
|
|
install_metadata "${flag/-Dmaven.repo.local=/}/"
|
|
|
|
local_add=""
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
shift
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
|
|
|
process_args "$@"
|
|
|
|
|
|
|
|
if [ -n "$local_add" ];then
|
|
|
|
install_metadata "${local_add/-Dmaven.repo.local=/}/"
|
|
|
|
fi
|
|
|
|
|
|
|
|
export M2_HOME=/usr/share/maven
|
|
|
|
echo $JAVA_HOME
|
|
|
|
export JAVA_HOME
|
|
|
|
# can't put it on command line due to
|
|
|
|
# http://jira.codehaus.org/browse/SUREFIRE-121
|
2012-06-11 19:10:55 +00:00
|
|
|
export MAVEN_OPTS="$MAVEN_OPTS -Dmaven.local.mode ${local_add} ${logfile_add}"
|
|
|
|
|
|
|
|
$M2_HOME/bin/mvn -o "$@" || exit $?
|
|
|
|
|
|
|
|
|
|
|
|
sanitize() {
|
|
|
|
for obj in $1; do
|
|
|
|
echo -n 'mvn-rpmbuild: possibly redundant dependency: '
|
|
|
|
rpm -qf "$(readlink -f $obj)" | sed 's/-[^-]*-[^-]*$//'
|
|
|
|
done | sort -u
|
|
|
|
}
|
|
|
|
|
|
|
|
installed=$(sanitize "$(rpm -ql `package-cleanup --all --leaves | xargs` | egrep '\.(jar|pom)$')")
|
|
|
|
used=$(sanitize "$(cat $log_file 2>/dev/null)")
|
|
|
|
|
|
|
|
diff - /dev/fd/3 <<<"$installed" 3<<<"$used" | grep '^< ' | sed s/..//
|
2011-02-10 10:57:07 +00:00
|
|
|
|
2012-06-11 19:10:55 +00:00
|
|
|
:
|