gradle

Gradle is a project build and automation tool for java based applications; something like ivy, ant and maven. Build tools help us to reduce our development and test time and hence increase productivity.

Gradle是用于基于Java的应用程序的项目构建和自动化工具; 像常春藤,蚂蚁和行家。 构建工具可帮助我们减少开发和测试时间,从而提高生产率。

Gradle (Gradle)

Grunt and Gulp are two popular build and automation tools for javascript projects like NodeJS or jQuery. Gant is a build tool mainly used for Groovy based applications. SBT stands for Scala Build Tool. SBT is mainly used for Scala based applications.

Grunt和Gulp是用于NodeJS或jQuery之类JavaScript项目的两种流行的构建和自动化工具。 Gant是一个构建工具,主要用于基于Groovy的应用程序。 SBT代表Scala Build Tool。 SBT主要用于基于Scala的应用程序。

Now-a-days, most of the java projects are using either maven or gradle build tools because of their benefits when compared to ant.

如今,大多数Java项目都使用maven或gradle构建工具,因为与ant相比,它们具有很多优势。

Before discussing about Gradle, first we will go through some shortcomings of ant and maven. Then we will discuss about why we need Gradle build tool to our projects.

在讨论Gradle之前,首先我们将探讨ant和maven的一些缺点。 然后,我们将讨论为什么我们需要在项目中使用Gradle构建工具。

蚂蚁的缺点 (Drawbacks of Ant)

The following are main drawbacks of using ant build tools in our project.

以下是在我们的项目中使用蚂蚁构建工具的主要缺点。

  1. We need to write ant build scripts using XML. If we want to automate a complex project, then we need to write a lot of logic in XML files.我们需要使用XML编写ant构建脚本。 如果要自动化复杂的项目,则需要在XML文件中编写很多逻辑。
  2. When we execute complex and large project’s ant build, it produces a lot of verbose at console.当我们执行复杂的大型项目的ant构建时,会在控制台上产生很多冗长的信息。
  3. There is no built-in ant project structure. Since we can use any build structure for our projects, new developers find it hard to understand the project struct and build scripts.没有内置的ant项目结构。 由于我们可以为项目使用任何构建结构,因此新开发人员很难理解项目的结构和构建脚本。
  4. It is very tough to write some complex logic using if-then-else statements.使用if-then-else语句编写一些复杂的逻辑非常困难。
  5. We need to maintain all jars with required version in version control. There is no support for dependency management.我们需要在版本控制中维护所有具有所需版本的jar。 不支持依赖项管理。

Because of these many drawbacks, now-a-days most of the projects have restructured and they are using maven build tool. Even though Maven provides the following benefits compare to ant, but still it has some drawbacks.

由于存在许多缺点,如今大多数项目已经进行了重组,并且正在使用maven构建工具。 尽管Maven与ant相比具有以下优点,但仍具有一些缺点。

Maven的优势 (Advantages of Maven)

  1. Maven is an expressive, declarative, and maintainable build tool.Maven是一种表达性,声明性和可维护性的构建工具。
  2. All maven projects follow pre-defined structure. Even new developers find it easy to understand the project structure and start development quickly.所有的Maven项目都遵循预定义的结构。 即使是新开发人员,也很容易理解项目结构并快速开始开发。
  3. We don’t need to maintain all jars with required version in version control. Maven will download all required jars at build time. Maven support for dependency management is one of the best advantage it has over ant.我们不需要在版本控制中维护所有具有所需版本的jar。 Maven将在构建时下载所有必需的jar。 Maven对依赖项管理的支持是它相对于ant的最大优势之一。
  4. Maven gives us very modularized project structure.Maven为我们提供了非常模块化的项目结构。

Maven的缺点 (Drawbacks of Maven)

  1. Maven follows some pre-defined build and automation lifecycle. Sometimes it may not fit to our project needs.Maven遵循一些预定义的构建和自动化生命周期。 有时它可能不适合我们的项目需求。
  2. Even though we can write custom maven life cycle methods, but it’s a bit tough and verbose.尽管我们可以编写自定义的Maven生命周期方法,但是这有点困难和冗长。
  3. Maven build scripts are a bit tough to maintain for very complex projects.对于非常复杂的项目,Maven构建脚本很难维护。

Maven has solved most of the ant build tool issues, but still it has some drawbacks. To overcome these issues, we need to use Gradle build tool. Now we can start our discussion on Gradle.

Maven解决了大多数蚂蚁构建工具问题,但仍然存在一些缺陷。 为了克服这些问题,我们需要使用Gradle构建工具。 现在我们可以在Gradle上开始讨论了。

什么是Gradle? (What is Gradle?)

Gradle is an opensource build and automation tool for java based projects. Using Gradle, we can reduce project development time and increase productivity.

Gradle是用于基于Java的项目的开源构建和自动化工具。 使用Gradle,我们可以减少项目开发时间并提高生产率。

