-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJavaProjectBootstrapper.sh
More file actions
45 lines (36 loc) · 1.43 KB
/
JavaProjectBootstrapper.sh
File metadata and controls
45 lines (36 loc) · 1.43 KB
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
#!/usr/bin/bash
# Author: jdjnovak
# This was written in order for me to not have to write more Java code than absolutely necessary.
# Bootstrap a new Java project
if [ $# -eq 0 ]
then
echo -e "USAGE:\n\tJavaProjectBootstrapper.sh <PROJECT NAME>"
echo -e "\tJavaProjectBootstrapper.sh <PROJECT NAME> <AUTHOR NAME>"
echo -e "EXAMPLES:\n\tJavaProjectBootstrapper.sh NewProject1 \"Tim Cook\""
echo -e "\tJavaProjectBootstrapper.sh NewProject2"
exit
fi
mkdir $1
cd $1
mkdir src
mkdir build
mkdir tests
# Create README file
if [ $# -gt 1 ]
then
echo -e "# $1\n## $2\nA new Java project generated by the best bootstrapper script." > README.md
else
echo -e "# $1\nA new Java project generated by the best bootstrapper script." > README.md
fi
# Create the build script and make it executable
echo -e "#!/usr/bin/bash\nif ! command -v javac &> /dev/null\nthen\n\techo \"ERROR: javac not installed or on PATH\"\n\texit\nfi\njavac -d build src/*.java" > compile.sh
chmod u+x compile.sh
# Create the run script and make it executable
echo -e "#!/usr/bin/bash\nif ! command -v java &> /dev/null\nthen\n\techo \"ERROR: java not installed or on PATH\"\n\texit\nfi\ncd build\njava Main\ncd .." > run.sh
chmod u+x run.sh
# Add main class to the src folder
cd src
echo -e "public class Main {\n\tpublic static void main(String[] args) {\n\t\tSystem.out.println(\"Can I use python instead?\");\n\t}\n}" > Main.java
cd ../../
# Exit message
echo "Bootstrap complete."