Skip to content

Instantly share code, notes, and snippets.

@ryantenney
Created June 9, 2014 23:32
Show Gist options
  • Save ryantenney/f522cfaf38fa300d5c3a to your computer and use it in GitHub Desktop.
Save ryantenney/f522cfaf38fa300d5c3a to your computer and use it in GitHub Desktop.
Download the latest version of a Jar from maven
jar=$1
propertiesFile=`tar -tvf $jar | grep pom.properties | awk ' { print $9 } '`
properties=`tar -xf $jar -O $propertiesFile`
groupId=`echo "$properties" | grep groupId | awk -F'=' ' { print $2 }'`
artifactId=`echo "$properties" | grep artifactId | awk -F'=' ' { print $2 }'`
jar=$artifactId.jar
mvn org.apache.maven.plugins:maven-dependency-plugin:2.8:get \
-Dartifact="$groupId:$artifactId:LATEST" \
-Dpackaging=jar \
-Ddest=$jar
propertiesFile=`tar -tvf $jar | grep pom.properties | awk ' { print $9 } '`
properties=`tar -xf $jar -O $propertiesFile`
version=`echo "$properties" | grep version | awk -F'=' ' { print $2 }'`
mv "$jar" "$artifactId-$version.jar"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment