A working script

This commit is contained in:
Éibhear Ó hAnluain 2017-08-12 22:54:39 +01:00
parent 553c3f29cb
commit 528d57851f

138
source/scripts/allInOne.sh Executable file
View file

@ -0,0 +1,138 @@
#!/bin/bash
# This script (known as ${0} to itself) is in
# <somewhere>/source/scripts/, and we want to know where <somewhere>
# is without forcing a hard-coding on anyone. This is how we do that.
export DEV_HOME=$(cd $(dirname ${0})/../..; pwd)
# Go to our top-level development directory.
cd ${DEV_HOME}
# Checkout the lesson-4 tag (any of lesson-1, lesson-2, lesson-3 or
# lesson-4 would work just as well).
git checkout lesson-4
# Confirm we have a javac
javac -version
# If this doesn't work, we'll stop here.
if [ ${?} -ne 0 ]; then
exit 1
fi
# Set the CLASSPATH
export CLASSPATH=/usr/share/java/tomcat8-servlet-api.jar:${CLASSPATH}
# Go to where the java source is
cd ${DEV_HOME}/source/java
# Compile them
javac org/gibiris/javaBootcampNoEclipse/*.java
# If this doesn't work, we'll stop here.
if [ ${?} -ne 0 ]; then
exit 1
fi
# Confirm
ls -l org/gibiris/javaBootcampNoEclipse/*.class
# Prepare for the jar file
mkdir -pv ../lib
# We're going with including the source as well
jar cvf ../lib/javaBootcampNoEclipse.jar org
# If this doesn't work, we'll stop here.
if [ ${?} -ne 0 ]; then
exit 1
fi
# Confirm
ls -l ${DEV_HOME}/source/lib/javaBootcampNoEclipse.jar
# Prepare for the war file (this command creates all the dirs we need
# created)
mkdir -vp ${DEV_HOME}/webapp/WEB-INF/lib
cd ${DEV_HOME}/webapp
# Copy the candidate files into place.
cp -rv ${DEV_HOME}/source/jsps/* ${DEV_HOME}/webapp
cp -rv ${DEV_HOME}/source/lib/javaBootcampNoEclipse.jar ${DEV_HOME}/webapp/WEB-INF/lib
cp -rv ${DEV_HOME}/source/res/web.xml ${DEV_HOME}/webapp/WEB-INF
# Create the war file
jar cvf ${DEV_HOME}/source/lib/javaBootcampNoEclipse.war *
# If this doesn't work, we'll stop here.
if [ ${?} -ne 0 ]; then
exit 1
fi
mv -v ${DEV_HOME}/source/lib/javaBootcampNoEclipse{,-up-to-lesson-4}.war
# Clean up
cd ${DEV_HOME}
rm -vf ${DEV_HOME}/source/java/org/gibiris/javaBootcampNoEclipse/*.class
rm -vf ${DEV_HOME}/source/lib/javaBootcampNoEclipse.?ar
rm -vfr ${DEV_HOME}/webapp
# Update the repository to get the changes
git checkout lesson-5-working
# We add the necessaries to the CLASSPATH
export CLASSPATH=${DEV_HOME}/source/lib/AstroLib-1.1.5ws.jar:${DEV_HOME}/source/java:${CLASSPATH}
# Go to where the source is
cd ${DEV_HOME}/source/java
# Compile them
javac org/gibiris/javaBootcampNoEclipse/*.java
# If this doesn't work, we'll stop here.
if [ ${?} -ne 0 ]; then
exit 1
fi
# Confirm
ls -l org/gibiris/javaBootcampNoEclipse/*{,/*}.class
# Again, we're including the source as well
jar cvf ../lib/javaBootcampNoEclipse.jar org
# If this doesn't work, we'll stop here.
if [ ${?} -ne 0 ]; then
exit 1
fi
# Confirm
ls -l ${DEV_HOME}/source/lib/javaBootcampNoEclipse.jar
# Prepare for the war file (this command creates all the dirs we need
# created)
mkdir -vp ${DEV_HOME}/webapp/WEB-INF/lib
cd ${DEV_HOME}/webapp
# Copy the candidate files into place, including the additional one.
cp -rv ${DEV_HOME}/source/jsps/* ${DEV_HOME}/webapp
cp -rv ${DEV_HOME}/source/lib/javaBootcampNoEclipse.jar ${DEV_HOME}/webapp/WEB-INF/lib
cp -rv ${DEV_HOME}/source/lib/AstroLib-1.1.5ws.jar ${DEV_HOME}/webapp/WEB-INF/lib
cp -rv ${DEV_HOME}/source/res/web.xml ${DEV_HOME}/webapp/WEB-INF
# Create the war file
jar cvf ${DEV_HOME}/source/lib/javaBootcampNoEclipse.war *
# If this doesn't work, we'll stop here.
if [ ${?} -ne 0 ]; then
exit 1
fi
mv -v ${DEV_HOME}/source/lib/javaBootcampNoEclipse{,-lesson-5}.war
cd ${DEV_HOME}
rm -vf ${DEV_HOME}/source/java/org/gibiris/javaBootcampNoEclipse/*.class
rm -vf ${DEV_HOME}/source/java/org/gibiris/javaBootcampNoEclipse/Astro/*.class
rm -vf ${DEV_HOME}/source/lib/javaBootcampNoEclipse.?ar
rm -vfr ${DEV_HOME}/webapp