- Java 9 Programming By Example
- Peter Verhas
- 453字
- 2021-07-02 23:37:31
Gradle
Ant and Maven are two worlds, and using one or the other may lead to heated debates on Internet forums. Ant gives freedom to developers to create a build process that fits their taste. Maven restricts the team to use a build process that is more standard. Some special processes that do not match any standard build, but which are sometimes needed in some environments, are hard to implement using Maven. In Ant, you can script almost anything using the built-in tasks, almost the same way as you can program bash. Utilizing Maven is not that simple, and, it often requires writing a plugin. Even though writing a plugin is not rocket science, developers usually like to have the possibility of making things in a simpler way: Scripting. We have two approaches, two mindsets and styles, and not a single tool to fulfill all the needs. No surprise that by the Java technologies were developed, a new build tool was emerging.
Gradle tries to use the best of both worlds, utilizing techniques that were not available by the time Maven and Ant were first developed.
Gradle has built-in targets and life cycle, but at the same time, you can also write your own targets. You can configure a project, just like using Maven, without scripting the tasks to do so, but at the same time, you can also script your own target just like in Ant. What is more, Gradle integrated Ant, so any task implemented for Ant is available for Gradle as well.
Maven and Ant use XML files to describe the build. Today, XML is a technology of the past. We still use it, and a developer should be fluent in handling, reading, and writing XML files, but a modern tool does not use XML for configuration. New, fancy formats such as JSON are more popular. Gradle is no exception. The configuration file of Gradle uses a domain-specific language (DSL) based on Groovy. This language is more readable for programmers and gives more freedom to program build processes. And, this is also the danger of Gradle.
Having the powerful JVM language Groovy in the hands of developers to create build tools gives a freedom and temptation to create complex build processes that seem to be a good idea at the start, but later may prove to be just too complex and hard, and, therefore, expensive to maintain. This is exactly why Maven was implemented in the first place.
I have to stop before getting into another area that is the ground for heated and pointless debates. Gradle is an extremely powerful build tool. You should use it carefully, just like you would use a weapon—don't shoot your legs.
- Java Web開(kāi)發(fā)學(xué)習(xí)手冊(cè)
- 企業(yè)級(jí)Java EE架構(gòu)設(shè)計(jì)精深實(shí)踐
- JMeter 性能測(cè)試實(shí)戰(zhàn)(第2版)
- Elastic Stack應(yīng)用寶典
- Java性能權(quán)威指南(第2版)
- Angular開(kāi)發(fā)入門與實(shí)戰(zhàn)
- Python全棧數(shù)據(jù)工程師養(yǎng)成攻略(視頻講解版)
- 愛(ài)上C語(yǔ)言:C KISS
- Maven for Eclipse
- 會(huì)當(dāng)凌絕頂:Java開(kāi)發(fā)修行實(shí)錄
- Developing RESTful Web Services with Jersey 2.0
- Getting Started with Backbone Marionette
- FORTRAN程序設(shè)計(jì)權(quán)威指南
- MySQL 5.7從入門到精通(視頻教學(xué)版)(第2版)
- MEAN Blueprints