A report on comparing three Java build tools

A report on comparing three Java build tools

这是学校CS306 软件工程 的一个作业。
This is an assignment of CS306 Software Engineering in Sustech.

Write a report on comparing build management tools for Java, including Gradle, Maven and Ant.
At least 800 words (exclude punctuations).

1. History of the build tools

1.1 Why build tools?

Before we start the topic, the first thing should do is thinking about this question: why we need build tools?
The development history of things is always the same. At first, we only have a project, all the dependent jar packages we used just put to a directory.
Also, we need to compile, test and packaged the project. We can simply use java javac jar to finish the procedures.
However, if the project grows bigger and bigger, it may be a waste of time and even nightmare to compile thousands of .java files with hundreds of dependencies.
Then some clever people have developed some useful shells to simplify the process, which we also call them build tools.

1.1 Ant

The overall thought of Ant is simple. It just defines a task and set its dependencies. That’s all. In detail, we have five default tasks: init, compile, build, test, clean, which cover most of the usages.
However, the management of dependencies is missing in Ant. That means, we still need to control the dependencies manually, just like a nightmare :(

1.2 Maven

There are two changes between Ant and Maven.

  1. The key component: dependency management
    Maven builds a system based on this main factor. It can quickly locate to a specified dependent package with three elements. Once given the groupId, artifactId, version, it can find the jar file and run automatically.
    It also introduces a new concept: a repository to store the dependencies and components. That can help reduce the duplicate copies and make the management more flexible. Also, thanks to the remote repository, it can directly download the files we need.

  2. An agreement: convention over configuration
    It also learns from the mistakes of Ant. In Ant, all the things just like the location of java files, resources, test sources. Those we have to define by ourselves. This may cause the mess of the files and the huge size of the xml file. However, in Maven, those files have already defined the place by the uniform default convention.

1.3 Gradle

Gradle is like a combination of Ant and Maven. But it still has some features.

  1. Groovy
    It uses a modern language called Groovy instead of the XML file to store the setting, which helps it reduce the setting file and make it more readable. Also, because it is a programming language, most of the pre-treatment and post-treatment can be done just in the Gradle.
  2. flexibility
    In Gradle you can find the tasks (personal define plugins) from Ant, and also can find convention over configuration from Maven, which can realize any functions you want.
  3. Speed Up!
    This part is about the Performance of the build tools. Gradle’s mechanisms for work avoidance and incrementality can help reduce the building time apparently, just like the official website shows:

2. Comparison of build tools

2.1 Ant

  • pros:
    easy to learn
    clear procedure
    satisfying expansibility
  • cons:
    fussy setting file
    missing dependence control

2.2 Maven

  • pros:
    dependency management
    convention over configuration
    an easy-following normalization
  • cons:
    less flexible
    fuzzy setting

2.3 Gradle

  • pros:
    high performance
    high flexibility
    more readable setting file
    easily inherit from Maven
  • cons:
    need to learn a new language

3. Summary

\ Ant Maven Gradle
language XML XML Groovy
config file fuzzy fuzzy simple
performance low low high
flexibility high low high
dependence management No Yes Yes
convention over configuration No Yes Yes

4. References


  1. the official website
  2. the Wikipedia of these three build tools

本文 暂无 评论