-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmkjar
executable file
·65 lines (57 loc) · 1.85 KB
/
mkjar
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
#!/bin/bash
`which jar &> /dev/null`
jar_status=$?
if [ "$1" == "-h" ]; then
echo "Usage: mkjar [-i | -h | jar_name]"
echo ""
echo "By default, mkjar will attempt to build a jar file from the source, this"
echo "includes compilation and archiving. If a jar_name is specified, that name"
echo "will be used for the completed jar file, otherwise 'simulator.jar' is used."
echo ""
echo "Switches:"
echo " -h This message"
echo " -i Install - used when you are not set up as a developer, this will get"
echo " a pre-built jar file."
exit
fi
if [ "$1" == "-i" ]; then
echo "Retrieving jar file from release area."
curl -O https://raw.githubusercontent.com/DaveChamberlain/casim/master/simulator.jar
exit
fi
if [ "$jar_status" == "1" ]; then
echo "The 'jar' command could not be found. Make sure it is installed and in your path."
echo "Likely that you may have installed the JRE but not the JDK, make sure you have"
echo "installed the JDK."
echo ""
echo "On Ubuntu 16.04, try installing with: "
echo " sudo add-apt-repository ppa:webupd8team/java"
echo " sudo apt-get update"
echo " sudo apt-get install oracle-java8-installer"
echo ""
echo "Otherwise, you will need to open your IDE and load the project and build."
echo ""
echo "NOTE: You may also retrieve one using the -i switch:"
echo " mkjar -i"
exit
fi
filename="simulator.jar"
if [ "$1" != "" ]; then
filename=$1
fi
echo "Creating jar file: ${filename}"
src=src/simulator
resource=resource
bin=${src}
here=`pwd`
filename=${here}/${filename}
javac ${src}/*.java 2>&1 | grep -v Note
cd ${bin}/..
echo "Class-Path: ." > .manifest
echo "Main-Class: simulator.Computer" >> .manifest
echo "" >> .manifest
jar cfm ${filename} .manifest simulator/*.class ${resource}/*
rm .manifest
cd ${here}
rm ${src}/*.class
echo "Done."