0

Our webapp project has been around for a while (or actually I should say the programmers who started the project were too busy to look into newer things) and we rely heavily on ant for our builds. While Ant is cool, Maven is cooler. So we want to start using it.

The webapp has been around for a while and has at least 70-80 jars. Mapping the maven co-ordinates for each jar is painful. Is there a way to auto generate a maven pom (just the dependency section) by pointing a tool to the current classpath file? Is there such a tool

sumit
  • 436
  • 3
  • 15

2 Answers2

2

The older your project is the harder it can be to identify older versions of open source modules.

What I've done is use the jar file's checksum as a search key into the public Nexus repositories. For example try the following REST URL:

http://oss.sonatype.org/service/local/data_index?sha1=7999a63bfccbc7c247a9aea10d83d4272bd492c6

Returns the following response fragment, identifying version 1.2.16 of the log4j module:

<search-results>   
    <artifact>
      ..
      <groupId>log4j</groupId>
      <artifactId>log4j</artifactId>
      <version>1.2.16</version>
      ..
    </artifact> 
</search-results>

Of course this approach will open identify those jars held in Maven central, but it's a great time-saver.

Hope this helps, Good luck!

Mark O'Connor
  • 76,015
  • 10
  • 139
  • 185
  • Mark - thanks for the tip, I am going to try this and will update the thread on how it went. – sumit Jan 31 '11 at 14:41
  • 1
    @sumit I wrote a script that generates an ivy file for a new project. Although ivy is not the same as Maven, the two tools are functionally similiar. You might be able to re-use the logic: http://stackoverflow.com/questions/7363580/apache-ivy-dependency-ivy-files/7393826#7393826 – Mark O'Connor Sep 13 '11 at 18:16
1

Maven supports transitive depedencies. If you add all transitive depedencies as direct depedencies, you are not making full use of maven, and future maintainers will not thank you, because upgrading a depedency will be as difficult as it was in ant, i.e. the versions of transitive depedencies have to be updated manually.

Also, note that 70 jars might mean only a dozen or so depedencies, so finding the proper artifact coordinates need not be a big deal. (maven repositories can be searched, you know ...)

meriton
  • 68,356
  • 14
  • 108
  • 175
  • Thanks meriton. You are right about transitive dependency and that I should stop being lazy and get it done :). Just checking if something's out there. – sumit Jan 27 '11 at 15:56