blue-sky
blue-sky

Reputation: 53816

Automate creation of pom file dependencies based on the jar file

I have hundreds of jar files scattered across different projects that I need to create pom file dependencies files for. I'd really like to avoid manually searching for every jar file and adding the dependency manually. Is there an API I can use to accomplish this task or some other way ?

Ive tried using a generic pom as described : http://maven.apache.org/plugins/maven-install-plugin/examples/generic-pom-generation.html

Using this command - mvn install:install-file -Dfile=spring-webmvc-portlet-3.0.6.RELEASE -DgroupId=test -DartifactId=test -Dversion=version -Dpackaging=jar-DgeneratePom=true

But should the generated pom not match the jar file ? Or do I need to add this myself

<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <modelVersion>4.0.0</modelVersion>
  <groupId>test</groupId>
  <artifactId>test</artifactId>
  <version>version</version>
  <packaging>jar-DgeneratePom=true</packaging>
  <description>POM was created from install:install-file</description>
</project>

Upvotes: 2

Views: 7661

Answers (2)

Mark O&#39;Connor
Mark O&#39;Connor

Reputation: 77961

I wrote a script that generates an ivy file. It uses the jar checksums to identify the matching modules in Maven central.

https://github.com/myspotontheweb/ant2ivy

This solution could be adapted to generate a Maven POM.

Upvotes: 3

ndeverge
ndeverge

Reputation: 21564

You may create a bash script which uses the Maven Install plugin to produce a generic POM.

See http://maven.apache.org/plugins/maven-install-plugin/examples/generic-pom-generation.html

Upvotes: 1

Related Questions