password
username
Sponsored by CakeMail, an email marketing software.
Newsletter preview

Tuesday, Feb 24, 2009

2009 JavaOne Conference – Register Now

Stay on top of everything new and different both inside and around Java™ technology – register by April 22, and save $200 on the JavaOne conference, June 2–5, 2009, in San Francisco. 300+ technical and hands-on sessions. Use priority code JJLPO1 when you register.

Register today at java.sun.com/javaone

Perspective

Seam UI: Free Refcard Download



Visit the DZone Tech Library


A Developer's Perspective
Next section
Adam Pohorecki is a founder of a small consulting firm named Draftsoft, where he develops custom software for middle and small-sized companies. He is a Computer Science student at the University of Science and Technology (AGH) in Kraków, Poland. You can contact Adam at: adam [at] pohorecki [dot] pl, or through his blog: http://adam.pohorecki.pl

The Future of Java Build Tools
By Adam Pohorecki

With a short post on dzone Adam Bien revived an old flame-war: should we use Ant or Maven as our build tool. The post itself seems a little biased on the maven side,  but not much. The only really questionable sentence is:

The real strength of Maven is its dependency management. (…) Ant doesn’t have such capabilities out-of-the-box (except via Ivy) and it will take a considerable amount of work to emulate Maven’s dependency management with Ant.

Although it’s certainly true that Ant does not have dependency management built in, it’s fairly easy to incorporate Ivy into your build.xml, so the "considerable amount of work" part is in my opinion rather misleading.

However, given a choice "Ant or Maven", I would most likely choose the former. I can see why so many people today use Maven as their primary build tool. It is pretty cool to have this drop-in build script, that with only a few lines of configuration will give you so many possibilities: dependency management, built in tasks for compiling and packaging applications, integration with Jetty, neat project web site, integration with cobertura, pmd or findbugs. In a situation, where one starts a new project, which is fairly typical (say a web application using Spring & Hibernate) this seems like a very good choice. I will say even more: for a project like that, this is probably a good choice.

No one really wants to write build scripts. This is the kind of code that does not have any real business value. Unfortunately that last statement holds only if the build script actually works, otherwise it has business value: a negative one. I feel that a build system like Maven is really great until you start encountering problems with it. Maybe your project just does not fit so very well in the convention. Maybe plugins you want to use conflict with each other. There’s lots of points of failure in a build system like Maven - and oftentimes it’s very hard to track the source of them and fix them.

The choice of Ant over Maven is not a very clear one. It truly is a chore to be forced to write all this build code by hand. But when the things go south, the build script is just another piece of code you’ve written. If you did it right, you should be able to find your way around that code, and fix it. No magic here.

OK, I’ve written enough to spill some oil to the flame-war fire. Now to the point of this article: are Maven and Ant our only choices? Is there really nothing better than that?

I claim there is. Over the last couple of years we’ve seen many such projects spring up to life. Those tools no longer use XML to define build logic, but real programming languages like Groovy, Ruby or Python(? - I thought I’ve seen an announcement somewhere for build tool in Python, but can’t find it now). They often allow dependency management (through Ivy or Maven) or Build By Convention. Some of those tools are:

My favorite build tool was Gant, up until the first release of Gradle was announced a couple of months ago. Gant is basically a Groovy way of invoking Ant tasks, which by itself gives you a lot compared to a good old build.xml. By using a real programming language instead of XML, some tasks which could become tedious in XML, are very easy: extracting common code into methods, loops, conditional logic (yes, I know about ant-contrib and use it whenever I have to use Ant, but trust me, it’s not the same). The fact is, that XML is not a programming language and it should not be used as one. Build scripts in languages like Groovy or Ruby are more concise and easier to read. There’s less clutter, boilerplate code, and your build script can be structured better.

In my opinion, the future of build automation in Java environments is Gradle, or at the very least some other tool, which will exhibit similar properties. Gradle is the kind of drop-in build script that I like: for simple, standard projects it allows you to use itself with just a few lines of configuration. It even allows transitive dependency management without using Maven or Ivy repositories. You know, how when you first learn about this "dependency management" thing, you wrote down your dependencies in ivy.xml or pom.xml and it took forever while "Maven downloaded the Internet"? How eventually you had to install a private repository just to store those dependencies which could not be found in the Maven repositories? How you had to fix pom.xml files, because some of the artifacts didn’t declare all their dependencies? Well, now you can have DM without all those problems. Just store the required libs in the SVN repository, and switch to "real" DM when needed.

On the other hand, for bigger projects, among many other features Gradle has first-class support for multi-project builds (for example, you can specify project dependencies, and when you build one of the sub-projects, all it’s dependencies will be built too). There’s plenty of other features and cool "magic tricks" you can do with Gradle. Check out the User’s Guide on the project web site. It’s about 100 pages long, and provides plenty of information. I mean it: you owe it to yourself to give up an hour of your time and read that manual to see how much better your life would be if you used Gradle :o)

That being said, I have to admit: Gradle might not be suitable for "production use" yet. The project is still fresh out of the oven - it’s less than a year old. It’s impressive how much Hans Dockter and other commiters managed to achieve in that time, though. The documentation is IMHO very good - short enough and informative. If you are looking for a replacement for Ant - Gradle is the thing for you. If you’re looking to replace Maven, you might want to wait a couple of months, since Gradle does not have support for many of the features Maven users rely on, like the project web site or generating project files for main IDEs. There’s also currently no IDE support for Gradle.

