Note that there are some explanatory texts on larger screens.

plurals
  1. POFinding the right version of the right JAR in a maven repository
    primarykey
    data
    text
    <p>I'm converting a build that has 71 <code>.jar</code> files in its global <code>lib/</code> directory to use Maven. Of course, these have been pulled from the web by lots of developers over the past ten years of this project's history, and weren't always added to VCS with all the necessary version info, etc.</p> <p>Is there an easy, automated way to go from that set of <code>.jar</code> files to the corresponding <code>&lt;dependency/&gt;</code> elements for use in my <code>pom.xml</code> files? I'm hoping for a web page where I can submit the checksum of a jar file and get back an XML snippet. The google hits for 'maven repository search' are basically just finding name-based searches. And <a href="http://repo1.maven.org/" rel="noreferrer">http://repo1.maven.org/</a> has no search whatsoever, as far as I can see.</p> <p>Update: <a href="http://grepcode.com/" rel="noreferrer">GrepCode</a> looks like it can find projects given an MD5 checksum. But it doesn't provide the particular details (<code>groupId</code>, <code>artifactId</code>) that Maven needs.</p> <p>Here's the script I came up with based on the accepted answer:</p> <pre><code>#!/bin/bash for f in *.jar; do s=`md5sum $f | cut -d ' ' -f 1`; p=`wget -q -O - "http://www.jarvana.com/jarvana/search?search_type=content&amp;content=${s}&amp;filterContent=digest" | grep inspect-pom | cut -d \" -f 4`; pj="http://www.jarvana.com${p}"; rm -f tmp; wget -q -O tmp "$pj"; g=`grep groupId tmp | head -n 1 | cut -d \&gt; -f 3 | cut -d \&lt; -f 1`; a=`grep artifactId tmp | head -n 1 | cut -d \&gt; -f 3 | cut -d \&lt; -f 1`; v=`grep version tmp | head -n 1 | cut -d \&gt; -f 3 | cut -d \&lt; -f 1`; rm -f tmp; echo '&lt;dependency&gt; &lt;!--' $f $s $pj '--&gt;'; echo " &lt;groupId&gt;$g&lt;/groupId&gt;"; echo " &lt;artifactId&gt;$a&lt;/artifactId&gt;"; echo " &lt;version&gt;$v&lt;/version&gt;"; echo "&lt;/dependency&gt;"; echo; done </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload