Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Maven vs Ant for automatic builds in Android applications

I'm evaluating whether to use Ant or Maven to automate my build process for Android development. I've been trying to read online to make an informed decision, but haven't found many specifics that relate to Android development. Based on your experience:

  • What are the main differences ?
  • I've read some people saying they have different purposes ? What would those be ?
  • What would make you pick one over the other ?
  • What are the strong points and weaknesses of each ?
  • Which is easier to setup and maintain ?
  • Is there one that is proffered/most used in the community ?

I found a similar question What benefits does Maven give (over ant) for building android projects?, but he was asking about the benefits of Maven over Ant and, first, I don't even know the Ant benefits and, second, he just got one answer that didn't make things clear for me.

I use Intellij, just in case it makes any difference though I hope it doesn't.

like image 405
bluediapente Avatar asked Jun 05 '11 15:06

bluediapente


People also ask

Does Maven replace Ant?

There are basically three build tools that can replace Ant: Maven, gradle and Buildr. It is important to be able to continue using existing Ant scripts and custom tasks alongside the new tool.

What is the difference between Maven Gradle and Ant?

Maven continues to use XML files just like Ant but in a much more manageable way. The name of the game here is convention over configuration. While Ant gives flexibility and requires everything to be written from scratch, Maven relies on conventions and provides predefined commands (goals).


3 Answers

If you can use Maven, go with Maven. And, don't you dare try to change the standard directories! Heck, even when we use Ant, I insist we setup the directories like Maven. That way, new developers know where things are, or have to trace through the build.xml to find where things are located. The other things is that if you do use Ant, you should also use Ivy. That way, you get the Maven dependency handling within Ant.

The big irony is that once we use Ant and Ivy, and stick to the standard Maven directory structure, moving from Ant to Maven is a cinch. But, the need to move to Maven is lessened too. Our build.xml is clean and simple to understand. All the files are in the right place. Builds are quick, simple, and easy to maintain. Who needs Maven?

The problem is once we've reach this state of Nirvana, is to keep the project from heading back to the State of New Jersey. Developers start carving out exceptions in our build.xml. Don't compile this *.java file. Move this *.xml into our java directory, put test code under the main directory, but we'll put the name test in the file, so we know it's test code... New and complex things are done. And, somehow, we're back in Secaucus.

So, once I've got my Ant project clean and neat enough to move to Maven, I make the leap.

One more thing: Maven makes it very, very simple to copy a project from one computer to another. Maven handles all the dependencies stuff -- even the build stuff. No more, you need AntContrib, or you need to download the hibernate Ant tasks. If you need something, it'll download itself. It's one of the big reasons Maven is so popular with many open source sites.

My big complaint about Maven is that it's so poorly documented. There's a Wiki, but almost no content, and very few manuals.

like image 127
David W. Avatar answered Sep 20 '22 14:09

David W.


I've not used Ant or Maven much for Java recently, but I can tell you the main differences between them -- it basically boils down to automated conventions (Maven) vs. absolute flexibility (Ant).

Maven will do almost everything for you, but it's much easier to use if you arrange your projects to suit it. It'll handle dependency tracking and resolution, building, packaging and storing the built packages, while also helping with branch maintenance and release engineering. I find it an awful lot easier to release my (flex) projects that are built with Maven.

Ant is much more flexible. You can do whatever you want, build in whichever way you want. If you have pre-existing projects, you can automate much of what your IDE is doing without changing anything else. It doesn't hand-hold as much as Maven, which also makes it easier to diagnose when things go wrong... You're on your own for dependencies, branches and releases, though. Where we use ant, we use it because we had a project set up which we wanted to automate, and Maven wouldn't adapt to fit it. If you need to do something not supported by Maven, Ant may be your only hope.

Personally, I'd use Maven over Ant if possible, but I'd admit that it's not always possible.

like image 32
Andrew Aylett Avatar answered Sep 24 '22 14:09

Andrew Aylett


Consider using Gradle!

It combines the best from Maven (convention over configuration) with the best from Ant (the flexibility and the huge library of pre-made tasks).

A Gradle build is written in Groovy, so you have the full power of a scripting language at your fingertips!

There is an Android plugin for Gradle. I haven't used it though, so I cannot tell if it's good or not.

See http://www.gradle.org

like image 45
Olle Hallin Avatar answered Sep 20 '22 14:09

Olle Hallin