To sum up: while there might not be a "one size fits all" solution to build automation, new tools being developed seem to come close. By allowing both build by convention, and combining it with do-it-yourself-if-you-like approach Gradle has a shot at attracting both Ant and Maven fans. In the future I expect build scripts to be written in programming languages like Groovy or Ruby, and Gradle is likely to gain a significant market share.

Until next time,
Adam Pohorecki

To read more of Adam's work, visit adam.pohorecki.pl

 
DZ Top Links

DZone Top Links
Next section
Back to top
most clicked this week from dzone.com

dzone

Most-clicked links this week


 
Popular at JL

Popular at Javalobby
Next section
Back to top
A recap of some of the most popular and active Javalobby.org discussions this week.

Maven or Ant?

Maven vs. Ant is one of the semi-religious topics (like IntelliJ vs. Eclipse, SWT vs. Swing or Spring vs. EJB). Depending on your specific needs, both build...

29 replies - 4900 views - 02/17/09 by adam bien in News

A Reason to Hate Enterprise Java

Today, while going through my morning ritual of scanning my RSS feeds, I came across this little gem.These are the kinds of pictures that a software architect...

9 replies - 4033 views - 02/19/09 by Mike Desjardins in Articles

A Recap on OSGi - Why and How?

Over the past several months, I’ve written quite a few blog entries about OSGi. Here’s a recap of those entries. If you’re not familar with OSGi, the...

3 replies - 2688 views - 02/20/09 by Kirk Knoernschild in News

Growing Revenue for Desktop Java

I was reading Jonathan Schwartz’s latest blog entry about JavaFX reaching 100 000 000 downloads.

2 replies - 2648 views - 02/20/09 by eppleton in News

How to Choose From Multiple Java/JEE Job Offers?

In Java and J2EE career forums, interview candidates often ask how to choose from multiple job offers? This is not an easy decision to make and often this...

0 replies - 2468 views - 02/18/09 by Arul Kumaran in Articles

Constructor Injection vs. Setter Injection

There seems to be two camps in dependency-injection: (1) The constructor-injection camp and (2) the setter-injection camp. Historically the setter-injection...

5 replies - 2372 views - 02/20/09 by mhevery in Articles

Embedding OSGi in Tomcat

My last post embedded OSGi in an application server using Felix, Jetty, and PAX WEB. Here, I’m going to embed Equinox in Tomcat. I originally set out to...

0 replies - 2055 views - 02/17/09 by Kirk Knoernschild in Articles

White Papers & Announcements

Product Announcements
Next section
Back to top
Product and service announcements for Java developers.

VisualVM 1.1.1: Improved Memory Monitoring

The Java diagnostics & troubleshooting tool VisualVM has its 1.1.1 release today, out at https://visualvm.dev.java.net.  The 1.1.1 release delivers...

0 replies - 655 views - 02/17/09 by Jiri Sedlacek in Announcements

JFXtras 0.3: JavaFX 1.1 & MigLayout!

The 0.3 release of JFXtras adds support for JavaFX 1.1, plus includes a JavaFX version of MigLayout for doing layout of JavaFX Nodes.  Because JavaFX 1.1 is...

0 replies - 391 views - 02/17/09 by browsecode in Announcements

ICEfaces 1.8RC1, JSF 2.0, and Maven

ICEfaces 1.8 is nearly here: ICEfaces 1.8RC1 is now available, awaiting your feedback just prior to the final release. Some of the new features include: Excel...

0 replies - 385 views - 02/16/09 by Ted Goddard in Announcements

DesignGridLayout 1.1: Now With Multiple Row-Span Support

DesignGridLayout 1.1, the easy but powerful open source Swing LayoutManager, has just been released. You can try DesignGridLayout examples online...

0 replies - 305 views - 02/18/09 by Jean-*** P... in Announcements

ServiceMix, ActiveMQ, CXF and Camel Training Videos

The FUSE team has assembled a collection of recorded demos, webinars and videos to help you get started quickly building your infrastructure using open source....

0 replies - 204 views - 02/18/09 by Nitin Bharti in Announcements

YourKit Java Profiler 8.0 Released

YourKit team is glad to announce immediate availability of YourKit Java Profiler 8.0 released on February 13, 2009. It can be downloaded at...

0 replies - 185 views - 02/19/09 by Vladimir Kondratyev in Announcements

Jep 3.3 Released - Parse and Evaluate Mathematical Expressions

Jep is a Java library for parsing and evaluating mathematical expressions. With this package you can allow your users to ...

0 replies - 146 views - 02/17/09 by Nathan Funk in Announcements

Your Account

Your Account
Next section
Back to top
Manage your account info for this and other Javalobby publications.

Manage your Javalobby membership details

Click on the following links to:

Contact Info
Next section
Back to top
Here's how to reach us, we love to hear from you.

Email us
Send news items to editor@javalobby.org
Send questions, complaints, or suggestions to feedback@javalobby.org
Send advertising inquiries to advertise@javalobby.org
 
  Call us
  Our number is (919) 678-0300. We'd love to hear from you!
Legal
Back to top
The fine print we'd rather avoid completely.
  Feel free to redistribute this newsletter in part or in full to your friends.
 
Javalobby News is a service mark of DZone, Inc.
Copyright © 2001-2009 DZone, Inc.

Thank you for your continued support of Javalobby and DZone. Click here if you prefer not to receive the Javalobby weekly newsletters.
DZone, Inc. - 1251 NW Maynard Rd. - Ste. 300, Cary, NC 27513 - (919) 678-0300