43 lines
2.5 KiB
Bash
Executable File
43 lines
2.5 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
# Set the project root directory
|
|
PROJECT_ROOT=$(dirname "$0")/..
|
|
|
|
# Function to exit script
|
|
_exitScriptIfError() {
|
|
if [ $1 -ne 0 ]; then
|
|
echo $2
|
|
# Handle the error here, e.g., exit the script or perform some recovery actions
|
|
exit 1
|
|
fi
|
|
}
|
|
|
|
# Clean all bin folders
|
|
rm -rf "$PROJECT_ROOT/Sample Code/bin/Protect With Hot Folder and Wrap Sample App/config"/*
|
|
rm -rf "$PROJECT_ROOT/Sample Code/bin/Protect With Hot Folder and Wrap Sample App/lib"/*
|
|
|
|
# Clear the src/bin dir containing compiled class files
|
|
rm -rf "$PROJECT_ROOT/Sample Code/src/Protect With Hot Folder and Wrap Sample App Code/bin"/*
|
|
|
|
echo "Successfully cleared the existing bin dir."
|
|
|
|
#find and compile all java files
|
|
find "$PROJECT_ROOT/Sample Code/src/Protect With Hot Folder and Wrap Sample App Code/src" -name "*.java" -exec javac -d "$PROJECT_ROOT/Sample Code/src/Protect With Hot Folder and Wrap Sample App Code/bin" -cp "$PROJECT_ROOT/Sample Code/src/Protect With Hot Folder and Wrap Sample App Code/lib/*" {} +
|
|
_exitScriptIfError $? "ERROR: Java files compilation failed."
|
|
echo "Successfully compiled the java files."
|
|
|
|
# Package the compiled classes into a JAR file
|
|
jar cvf "$PROJECT_ROOT/Sample Code/bin/Protect With Hot Folder and Wrap Sample App/lib/sample-app.jar" -C "$PROJECT_ROOT/Sample Code/src/Protect With Hot Folder and Wrap Sample App Code/bin" .
|
|
_exitScriptIfError $? "ERROR: error making jar file."
|
|
echo "Successfully built the jar file ."
|
|
|
|
# Copy all libs and config files to bin
|
|
cp -rf "$PROJECT_ROOT/Sample Code/src/Protect With Hot Folder and Wrap Sample App Code/lib"/* "$PROJECT_ROOT/Sample Code/bin/Protect With Hot Folder and Wrap Sample App/lib"
|
|
_exitScriptIfError $? "Error while copying libs from '$PROJECT_ROOT/Sample Code/src/Protect With Hot Folder and Wrap Sample App Code/lib' to '$PROJECT_ROOT/Sample Code/bin/Protect With Hot Folder and Wrap Sample App/lib'"
|
|
echo "Successfully copied libs from '$PROJECT_ROOT/Sample Code/src/Protect With Hot Folder and Wrap Sample App Code/lib' to '$PROJECT_ROOT/Sample Code/bin/Protect With Hot Folder and Wrap Sample App/lib'."
|
|
|
|
cp -rf "$PROJECT_ROOT/Sample Code/src/Protect With Hot Folder and Wrap Sample App Code/config"/* "$PROJECT_ROOT/Sample Code/bin/Protect With Hot Folder and Wrap Sample App/config"
|
|
_exitScriptIfError $? "Error while copying config from '$PROJECT_ROOT/Sample Code/src/Protect With Hot Folder and Wrap Sample App Code/config' to '$PROJECT_ROOT/Sample Code/bin/Protect With Hot Folder and Wrap Sample App/config'."
|
|
echo "Successfully compiled the java files." |