Trap The Spark…

December 28, 2008

Apache Maven vs. Apache Ant (Part 2)

Earlier I blogged about my recent experiences with Apache Maven, i.e. Apache Maven vs. Apache Ant.  Several of the major issues were had were:

  • Performance – Maven’s performance (compared to Apache Ant) is horrible.  It repeats steps throughout the build (doesn’t skip anything and worse repeats some steps).  It’s constantly calling out to the Internet looking for  SNAPSHOT’s (per target/goal) as if somehow it magically changed mid-build.  A hack for repeated SNAPSHOT searches is to review all dependencies you have to remove as many SNAPSHOT’s on 3rd party components (wherever possible).  This isn’t foolproof as some of your dependencies might have dependencies on SNAPSHOT’s.  (For the ultimate hack you could tweak all of the POM’s in question but that’s painful and error prone and the next time you update something it could all get blown away.)  Another hack is to shut off your Internet connection.  The lack of a connection makes Maven stop looking (brilliant).
  • Scalability – Maven is a memory hog. The more complex (i.e. more nested components leveraging the reactor) your build process becomes the more memory consumed.  Here you need to tweak MAVEN_OPTS environment variable.

I was recently able to make some performance improvements to help Apache Maven, i.e.

  • Got a new laptop App MacBook Pro (2.6Ghz, 4 G RAM, HD w 7200 RPM)… not sure what exactly has sped things up but I suspect its the hard drive (as everything else is marginally better, i.e. 0.30 GHz faster CPU, 1G more RAM).
  • Tweaked the MAVEN_OPTS 

Originally I had the following MAVEN_OPTS settings: setenv MAVEN_OPTS “-Xmx640m” but I was getting errors for “out of perm space” so I used the following MAVEN_OPTS settings:

setenv MAVEN_OPTS “-Xms128m -Xmx640m -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -XX:+UseConcMarkSweepGC -XX:+CMSPermGenSweepingEnabled -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=640m -Xverify:none”

But as the number of components were built it locked the system.  I suspect the issue is the garbage collection settings.  So I reduced the MAVEN_OPTS settings to the following:

setenv MAVEN_OPTS “-Xms128m -Xmx640m -XX:MaxPermSize=640m”

This immediately helped get further in the build process.  Eventually it ran out of heap memory so now the MAVEN_OPTS settings are as follows:

setenv MAVEN_OPTS “-Xms128m -Xmx1280m -XX:MaxPermSize=640m” which seems to have done the trick.  I’m now able to do complete builds (mvn clean install) with these settings without doing hacks like shutting off my network connections, tweaking POM’s, etc.

But… need to get this working for creating sites, (i.e. mvn site) as well as getting this running with integration tests… (I have quite a few).

In the meantime I’ve been reading the Ant In Action book (which is quite good).  I’ve basically re-examined my entire Ant build process (and theory).  So I’ve started creating scripts from scratch trying to incorporate concepts from the book, i.e.

  • Declaring “beaucoup” ANT properties that can be overridden in a property file (or passed in properties from parent ANT scripts).
  • Importing ANT tasks (both life cycle tasks that can be overridden as needed as well as common functionality).
  • Potentially leveraging IVY for dependency management.
  • Potentially leveraging SmartFrog for deployment management (conceptually cool project).
  • Getting JBoss Seam’s testing to work with ANT (shouldn’t be an issue as JBoss Seam uses ANT primarily).

Fingers crossed but making progress…

December 14, 2008

Apache Maven vs. Apache Ant

For doing software builds in the Java world… most people use either Ant or Maven.  I’ve used both…

From a requirements perspective I need a continuous integration/build process that can do the following:

  • Dependency Management – In one place identify the components and their versions that are included in this project.  Ideally the same dependency management system can deal with child dependencies automatically.
  • Support some form of reuse across the components (in terms of the build scripts, ideally there’s no large scripts that have redundant text across the commands, difficult to maintain/keep consistent)
  • Support for hierarchical projects composed of numerous components (must scale and allow complexity).
  • Allow quick builds (most perform)
  • Ideally create a project Web site (documentation)
  • At least create project reports per component.

I started in the Ant world, i.e. oodles of ANT scripts on big projects.  My main issue was the complexity of the ANT scripts after awhile and the lack of reuse when you had a multi-component.  But it was fast and it could do anything, i.e. powerful.  I experimented on/off with Maven over the years.  Finally got it working this year.  Everything as advertised except really slow when there’s an Internet connection (and just slow in general).  And needed to break large projects up and build them separately (or them crash early, i.e. PermSpace errors).  With command lines like the following:

MAVEN_OPTS “-Xms128m -Xmx640m -Dsun.rmi.dgc.client.gcInterval=3600000 -Dsun.rmi.dgc.server.gcInterval=3600000 -XX:+UseConcMarkSweepGC -XX:+CMSPermGenSweepingEnabled -XX:+CMSClassUnloadingEnabled -XX:MaxPermSize=640m -Xverify:none”

It didn’t crash on the mini-builds… but when trying to build everything it would just slow down and ultimately lock the machine.  I was really attracted to the Development Web site that was created with mvn site but if the system can’t perform nor scale… it’s not worth it.  Looking at Seam and Hibernate.. they appear to get by just fine.  And then there’s trying to get the JBOSS Embedded Server running in Maven…  I’ve searched alot/experimented and just not sure what I’m missing there.  Time to thrown in the towel.  So now I’m going to move back to Ant.  In the past few years… it appears as though Ivy has caught on so perhaps Dependency Management.  Appears to be some templating/reuse concepts (although that may have been there awhile and I overlooked it).  Not sure how much can be templated so will be interested to investigate.

So in retrospect… Maven is nice for small projects.  Mine appears massive (i.e. many components, a lot of code generation, etc.).  So time to go back to Apache Ant.  Also need to get a wiki like http://www.SeamFramework.org and http://in.relation.to (i.e. the documentation posted to Al Gore’s Internet).

Theme: Silver is the New Black. Blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.