JavaTXCompilerInJavaTX/compile.sh

60 lines
1.8 KiB
Bash
Executable File

#!/bin/bash
SRCDIR="/home/julian/Dokumente/Programming/Java/Studienarbeit/JavaTXCompilerInJavaTX/javatx-src/main/java"
DESTDIR="/home/julian/Dokumente/Programming/Java/Studienarbeit/JavaTXCompilerInJavaTX/out"
JAVAC_FLAGS="-g:none -nowarn"
JAVATX_COMPILER_PATH="/home/julian/Dokumente/Programming/Java/Studienarbeit/JavaTXCompilerInJavaTX/JavaTXcompiler-1.1-jar-with-dependencies.jar"
#remove all files, if the script is called with parameter "clear"
if [ "$1" = "clear" ]; then
rm -r "$DESTDIR"
exit 0
fi
#find all .java/.jav files recursively and store them i an array
JAVA_FILES=($(find "$SRCDIR" -name "*.java"))
JAV_FILES=($(find "$SRCDIR" -name "*.jav"))
#create empty arrays for .class file paths
JAVA_CLASSES=()
JAV_CLASSES=()
JAVA_CHANGED=()
JAV_CHANGED=()
mkdir -p $DESTDIR
#fill class files arrays by subsituting .java/.jav -> .class for each file
for file in "${JAVA_FILES[@]}"; do
class_name="$DESTDIR${file#$SRCDIR}"
class_name="${class_name%.java}.class"
if [ ! -f "$class_name" ] || [ "$(stat -c "%Y" "$file")" -gt "$(stat -c "%Y" "$class_name")" ]; then
JAVA_CHANGED+=("$file")
JAVA_CLASSES+=("$class_name")
fi
done
for file in "${JAV_FILES[@]}"; do
class_name="$DESTDIR${file#$SRCDIR}"
class_name="${class_name%.jav}.class"
if [ ! -f "$class_name" ] || [ "$(stat -c "%Y" "$file")" -gt "$(stat -c "%Y" "$class_name")" ]; then
JAV_CHANGED+=("$file")
JAV_CLASSES+=("$class_name")
fi
done
if [ "${#JAV_CHANGED[@]}" -ne 0 ]; then
for ((i = 0; i < "${#JAV_CHANGED[@]}"; i++)); do
java -jar $JAVATX_COMPILER_PATH -d "${JAV_CLASSES[i]%/*}" -cp "$SRCDIR:$DESTDIR:target/dependencies/" ${JAV_CHANGED[i]}
done
fi
if [ "${#JAVA_CHANGED[@]}" -ne 0 ]; then
javac -d $DESTDIR -cp "$SRCDIR:$DESTDIR:target/dependencies/*" $JFLAGS ${JAVA_CHANGED[@]}
fi