Skip to content

ldez/jar2pom

Repository files navigation

JAR2POM Logo

JAR2POM

Build Status Coverity Scan Build Status Coverage Status

Summary

Command line tools for producing a POM from one or more JAR.

jar → maven search → pom

Based on the idea of Provenance by George Armhold.

Download

Download version 2.0.0 here

Build

In the directory where the pom.xml is, run:

mvn clean package

Run

java -jar jar2pom.jar

or

java -jar jar2pom.jar -host 192.168.0.1 -i "c:\myProjet\source" -o "c:\output" -p -r

Show all options:

java -jar jar2pom.jar -h

Options (no options are mandatory):

 -h (--help)  : display help.
 -host HOST   : defined custom Nexus host.
                (ex: oss.sonatype.org)
 -i INPUT     : input path (file or directory).
 -o OUTPUT    : directory output path.
                (default output is console)
 -p (--proxy) : Use system proxies.
 -r           : inspect input path recursively.

Technologies

  • Java 8
  • args4j : interface and options for the command line
  • NIO.2 : browse JAR files.
  • Guava : calculating SHA1 from the contents of the JAR files.
  • Jersey : Rest client
  • mustache.java : generation of the output file

Explanation

  • Browse and detect all jars.
  • For each JAR file, calculates the SHA1.
  • Querying REST Services Maven repositories.
  • Creating a POM file.

Browse Jar

  • a single jar.
  • a folder containing jars (recursive or not).

Maven Search

April 22, 2015

Nexus:

URL version
oss.sonatype.org 2.11.2-06
repository.sonatype.org 2.11.2-06
maven.java.net 2.11.2-06
maven.atlassian.com 2.11.2-06
repository.apache.org 2.11.1-01

Search type:

  • Checksum (SHA1).
  • Artifact id
  • Class name

POM build

Output as an XML file [Partial POM].

REST API

Nexus

Nexus Indexer Lucene Plugin REST API

Le service supporte des réponses en XML ou JSON uniquement pour certaines ressources. La définition XSD est disponible pour le XML uniquement pour une partie des ressources.

Warning
  • Bug with Nexus Indexer Lucene Plugin REST API XSD : NEXUS-6755
  • da39a3ee5e6b4b0d3255bfef95601890afd80709 qui est le sha1 d'un fichier vide correspond à plus de 100 jars mais identify ne retourne qu'une seule valeur sans cohérence.

Example :

Nexus Core API (Restlet 1.x Plugin) REST API

Maven Central

Le service supporte des réponses en XML ou JSON. Aucune définition XSD n'est disponible pour le XML.

Warning : la response ne correspond pas à l'artifact mais au "bundle", ie toutes les checksum d'un ensemble retourne toujours la même réponse.

ex : search

XML file

<!-- source url / file path -->
<dependency>
    <groupId>groupId</groupId>
    <artifactId>artifactId</artifactId>
    <version>version</version>
</dependency>
  • source url
  • absolute input file path
  • artifact :
  • groupId (groupId by default: unknownGroupId)
  • artifactId (jar name by default)
  • version (version by default: 0.0.0)
  • classifier