Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven: how to identify jar files by SHA

Tags:

java

maven

jar

ant

I've inherited an Ant-based project that has over 80MB of jar files in a lib dir. I'd like to convert it to Maven. The jar files are named very simply, like quartz.jar. Since there is no indication of group id, much less version, converting this to pom.xml format is going to be very painful.

Is there a service or API that will return the Maven coordinates (group, artifact, version) for a jar file, given its SHA?

My fallback will be to examine the MANIFEST file from each jar, which will at least give me version info, if not specific Maven coordinates.

like image 782
George Armhold Avatar asked Sep 03 '11 00:09

George Armhold


People also ask

How can I tell what JAR file contains?

JAR files are packaged in the ZIP file format. The unzip command is a commonly used utility for working with ZIP files from the Linux command-line. Thanks to the unzip command, we can view the content of a JAR file without the JDK.

Is jar just a ZIP?

A JAR file is essentially a zip file that contains an optional META-INF directory. A JAR file can be created by the command-line jar tool, or by using the java. util. jar API in the Java platform.

Does maven include test classes in jar?

You can produce a jar which will include your test classes and resources. To reuse this artifact in an other project, you must declare this dependency with type test-jar : <project>


1 Answers

Ah, looks like I needed to Google on "checksum search", rather than "SHA". That turned up this page:

How to Convert from Ant to Maven in 5 Minutes

... which explains that you can use the checksum search on this page.

Based on this info, I just coded up a quick project on Github that will use this API and generate the XML dependencies stanza automatically. You can use it like:

$ java com.armhold.Provenance lib_dir

And it will print out the Maven coords for each jar file it finds.

like image 77
George Armhold Avatar answered Oct 05 '22 13:10

George Armhold