Matt RaibleMatt Raible is a Web Architecture Consultant specializing in open source frameworks.


Over 10 years ago, I wrote my first blog post. Since then, I've authored books, had kids, traveled the world, found Trish and blogged about it all.

Maven 2's Transitive Dependencies

I spent a few hours this week integrating Maven 2's Ant tasks into Equinox. Here's a things I discovered in the process.

  • The JAR you need to include to use the Maven Tasks is quite large, weighing in at a hefty 833K. Regardless, it's easier to include a ~1MB JAR in CVS than it is 10MB of JARs. Equinox (w/o the extras directory) weighs in at 10.2MB before, 1.3MB after.
  • The transitive dependencies feature needs to be cleaned up a fair bit. There are a *lot* of unnecessary dependencies downloaded for many libraries. For example, Hibernate downloads a bunch of JBoss JARs and the Display Tag downloads all the various web framework JARs. I found myself excluding almost as many dependencies as I added.
  • Using in-line dependencies (where you specify each one in your build.xml) is cleaner and requires less XML (b/c of attributes vs. elements). I went this route at first and it worked well, but to allow greater flexibility (for those who might want to use Maven 2), I ended up creating a pom.xml. 48 lines in build.xml turned into 195 lines in pom.xml.
  • The Maven Developer team provides fantastic support - both on the mailing list and IRC. Thanks Brett!
  • Maven 2.0 RC was released today.
  • I need to figure out a way to "install" the persistence/web framework options in Equinox. The easiest way from a maintenance perspective is to parse pom.xml to add new dependencies. Entity includes might make the project more extensible though - and easier to upgrade.
  • Once you have pom.xml in place, it's pretty easy to make the build/test/package process M2 friendly.
  • Maven 2 is faster than Ant.

Overall, it was a pretty frustrating experience, with lots of trail-and-error. In the end, I got it all figured out and the only "hack" I had to do was delete servlet-api-2.4.jar after copying dependencies into my WAR. This is b/c Ant is not smart enough to know that dependencies with a "provided" scope shouldn't be copied. I could probably have a 4th dependencies path to solve this, but deleting sounded easier at the time.

I'm not going to check anything in yet b/c I still have to modify all the installers to specify their dependencies. The main advantage I can see in using a download-dependencies feature is easier upgrading of dependencies. It'll also make a lot more sense in AppFuse b/c certain parts of project (i.e. appfuse-dao.jar) can be published as re-usable modules.

In the meantime, if you'd like to try out Equinox with this feature (works with both Maven 2 or Ant), you can integrate it into a CVS version with the following steps:

That's it! I'm sure some things can be improved - please let me know if you find any issues.

Posted in Java at Oct 15 2005, 12:57:39 PM MDT 7 Comments

Thanks Matt - I guess the one encouraging thing about the exclusions was that it was limited to only 3 or 4 of your dependencies (though displaytag and hibernate had quite a lot to exclude). Once those get cleaned up it should become unnecessary. Good luck!

Posted by Brett Porter on October 15, 2005 at 01:42 PM MDT #

True. One other thing I thought was wierd is that Hibernate distributes jta.jar, but you can't get it from ibiblio - unless you use the Geronimo version.

Posted by Matt Raible on October 15, 2005 at 01:47 PM MDT #

jta can be bundled with your application but not redistributed alone (like making it available in ibiblio), you can put it in your local repo once and will be available for all your applications.

Posted by Carlos Sanchez on October 15, 2005 at 06:23 PM MDT #

You should try out Ivy instead. It's transitive dependency support is better and it sounds like it's much easier to setup. Plus, you can still use your Ant scripts that you (and everyone else) is familiar with.

Posted by Jason Carreira on October 16, 2005 at 07:49 PM MDT #

Jason - I do plan on trying out Ivy to see if it's easier to setup. The advantage to the setup I described here I have is 1) it works and works well (w/ the current Ant setup) and 2) you can use Maven 2 if you so desire. The biggest advantage of using Maven (IMO) is you can generate project files for Eclipse and IDEA.

Posted by Matt Raible on October 17, 2005 at 03:23 PM MDT #

Took me a few minutes to find the exclusion capability, so I'll post it here for future readers: Would also be great ato get a view of all the transitive dependencies so I know where to start excluding.

Posted by Geoffrey Wiseman on November 01, 2005 at 10:34 PM MST #

You can run maven with the -X option to get the tree of dependencies

Posted by Carlos Sanchez on November 01, 2005 at 10:41 PM MST #

Post a Comment:
  • HTML Syntax: Allowed