Finding the right version of the right JAR in a maven repository

I was in the same situation as OP, but as mentioned in later answers Jarvana is no longer up.

I used the search by checksum functionality of Maven Central Search and their search api to achieve the same results.

First create a file with the sha1sums

sha1sum *.jar > jar-sha1sums.txt

then use the following python script to check if there is any information on the jars in question

import json
import urllib2

f = open('./jar-sha1sums.txt','r')
pom = open('./pom.xml','w')
for line in f.readlines():
    sha = line.split("  ")[0]
    jar = line.split("  ")[1]
    print("Looking up "+jar)
    searchurl = 'http://search.maven.org/solrsearch/select?q=1:%22'+sha+'%22&rows=20&wt=json'
    page = urllib2.urlopen(searchurl)
    data = json.loads("".join(page.readlines()))
    if data["response"] and data["response"]["numFound"] == 1:
        print("Found info for "+jar)
        jarinfo = data["response"]["docs"][0]
        pom.write('<dependency>\n')
        pom.write('\t<groupId>'+jarinfo["g"]+'</groupId>\n')
        pom.write('\t<artifactId>'+jarinfo["a"]+'</artifactId>\n')
        pom.write('\t<version>'+jarinfo["v"]+'</version>\n')
        pom.write('</dependency>\n')
    else:
        print "No info found for "+jar
        pom.write('<!-- TODO Find information on this jar file--->\n')
        pom.write('<dependency>\n')
        pom.write('\t<groupId></groupId>\n')
        pom.write('\t<artifactId>'+jar.replace(".jar\n","")+'</artifactId>\n')
        pom.write('\t<version></version>\n')
        pom.write('</dependency>\n')
pom.close()
f.close()

YMMV


Jarvana can search on a digest (select digest next to the Content input field).

For example, a search on d1dcb0fbee884bb855bb327b8190af36 will return commons-collections-3.1.jar.md5. Then just click on the alt text icon to get the details (including maven coordinates).

One can imagine automating this.

Tags:

Maven 2