Srikanth Balaji
Srikanth Balaji

Reputation: 2718

Generating maven dependencies using list of jar file names

I am on the process of converting java projects with many dependencies to maven projects.

These Java projects have dependencies, which are present in maven central. Now, I am trying to automate this conversion to the maven project to include all the libraries as dependencies and generate a maven pom.xml.

I thought of the below approach

Step 1 - Locate the version from the jar file name, if not found - search in the manifest file.

Step 2 - Locate the artifact id from the jar file name - though may not be valid for all jars.

Step 3 - For locating the group id - expand the jar file, and try to create group id using package name.

Step 4 - Verify the dependency formation using search api

Is there a better way to perform the above steps.

Upvotes: 0

Views: 492

Answers (1)

J Fabian Meier
J Fabian Meier

Reputation: 35795

An important additional option is to compute the SHA1 of your jar and search for it in MavenCentral.

Furthermore, you can look for a pom.properties file in the jar, which is present if the jar was originally built with Maven.

Upvotes: 1

Related Questions