#!/bin/bash

DIR="`dirname $0`/..";

STANDARD_JARS=(
	"$DIR/java/alt2xml-cli/dist/alt2xml-cli.jar"
	"$DIR/java/alt2xml-lib-input/dist/alt2xml-lib-input.jar"
);

PLUGINS=(
	"$DIR/java/alt2xml-in-properties/dist/alt2xml-in-properties.jar"
	
	"$DIR/java/alt2xml-in-json/dist/alt2xml-in-json.jar"
	"$DIR/../temp/lib/json_simple-1.1.jar"
);

for e in "${STANDARD_JARS[@]}" "${PLUGINS[@]}"; do
	CLASS_PATH="$CLASS_PATH:$e";
done

MAIN_CLASS="cz.frantovo.alt2xml.cli.CLI";

SAX_PARSER_FACTORY_ALT="cz.frantovo.alt2xml.ParserFactory";                             # our alternative ParserFactory as default
SAX_PARSER_FACTORY_XML="com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl";  # former default factory as fallback 

java \
	-cp "$CLASS_PATH" \
	-D"javax.xml.parsers.SAXParserFactory=$SAX_PARSER_FACTORY_ALT" \
	-D"cz.frantovo.alt2xml.fallback.javax.xml.parsers.SAXParserFactory=$SAX_PARSER_FACTORY_XML" \
	$MAIN_CLASS \
	"$@"

