官术网_书友最值得收藏!

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.

主站蜘蛛池模板: 吐鲁番市| 尤溪县| 蓬安县| 自贡市| 永年县| 东阳市| 长沙县| 宁武县| 海安县| 双牌县| 开封县| 沂源县| 榕江县| 延安市| 永靖县| 柳州市| 新化县| 温州市| 翁牛特旗| 丰台区| 安龙县| 三台县| 陇川县| 龙南县| 武乡县| 宜君县| 霞浦县| 达尔| 巴东县| 鄂温| 通州市| 万山特区| 海城市| 怀化市| 澄江县| 宽甸| 松原市| 麻城市| 玉田县| 邳州市| 秭归县|