Gradle is a multi-language, multi-platform, multi-project and multi-channel build and automation software.

Gradle是一款多语言,多平台,多项目和多渠道的构建和自动化软件。

Gradle优势 (Gradle advantages)

Gradle will provide the following advantages compared to ant and maven. That’s why all new projects are using Gradle as build tool.

与ant和maven相比,Gradle将提供以下优势。 这就是所有新项目都使用Gradle作为构建工具的原因。

  1. Like Maven, Gradle is also an expressive, declarative, and maintainable build Tool.与Maven一样,Gradle也是一种表达性,声明性和可维护性的构建工具。
  2. Just like maven, Gradle also supports dependency management.就像Maven一样,Gradle也支持依赖项管理。
  3. Gradle provides very scalable and high-performance builds.Gradle提供了非常可扩展的高性能构建。
  4. Gradle provides standard project layout and lifecycle, but it’s full flexibility. We have the option to fully configure the defaults. This is where it’s better than maven.Gradle提供了标准的项目布局和生命周期,但具有完全的灵活性。 我们可以选择完全配置默认值。 这是比Maven更好的地方。
  5. It’s very easy to use gradle tool and implement custom logic in our project.在我们的项目中使用gradle工具和实现自定义逻辑非常容易。
  6. Gradle supports the project structure that consists of more than one project to build deliverable.Gradle支持由多个项目组成的项目结构,以构建可交付成果。
  7. It is very easy to integrate existing ant/maven project with Gradle.将现有的ant / maven项目与Gradle集成非常容易。
  8. It is very easy to migrate from existing ant/maven project to Gradle.从现有的ant / maven项目迁移到Gradle非常容易。

Gradle combines most of the popular build tool plus points into a single build tool.

Gradle将大多数流行的构建工具加点组合到一个构建工具中。

In simple terminology, Gradle is built by taking all the good things from ant, maven, ivy and gant.

用简单的术语来说,Gradle是通过吸收蚂蚁,maven,常春藤和gant的所有好东西而构建的。

That means Gradle combines best features of all popular build tools:

这意味着Gradle结合了所有流行构建工具的最佳功能:

  • Ivy and ant power and flexibility常春藤和蚂蚁的力量和灵活性
  • Maven’s easy to use, lifecycle management and dependency managementMaven易于使用,生命周期管理和依赖管理
  • Gant’s build scriptsGant的构建脚本

NOTE: Gant is a Groovy based build system that internally uses ant tasks. In Gant, we need to write build scripts in Groovy, but no XML. Refer it’s official website for more information.

注意: Gant是一个基于Groovy的构建系统,在内部使用ant任务。 在Gant中,我们需要用Groovy编写构建脚本,但是不需要XML。 请参阅其官方网站以获取更多信息。

为什么我们需要选择Gradle? (Why we need to choose Gradle?)

  1. Gradle’s build scripts are more readable, expressive and declarative.Gradle的构建脚本更具可读性,表达性和声明性。
  2. Gradle’s build scripts are written in simple Groovy, no XML. That means it use it’s own DSL based on Groovy script.Gradle的构建脚本使用简单的Groovy编写,没有XML。 这意味着它使用基于Groovy脚本的自己的DSL。
  3. It’s highly scalable for complex multi-module projects.对于复杂的多模块项目,它具有高度的可扩展性。
  4. Unlike Maven’s pom.xml, No need to write boilerplate XML Code与Maven的pom.xml不同,无需编写样板XML代码
  5. It provides plugins for most of the IDEs like Eclipse, IntelliJ IDEA, Spring STS Suite etc.它为大多数IDE(例如Eclipse,IntelliJ IDEA,Spring STS Suite等)提供插件。
  6. It is very easy to maintain even for multi-module complex projects.即使对于多模块的复杂项目,维护也非常容易。

什么是Gradle的座右铭? (What is Gradle’s Motto?)

“Make the impossible possible, make the possible easy, and make the easy elegant”.

“使不可能变为可能,使可能变得容易,并使容易变得优雅”。

By reading the Gradle’s Motto, we can understand that main goal and advantages of Gradle build tool.

通过阅读Gradle的座右铭,我们可以了解Gradle构建工具的主要目标和优势。

As of now, Gradle works as build and automation tool for the following projects.

到目前为止,Gradle可以作为以下项目的构建和自动化工具。

  • Java/Scala/Groovy Based Projects基于Java / Scala / Groovy的项目
  • Android ProjectsAndroid专案
  • C/C++ ProjectsC / C ++项目
  • JavaScript Based Projects基于JavaScript的项目

Now we are clear that Gradle is the best build and automation tool to use in our projects. We are going to use Gradle in my Spring Boot Tutorial. As of today, Gradle’s latest and stable version is 4.1 released on 07-Aug-2017. We are going to use this version to run our examples.

