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).
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
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
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:
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 :(
There are two changes between
The key component: dependency management
Mavenbuilds a system based on this main factor. It can quickly locate to a specified dependent package with three elements. Once given the
version, it can find the
jarfile and run automatically.
It also introduces a new concept: a
repositoryto 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.
An agreement: convention over configuration
It also learns from the mistakes of
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
xmlfile. However, in
Maven, those files have already defined the place by the uniform default convention.
Gradle is like a combination of
Maven. But it still has some features.
It uses a modern language called
Groovyinstead of the
XMLfile 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
Gradleyou 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.
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:
easy to learn
fussy setting file
missing dependence control
convention over configuration
an easy-following normalization
more readable setting file
easily inherit from
need to learn a new language
|convention over configuration||No||Yes||Yes|