A, Gradle Profile
1.1 What is Gradle?
Gradle is an open source tool for building automation projects based on Apache Ant and Maven concepts of Apache. It is based on the use Groovy
of DSL
(Domain-Specific Language Domain Specific Language) to declare the project settings, abandoned the XML-based variety of complicated configurations. For Java-based applications. It supports the current language is limited to Java, Groovy, Kotlin and Scala, plan for the future will support more languages.
Gradle is a JVM-based build tool, is a versatile and flexible building tools, support for Maven, Ivy warehouse, supports transitive dependencies management, without the need to warehouse or remote pom.xml
and ivy.xml
profiles, based on Groovy (Groovy is a JVM-based dynamic languages), build scripts written in Groovy.
1.2 Gradle function
- Based on the construction and building claims-based convention
- Language support is dependent manner based programming
- Construction of structured
- Depth API
- Good Gradle extension
- Construction of multi-project
- In many ways depend on administration
- Easy to transplant
- Gradle build scripts are written using Groovy instead of XML
- Gradle Wrapper allows you to perform on machines without installation of Gradle Gradle build
- Gradle is an open source project, and follow the ASL license
1.3 Groovy compared with Java
Groovy is an agile dynamic to as a JVM language, it is a mature object-oriented programming language that can be used for both object-oriented programming, but also can be used as a pure scripting language. Use the language without having to write much code, but also has 闭包
other characteristics and dynamic languages.
- Groovy is fully compatible with Java syntax (because they are based on the JVM)
- The semicolon is optional
- Class, the default method is
public
the - Attribute automatic-addition to the compiler
getter/setter
method - Property can be used as a dot (
.
) Gets - The last value of the expression is as a return value (that is, if the method needs to return a value, you
return
can not write) ==
Equivalentequals()
, noNullPointerExceptions
1.4 Groovy some efficient properties
- Own
assert(断言)
statement (assertion can operate anywhere) - Optional Type Definition (corresponding to a weakly typed programming languages)
- Optional brackets (parentheses parameters such as call can not write)
- String (expressed in three forms: single and double quotation marks, and three single quotes)
- Set of API (Groovy in List, Map a more simple wording)
- Closure
Two, Gradle installation configuration (Windows)
2.1 Prerequisites
- The JDK:
JDK 8
(JDK & JRE need to 8 or higher, this is usedjava version "1.8.0_65"
)
2.2 Manual installation
The current version is version 5.4.1 Gradle, on April 26, 2019 release. Distribution zip files in two versions:
- Binary-only (gradle-5.4.1-bin.zip 81.3M) ;
- Complete (gradle-5.4.1-all.zip 127M) , there are documents and sources.
When in doubt, choose only a binary version and see the online documentation and source . You need to use the old version? See version page .
2.3 environment configuration
- New directory under the disk D
D:\Gradle
, and download thegradle-5.4.1-bin.zip
unzip to the folder; - Editing environment variables
Path
variable, add entriesD:\Gradle\gradle-5.4.1\bin
, click "OK" to save.
2.4 Gradle verify whether the installation was successful
Windows + R
-> inputcmd
into the command line;- Run
gradle -v
View Gradle version information.
C:\Users\Administrator>gradle -v
Welcome to Gradle 5.4.1!
Here are the highlights of this release:
- Run builds with JDK12
- New API for Incremental Tasks
- Updates to native projects, including Swift 5 support
For more details see https://docs.gradle.org/5.4.1/release-notes.html
------------------------------------------------------------
Gradle 5.4.1
------------------------------------------------------------
Build time: 2019-04-26 08:14:42 UTC
Revision: 261d171646b36a6a28d5a19a69676cd098a4c19d
Kotlin: 1.3.21
Groovy: 2.5.4
Ant: Apache Ant(TM) version 1.9.13 compiled on July 10 2018
JVM: 1.8.0_65 (Oracle Corporation 25.65-b01)
OS: Windows 10 10.0 amd64