Last active
August 20, 2018 06:29
-
-
Save sachinsshetty/bab6ca24671cafe2cb63daaab47103f3 to your computer and use it in GitHub Desktop.
Solution for https://stackoverflow.com/questions/3063215/finding-the-right-version-of-the-right-jar-in-a-maven-repository
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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