Skip to content

Instantly share code, notes, and snippets.

@sachinsshetty
Last active August 20, 2018 06:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sachinsshetty/bab6ca24671cafe2cb63daaab47103f3 to your computer and use it in GitHub Desktop.
Save sachinsshetty/bab6ca24671cafe2cb63daaab47103f3 to your computer and use it in GitHub Desktop.
jar_name=junit-4.12.jar
sha1sum $jar_name > jar-sha1sums.txt
shaVal=`cat jar-sha1sums.txt | cut -d " " -f1`
response=$(curl -s 'http://search.maven.org/solrsearch/select?q=1:%22'$shaVal'%22&rows=20&wt=json')
formatted_response=`echo $response | grep -Po '"response":*.*'`
versionId=`echo $formatted_response | grep -Po '"v":"[0-9]*.[0-9]*"' | cut -d ":" -f2| xargs`
artifactId=`echo $formatted_response | grep -Po '"a":"[a-z]*"' | cut -d ":" -f2 | xargs`
groupId=`echo $formatted_response | grep -Po '"g":"[a-z]*"' | cut -d ":" -f2 | xargs`
## gist created from ant2maven script @ https://github.com/sachinsshetty/ant2Maven.git
## To find latest availabe version
lat_ver_response=$(curl -s https://search.maven.org/solrsearch/select?q=g:"$groupId"+AND+a:"$artifactId"&core=gav&rows=20&wt=json)
format_lat_ver_response=`echo $lat_ver_response | grep -Po '"response":*.*'`
latestVersionId=`echo $format_lat_ver_response | grep -Po '"latestVersion":"[0-9]*.[0-9]*"' | cut -d ":" -f2| xargs`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment