Why do we need Maven or Ant, if we already have Eclipse?

Jackson Tale picture Jackson Tale · May 26, 2012 · Viewed 33.1k times · Source

I think this question is an extension of Compare to the IDE for Java,do we still need Ant?

There are answers for the question above, but I wish to know a concrete example of using Maven or Ant over just Eclipse.

When I develop in Eclipse, Eclipse does everything for me and I just need to click the run button. And also, Eclipse can let you export your code to a runnable jar or even .exe for windows.

So I really don't know why I need Maven or Ant.

And also if I do need, which one should I choose, Maven or Ant?

Answer

JB Nizet picture JB Nizet · May 26, 2012
  1. Because your collegue might prefer NetBeans or IDEA
  2. Because the settings might vary from one eclipse install to another
  3. Because you might want to get your dependencies automatically
  4. Because you want to automate the complete build: build, jar, apply static code analysis, run the unit tests, generate the documentation, copy to some directory, tune some properties depending on the environment, etc.
  5. Because once it's automated, you can use a continuous integration system which builds the application at each change or every hour to make sure everything still builds and the tests still pass...
  6. Because Maven uses convention over configuration.
  7. Because your IDE may not support some fancy code generation/transformation you need.
  8. Because a build script documents the build process.

Eclipse is a development environment. But it's not a build tool.

I personally hate Maven, but YMMV. There are many alternatives: gradle, buildr, etc.