#!/bin/sh

if [ -z "$MAVEN_HOME" ]; then
    echo MAVEN_HOME must be set
    exit 1
fi
cd $MAVEN_HOME

if [ -f /etc/java/java.conf ]; then
    . /etc/java/java.conf
fi

rm -rf lib/*
PATH=/usr/bin:$PATH
mkdir -p lib/endorsed
build-jar-repository lib \
    ant \
    ant-launcher \
    ant/ant-antlr \
    ant/ant-apache-bcel \
    ant/ant-apache-bsf \
    ant/ant-apache-log4j \
    ant/ant-apache-oro \
    ant/ant-apache-regexp \
    ant/ant-apache-resolver \
    ant/ant-commons-logging \
    ant/ant-commons-net \
    ant/ant-jai \
    ant/ant-javamail \
    ant/ant-jdepend \
    ant/ant-jmf \
    ant/ant-jsch \
    ant/ant-junit \
    ant/ant-nodeps \
    ant/ant-swing \
    ant/ant-trax \
    commons-beanutils16 \
    commons-betwixt \
    commons-cli \
    commons-collections \
    commons-digester \
    commons-grant \
    commons-graph \
    commons-httpclient \
    commons-io \
    commons-jelly \
    commons-jelly-tags-ant \
    commons-jelly-tags-define \
    commons-jelly-tags-util \
    commons-jelly-tags-xml \
    commons-jexl \
    commons-lang \
    commons-logging \
    dom4j \
    forehead \
    jaxen \
    log4j \
    werkz \
    xml-commons-which \

build-jar-repository lib/endorsed xml-commons-apis xerces-j2

(cd lib
MAVEN_JAR_INST=`build-classpath maven`
[ $? -eq 0 ] && ln -sf $MAVEN_JAR_INST maven.jar
MAVEN_JELLY_TAGS_INST=`build-classpath maven-jelly-tags-1.0.1`
[ $? -eq 0 ] && ln -sf $MAVEN_JELLY_TAGS_INST maven-jelly-tags-1.0.1.jar
)
exit 0
