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).
Maven archetype is powerful feature, which allows you to quickly create project. Ant is better for controlling of build process.
While Ant gives flexibility and requires everything to be written from scratch, Maven relies on conventions and provides predefined commands (goals). Simply put, Maven allows us to focus on what our build should do, and gives us the framework to do it.
According to the 2021 Java Developer Productivity Report, the majority of Java developers reported using Maven as their main build tool, at 67% of respondents. In a distant second and third place were Gradle at 20% of respondents and Ant at 11%.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With