This repository has been archived by the owner on Nov 29, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
operations.sh
executable file
·86 lines (68 loc) · 1.83 KB
/
operations.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
# A collection of operations to manipulate this repository.
# Part of Willow by Tiger Sachse.
BUILD="build"
BUILD_STYLES="Styles"
BUILD_SOURCE="Source"
BUILD_PACKAGE="Willow"
BUILD_DOCS="Documentation"
REPO_DOCS="docs"
REPO_SOURCE="source"
REPO_STYLES="styles"
REPO_PACKAGE="willow"
DIST="dist"
MANIFEST="manifest.txt"
ENTRY_CLASS="GraphicalInterface"
# Build and run this project.
function run_project {
build_project
cd $BUILD
java $BUILD_PACKAGE.$ENTRY_CLASS
cd - &> /dev/null
rm -rf $BUILD
}
# Build this project.
function build_project {
rm -rf $BUILD
mkdir -p $BUILD/$BUILD_PACKAGE
mkdir -p $BUILD/$BUILD_STYLES
cp $REPO_SOURCE/$REPO_STYLES/* $BUILD/$BUILD_STYLES/
javac -d $BUILD $REPO_SOURCE/$REPO_PACKAGE/*.java
}
# Build and package this project.
function package_project {
# If no name is provided, resort to a default.
if [ -z "$1" ]
then
JAR_NAME=$BUILD_PACKAGE
else
JAR_NAME=$1
fi
# Build the project and create some necessary directories.
build_project
mkdir -p $BUILD/$BUILD_DOCS
mkdir -p $BUILD/$BUILD_SOURCE
mkdir -p $DIST
cd $BUILD
# Copy the project source and documentation into the build directory.
cp -r ../$REPO_SOURCE/* $BUILD_SOURCE
cp -r ../$REPO_DOCS/* $BUILD_DOCS
# Create a manifest file and compress everything into a jar.
echo "Main-Class: Willow.GraphicalInterface" > $MANIFEST
jar cvfm ../$DIST/$JAR_NAME.jar $MANIFEST \
$BUILD_SOURCE/* $BUILD_PACKAGE/* $BUILD_STYLES/* $BUILD_DOCS/*
cd - &> /dev/null
# Clean up after yourself.
rm -r $BUILD
}
# Execute the appropriate function based on the first script argument.
case $1 in
--run)
run_project
;;
--build)
build_project
;;
--pack)
package_project $2
;;
esac