- 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.
- 微服務設計(第2版)
- Spring 5.0 By Example
- C語言程序設計案例教程(第2版)
- Learning ArcGIS Pro 2
- C語言程序設計教程(第2版)
- 碼上行動:零基礎學會Python編程(ChatGPT版)
- SAP BusinessObjects Dashboards 4.1 Cookbook
- C#實踐教程(第2版)
- Getting Started with React Native
- 深入解析Java編譯器:源碼剖析與實例詳解
- Android移動應用開發項目教程
- Python Projects for Kids
- Design Patterns and Best Practices in Java
- 熱處理常見缺陷分析與解決方案
- C++ Windows Programming