现在我们很清楚,Gradle是在我们的项目中使用的最佳构建和自动化工具。 我们将在我的Spring Boot Tutorial中使用Gradle。 截至今天,Gradle的最新稳定版本为2017年8月7日发行。 我们将使用此版本来运行示例。

Gradle official website: https://gradle.org/

Gradle官方网站: https : //gradle.org/

Gradle安装 (Gradle Install)

Please follow the following steps to install Gradle in Windows systems.

请按照以下步骤在Windows系统中安装Gradle。

  1. Download latest Gradle software from https://gradle.org/ by clicking “Download Gradle 2.4” button as shown below通过单击“ Download Gradle 2.4”按钮,从https://gradle.org/下载最新的Gradle软件,如下所示
  2. Once download is successfully, we can observe a zip file as shown below

    下载成功后,我们可以看到一个zip文件,如下所示

  3. Extract zip file into local file system将zip文件解压缩到本地文件系统中
  4. Observe Gradle Home directory:

    观察Gradle主目录:

    Observe Gradle BIN directory:

    观察Gradle BIN目录:

  5. Set the following System Variables设置以下系统变量
  6. set GRADLE_HOME=D:\gradle-2.4
    set PATH=D:\gradle-2.4\bin;%PATH%

    设置GRADLE_HOME=D:\gradle-2.4
    设置PATH=D:\gradle-2.4\bin;%PATH%

  7. Open CMD Prompt and check the Setup is done successfully or not.打开CMD提示符,然后检查设置是否成功。

We can use either of the following two commands to know the Gradle version.

我们可以使用以下两个命令之一来了解Gradle版本。

D:\>gradle -v
Or
D:\>gradle --version

By observing this output at Command Prompt as shown in above screenshot, we can say that Gradle installation is successful.

通过如上截屏所示在命令提示符处观察此输出,可以说Gradle安装成功。

That’s it for now. We will see some Gradle simple and complex examples in coming posts.

现在就这样。 在接下来的文章中,我们将看到一些Gradle简单和复杂的示例。

翻译自: https://www.journaldev.com/7971/gradle

gradle

gradle_Gradle相关推荐

  1. ant构建项目迁移到gradle_Gradle构建工具

    构建工具的作用:依赖管理:测试.打包.发布:机器能干的活,绝不自己动手. 主流构建工具: (1)Ant:编译.测试.打包: (2)Maven:依赖管理.发布: (3)Gradle:Groovy,具有更 ...

  2. ant构建项目迁移到gradle_Gradle这么弱还跑来面腾讯?

    点击上方"刘望舒",选择"星标"  多点在看,就是真爱 作者: 厘米姑娘(腾讯开发妹子)| 来源 :公号 码个蛋 https://www.jianshu.com ...

  3. as4配置本地gradle_Gradle和Maven的区别

    Java世界中主要有三大构建工具:Ant.Maven和Gradle.Maven的主要功能是:依赖管理系统.多模块构建.一致的项目结构.一致的构建模型和插件机制. maven使用groupId.arti ...

最新文章

  1. 黑帽SEO:Google为什么会屏蔽你的网站
  2. C++类型转换(翻译自cplusplus)
  3. linux终端显示被覆盖,图文说明:Linux监控命令全覆盖
  4. 元素水平垂直居中的方法
  5. 使用 C# 开发智能手机软件:推箱子(十二)
  6. Linux日志文件总管——logrotate
  7. 深入理解对象的数据属性与访问器属性及属性间相互转换
  8. GNU宣言——Ubuntu*操作系统将ubuntu精神带到了软件世界
  9. CentOS 7 (RHEL 7)服务管理命令的变化
  10. 静态include与动态include的区别
  11. mac tree命令
  12. 简单谈谈对软件工程的理解
  13. Intel HD Graphics
  14. 计算机科学导论第五版第二章答案,计算机科学导论第2章-答案
  15. linux系统格式化硬盘
  16. 锐龙r7 4800U和i7-10710U 哪个好
  17. 雷神电脑 ST-plus windows10+ubuntu16.04 双硬盘 双系统超详细安装
  18. 粘结剂菱镁板建筑材料英国UKCA认证—EN 14016-1
  19. Netty相关面试题汇总
  20. 认准魔趣吧唯一网址https://www.moqu8.com,谨防上当受骗!

热门文章

  1. 纪念宾得4000万象素的120数码相机645D推出两周年
  2. 使用特殊字体实现特殊报表效果
  3. [转载] python学习-基础教程、深度学习
  4. Hamilton四元数
  5. 学习项目管理PRINCE2有什么用??
  6. 【bzoj 入门OJ】[NOIP 热身赛]Problem C: 星球联盟(并查集)
  7. Starship Troopers(HDU 1011 树形DP)
  8. HttpClient的使用方法
  9. Codeforces Round#308
  10. PS中的Workflow的创建