#!/bin/bash
#
# google-java-format script
# JPackage Project <http://www.jpackage.org/>

# Set default JAVA_HOME
JAVA_HOME="${JAVA_HOME:-/usr/lib64/jvm/java}"

# Source functions library
. /usr/share/java-utils/java-functions

# Source system prefs
if [ -f /etc/java/google-java-format.conf ] ; then
  . /etc/java/google-java-format.conf
fi

# Source user prefs
if [ -f $HOME/.google-java-formatrc ] ; then
  . $HOME/.google-java-formatrc
fi

# Configuration
MAIN_CLASS=com.google.googlejavaformat.java.Main
BASE_FLAGS=""
BASE_OPTIONS="--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED
--add-exports=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED
--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED
--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED
--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED
--add-exports=jdk.compiler/com.sun.tools.javac.tree=ALL-UNNAMED
--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED
"
BASE_JARS="google-java-format guava auto google-errorprone"

# Set parameters
set_classpath $BASE_JARS
set_flags $BASE_FLAGS
set_options $BASE_OPTIONS

# Let's start
run "$@"
