Create and move over templates
This commit is contained in:
commit
4d6310600b
9
Java/scripts/build.sh
Executable file
9
Java/scripts/build.sh
Executable file
@ -0,0 +1,9 @@
|
|||||||
|
#Builds and runs the project.
|
||||||
|
#Java
|
||||||
|
rm -Rf out/*
|
||||||
|
javac -Xlint:unchecked -cp ${PROJECT_DIR}/.. -d ${OUT_DIR} ${PROJECT_DIR}/*.java
|
||||||
|
printf "\n\n\nRunning Program...\n\n"
|
||||||
|
ORIGINAL_LOC=$(pwd)
|
||||||
|
cd $OUT_DIR
|
||||||
|
java ${MAIN_CLASS} "$@"
|
||||||
|
${ORIGINAL_LOC}/scripts/clean.sh
|
4
Java/scripts/clean.sh
Executable file
4
Java/scripts/clean.sh
Executable file
@ -0,0 +1,4 @@
|
|||||||
|
#Cleans up and removes unused files.
|
||||||
|
#Java
|
||||||
|
find . -type f -name *.class -delete
|
||||||
|
find . -type f -name manifest -delete
|
6
Java/scripts/commit.sh
Executable file
6
Java/scripts/commit.sh
Executable file
@ -0,0 +1,6 @@
|
|||||||
|
#Adds a commit message and pushes project to github repository.
|
||||||
|
#Java
|
||||||
|
git add -u
|
||||||
|
git add *
|
||||||
|
git commit -m "$*"
|
||||||
|
git push
|
16
Java/scripts/jar.sh
Executable file
16
Java/scripts/jar.sh
Executable file
@ -0,0 +1,16 @@
|
|||||||
|
#Builds a runnable jar file using ${MAIN_CLASS} as an entry point and then runs the newly generated jar.
|
||||||
|
#Java
|
||||||
|
rm -Rf bin/*
|
||||||
|
javac -Xlint:unchecked -cp src -d bin ${PROJECT_DIR}/${PROJECT_NAME}.java
|
||||||
|
printf "\n\n\nGenerating Manifest...\n\n"
|
||||||
|
touch manifest
|
||||||
|
echo "Main-Class: ${MAIN_CLASS}" >> manifest
|
||||||
|
printf "\n\n\nCreating Jar...\n\n"
|
||||||
|
ORIGINAL_LOC=$(pwd)
|
||||||
|
cd ${OUT_DIR}
|
||||||
|
jar cfm ${PROJECT_NAME}.jar ${ORIGINAL_LOC}/manifest sig
|
||||||
|
printf "\n\n\nRunning Program...\n\n"
|
||||||
|
java -jar ${PROJECT_NAME}.jar
|
||||||
|
mv ${PROJECT_NAME}.jar ${ORIGINAL_LOC}
|
||||||
|
cd ..
|
||||||
|
./scripts/clean.sh
|
33
README.md
Normal file
33
README.md
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
This repository contains general build scripts and pipelines for all languages that I incorporate in my projects. The goal is to provide an easy retrieval and update system for the project. Each script will be a shell script containing the following template:
|
||||||
|
```bash
|
||||||
|
#Short description about what I do
|
||||||
|
#Language[Folder]
|
||||||
|
/* The script's code goes in here.
|
||||||
|
rm -Rf out/*
|
||||||
|
javac -Xlint:unchecked -cp ${PROJECT_DIR}/.. -d ${OUT_DIR} ${PROJECT_DIR}/*.java
|
||||||
|
printf "\n\n\nRunning Program...\n\n"
|
||||||
|
cd $OUT_DIR
|
||||||
|
java ${MAIN_CLASS} "$@"
|
||||||
|
../scripts/clean.sh
|
||||||
|
*/
|
||||||
|
```
|
||||||
|
Each language will be in the following structure:
|
||||||
|
```
|
||||||
|
-<Language>
|
||||||
|
--<scripts>
|
||||||
|
---[script files.sh]
|
||||||
|
```
|
||||||
|
|
||||||
|
The `sig` script will display by default any scripts in the `scripts` folder, therefore when creating a project, copy over the scripts folder of the desired language into your project then the `sig` script handles the rest appropriately. If your project requires multiple languages and build setups, then you can use the `sig2` command, which has an additional parameter to specify the language when running it. When setting up a multi-language setup, you'll just copy the entire folder to include the programming language itself. So a multi-language project structure may look something like this:
|
||||||
|
```
|
||||||
|
-C
|
||||||
|
--scripts
|
||||||
|
---build.sh
|
||||||
|
---clean.sh
|
||||||
|
---make.sh
|
||||||
|
-Java
|
||||||
|
--scripts
|
||||||
|
---build.sh
|
||||||
|
---clean.sh
|
||||||
|
---jar.sh
|
||||||
|
```
|
32
sig
Executable file
32
sig
Executable file
@ -0,0 +1,32 @@
|
|||||||
|
export PROJECT_NAME="JavaProjectTemplate"
|
||||||
|
export PROJECT_DIR="src/sig"
|
||||||
|
export MAIN_CLASS="sig.${PROJECT_NAME}"
|
||||||
|
export OUT_DIR="bin"
|
||||||
|
|
||||||
|
|
||||||
|
if [ -z "$1" ]
|
||||||
|
then
|
||||||
|
echo ""
|
||||||
|
echo " Usage: ./sig <command> {args}"
|
||||||
|
echo ""
|
||||||
|
printf "====\tCurrent Configuration"
|
||||||
|
printf "\t====================="
|
||||||
|
printf "\n\t%-15s%20s" PROJECT_NAME ${PROJECT_NAME}
|
||||||
|
printf "\n\t%-15s%20s" PROJECT_DIR ${PROJECT_DIR}
|
||||||
|
printf "\n\t%-15s%20s" MAIN_CLASS ${MAIN_CLASS}
|
||||||
|
printf "\n\t%-15s%20s" OUT_DIR ${OUT_DIR}
|
||||||
|
printf "\n====================================================="
|
||||||
|
echo ""
|
||||||
|
echo ""
|
||||||
|
echo " Command List:"
|
||||||
|
FILES=$(ls -1 ./scripts | sed -e 's/\.sh$//' | sed -e 's/^/ /')
|
||||||
|
for f in $FILES
|
||||||
|
do
|
||||||
|
DESC="$(head -n1 ./scripts/$f.sh)"
|
||||||
|
printf "\n\t%-15s%-65s" $f "${DESC:1}"
|
||||||
|
done
|
||||||
|
echo ""
|
||||||
|
exit
|
||||||
|
fi
|
||||||
|
|
||||||
|
./scripts/$1.sh "${*:2}"
|
Loading…
x
Reference in New Issue
Block a user