Skip to content

Instantly share code, notes, and snippets.

@megalucio
Created December 23, 2020 22:00
Show Gist options
  • Save megalucio/6ff7813e9b8fcb02fa514c71eda94b1a to your computer and use it in GitHub Desktop.
Save megalucio/6ff7813e9b8fcb02fa514c71eda94b1a to your computer and use it in GitHub Desktop.
Script to compile and deploy maven generated war file into servlets container.
#!/bin/sh
[ "$UID" -eq 0 ] || exec sudo "$0" "$@"
export DESTINATION=/usr/share/tomcat/webapps
export WAR_NAME=mywebapp
export WAR_EXTENSION=war.original
export MAVEN_HOME=~/apache-maven-3.5.4
export SERVICE_NAME=tomcat
set -x #echo on
set -e #exit on error
service $SERVICE_NAME stop
$MAVEN_HOME/bin/mvn clean package -DskipTests=true
rm -rf $DESTINATION/$WAR_NAME
cp target/$WAR_NAME.$WAR_EXTENSION $DESTINATION/$WAR_NAME.war
service $SERVICE_NAME start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment