-
Notifications
You must be signed in to change notification settings - Fork 0
/
bluej.sh
executable file
·66 lines (56 loc) · 1.57 KB
/
bluej.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
#!/bin/bash
# Maven to BlueJ helper script
# Author: Pawel Makles <https://insrt.uk>
# Repository: https://github.com/KCLOSS/maven-bluej
# Version: 0.1
# Usage:
# ./bluej.sh <action> [...action]
#
# Actions:
# - build
# - run
#
# Example Usage:
# ./bluej.sh build run
BLUEJ="bluej"
TEST_DIRECTORY="test"
OUT="target/bluej_out.jar"
BUILD="mvn clean compile assembly:single"
for arg in "$@"
do
if [ "$arg" = "build" ]; then
# Build Maven project.
$BUILD;
# Copy the chad Maven build.
for file in target/*-jar-with-dependencies.jar;
do cp "$file" "$OUT";
done;
# BlueJ expects all package declarations to start from root. (lol)
# Inject source code into JAR file.
pushd src/main/java;
zip -ur "../../../$OUT" *;
popd;
# Mark this as a BlueJ project.
# Use resource loader to detect during runtime.
touch ThisIsABlueJProject;
zip -u $OUT ThisIsABlueJProject;
rm ThisIsABlueJProject;
elif [ "$arg" = "run" ]; then
# Ensure project has been built.
if ! test -f "target/bluej_out.jar"; then
echo "Must build project first!";
exit;
fi;
# Remove existing BlueJ project.
rm -rf $TEST_DIRECTORY;
# Copy exported jar
mkdir $TEST_DIRECTORY;
cp target/bluej_out.jar $TEST_DIRECTORY/out.jar;
# Open it with BlueJ.
bluej "$(realpath $TEST_DIRECTORY/out.jar)";
# Clean up.
rm -rf $TEST_DIRECTORY;
else
echo "Unknown action $arg!";
fi
done