wget -nc http://apache.mirrors.nublue.co.uk/maven/maven-3/3.5.4/binaries/apache-maven-3.5.4-bin.zip
rm -rf apache-maven-3.5.4
unzip apache-maven-3.5.4-bin.zip
export PATH=`pwd`/apache-maven-3.5.4/bin:$PATH
wget -nc http://apache.mirror.anlx.net//ant/binaries/apache-ant-1.10.5-bin.zip
rm -rf apache-ant-1.10.5
unzip apache-ant-1.10.5-bin.zip
export PATH=`pwd`/apache-ant-1.10.5/bin/:$PATH

ant -v || true
mvn -v || true

if [ ! -d tomcat ]; then git clone https://github.com/tomjenkinson/tomcat.git; fi
cd tomcat
git checkout TSR
git reset --hard origin/TSR
ant
mkdir -p ~/.m2/repository/org/apache/tomcat/tomcat-dbcp/9.0.10
cp output/build/lib/tomcat-dbcp.jar ~/.m2/repository/org/apache/tomcat/tomcat-dbcp/9.0.10/tomcat-dbcp-9.0.10.jar
cd ..

if [ ! -d drools ]; then git clone https://github.com/tomjenkinson/drools.git; fi
cd drools
git checkout baqe-439
git reset --hard origin/baqe-439
mvn install -DskipTests
cd drools-persistence
mvn clean install
cd ../..


if [ ! -d jbpm ]; then git clone https://github.com/tomjenkinson/jbpm.git; fi
cd jbpm
git checkout baqe-439
git reset --hard origin/baqe-439
mvn clean install -Dintegration-tests -fn
cd ..
