1

Using Maven Ant Tasks, I see lots of examples that build Ant classpath from Maven dependencies, but what about the other way round?

I have a carefully tuned Ant project that builds the Java task classpath from all the jars in my lib directory. How can I use Maven-Ant-tasks to use my classpath to build Maven dependencies?

I would rather not do each jar file individually (my last resort). Is there a better way?

lyates
  • 167
  • 1
  • 3
  • 9

1 Answers1

3

If you're working on converting from Ant to Maven, just bite the bullet and write out your <dependencies> section to match your ant classpath. You only have to do it once, and you'll thank yourself many times over.

Ryan Stewart
  • 126,015
  • 21
  • 180
  • 199
  • I'm also upgrading packages from JDK 1.4 to JDK 6 and hoped that Maven would magically handle my version numbers. May be that you're right, @Ryan. ...but, wouldn't it be cool if this chore could be automated? – lyates Aug 18 '11 at 02:51
  • By "chore", do you mean generating the dependency XML from existing ant jars? It can be automated somewhat. I did it once. [Sonatype Nexus](http://nexus.sonatype.org/) has a feature that lets you search for jars by the SHA-1 checksum of the file. I happened to have set up my own Nexus server, but http://search.maven.org is one now, too. It's a relatively trivial groovy script to read in all the jars from some directory, SHA-1 them, make a request to nexus, parse out the dependency info, and stick it into XML. After that, it's just a question of excluding unneeded transitive dependencies. – Ryan Stewart Aug 18 '11 at 03:01
  • Yes agreed. Using files in a lib directory means you are missing the "groupId" part of the dependency and frequently the file naming convention might be missing the "version" number..... – Mark O'Connor Aug 18 '11 at 05:28