Question

From my small amount of experience, I've only used Ant as a build tool. Are there any other projects which are better, and why?

Was it helpful?

Solution

Maven

It is much better than ant because for most common tasks you don't have to write a complicated build.xml, maven has very good defaults and it's all convention over configuration.

It has also a big central repository of libraries and it's very easy to configure it to, like, "use latest stable commons-whatever". Maven will then download the latest stable version for you (no more checking in jars into VCS) and if a new upstream stable version is released, it will download it as well. Of course, it's just as easy to lock it to some specific version should you need that.

It is also well integrated both with Netbeans and Eclipse (m2eclipse plugin) so the IDE honors whatever settings (including dependencies) you declare in the pom.xml file.

There are also some downsides to maven: some plugins are rather poorly documented, integration with both IDEs is not really perfect, and that in different ways, some error messages may be hard to understand.

OTHER TIPS

Ant is still a major player. In my experience, it is dominant. Plus, with Ivy, it handles some of Maven's strengths. IMO, Ant will become a framework for other tools: XML is too rigid (see link below).

Maven 2 is also a major player. I know people who quite like it and bristle at criticisms that were true for Maven 1 (it has come a long way).

Groovy is offering some cool stuff in the build space, because they build on Ant. Gant is used in Grails, but may be subsumed into Gradle. These can be used for Java as well.

At the risk of pimping my own blog, here is a post about Gant and Gradle. Here is a link to the very current debate about their future.

in the enterprise, ant is still the entrenches player. dependencies don't change fast. unlike open source projects that keep moving to fairly newest version of dependent jars, MOST enterprises try NOT to change their dependencies too fast. Given that, maven's advantages are NOT too much compared to ant.

Then again, if you want some of maven's features, ant folks have ivy (http://ant.apache.org/ivy/) for the dependencies feature.

IF you want to continue using ant, get hold of "ANT IN ACTION", 2nd edition so that you can use ant to the best productivity.

Good luck,

Some people like Ivy, which is a dependency managing thingy for Ant so I suppose that people coming from an Ant background will like it.

Others like Buildr. It's a JRuby thing, so if you can juggle Ruby and Java in the same projects, then I suppose it'll be interesting.

Personally, I just use Maven. It's easy to whip up a default pom.xml file and have all the build commands at your disposal. And when the project grows, you already have the infrastructure in place for running plugins and adding dependencies.

You also have Gant. Gant is Groovy + Ant, you can write your tasks in plain groovy and you can also call any ant task. If you are a Java shop and want to reuse the ant skills you have but dislike XML, I recommend Gant, it is ver easy to setup and you can embed it in ant (and also call gant from ant).

I really like SCons, which is a build tool whose configuration files are all just Python scripts. This will appeal to anyone who knows Python or similar scripting languages. SCons is designed to work well with Java as well as C/C++ and other languages, and I've been very satisfied with it in the past.

Because SCons files are written in Python, you can write arbitrary Python code if you find yourself needing to do anything special. However, if you're completely unfamiliar with Python, then there will possibly be a higher learning curve than trying to extend Ant or something similar to do what you want.

Maven2 seems to be the up and coming thing.

For our projects however we are migrating back to ant wherever feasible.

Maven2 requires quite a bit of knowledge to get it exactly the way you want, and Maven2 versions seem to handle classpaths differently.

And it is a pain to check all licenses included in the dependencies of the dependencies which may get drawn in.

And may have a slower start-up time, as you need to figure out the dependencies yourself, but at least it's easily readable. No magic going on here :)

If you do use maven, give a thought to an internal repository like Nexus. That way your software is not dead if some libraries decide to go away from the net*.

*We got burned with maven1; the ibiblio maven1 repository redirects and maven1 does not support redirects :(

I would urge you to start with your requirements when considering the right tool. Each project is different, the tool you use should reflect the problem space not the fashion.

That being said, I think for general use ant is still probably the best general tool for building java applications. It is often used effectively with other tools for dependency management but there we go again skirting off into a solution without a problem.

The very good news, is that if your process are good switching build tools is a fairly painless process - lesson - start with a good process scaled to the problem at hand.

You will find already some answers in What are some good java make utilities?.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top