From 528d57851f17583904935aeacaf4ffb2f32ea2b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=89ibhear=20=C3=93=20hAnluain?= Date: Sat, 12 Aug 2017 22:54:39 +0100 Subject: [PATCH] A working script --- source/scripts/allInOne.sh | 138 +++++++++++++++++++++++++++++++++++++ 1 file changed, 138 insertions(+) create mode 100755 source/scripts/allInOne.sh diff --git a/source/scripts/allInOne.sh b/source/scripts/allInOne.sh new file mode 100755 index 0000000..362d795 --- /dev/null +++ b/source/scripts/allInOne.sh @@ -0,0 +1,138 @@ +#!/bin/bash + +# This script (known as ${0} to itself) is in +# /source/scripts/, and we want to know where +# 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