Java Build Tools: Ant vs. Maven [closed]

2019-03-09 12:12发布

问题:

I was reading this blog by Kent R.Spillner regarding java build tools. Although I have lightly used Ant and Maven, I didn't have commited to either one seriously which I intend to do. Is the blog post I linked an exagerated one? Most importantly, should I use Maven or Ant for a medium sized project ( approximately 20K LOC).

回答1:

It really depends. Maven and Ant are just different approaches: imperative and declarative (see Imperative vs Declarative build systems)

Maven is better for managing dependencies (but Ant is ok with them too, if you use Ant+Ivy) and build artefacts. The main benefit from maven - its lifecycle. You can just add specific actions on correct phase, which seems pretty logical: just launch you integration tests on integration-test phase for example. Also, there are many existing plugins, which can could almost everything. Maven archetype is powerful feature, which allows you to quickly create project.

Ant is better for controlling of build process. Before your very first build you have to write you build.xml. If your build process is very specific, you have to create complicated scripts. For long-term projects support of ant-scripts could become really painful: scripts become too complicated, people, who's written them, could leave project, etc.

Both of them use xml, which could become too big in big long-term projects.

Anyway, you shoud read specific documentation on both. Also, there is ant-maven-plugin, which allow to launch ant-scripts with maven.

P.S. You can take a look on Gradle, which for me could provide more freedom than Maven, but is easier to use than Ant.



标签: maven ant build