Skip to content

Instantly share code, notes, and snippets.

@clathrop
Created July 31, 2015 20:41
Show Gist options
  • Save clathrop/28aeffd8f030e8169552 to your computer and use it in GitHub Desktop.
Save clathrop/28aeffd8f030e8169552 to your computer and use it in GitHub Desktop.
Build-deploy script which looks at the java version defined in a projects pom.xml and sets the environment java version accordingly then runs a maven build and deploy. Supports java 1.7 & 1.8 but can easily be extended to support previous and future java releases.
#!/bin/bash
# Build-deploy script which looks at the java version defined in a projects pom.xml
# and sets the environment java version accordingly then runs a maven build and deploy.
# Supports java 1.7 & 1.8 but can easily be extended to support previous and future java
# releases.
grep "<source>" pom.xml | grep "1.7" >/dev/null
if [ $(echo $?) -eq "0" ]
then
jv=1.7
fi
grep "<source>" pom.xml | grep "1.8" >/dev/null
if [ $(echo $?) -eq "0" ]
then
jv=1.8
fi
export JAVA_HOME=$(/usr/libexec/java_home -v $jv)
echo "java version is $jv"
echo "running: mvn clean install -P auto-deploy"
mvn clean install -P auto-deploy
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment