-
Overview
-
Popular understanding of gradle
The tedious work caused by different software release channels, different mobile phone models, and different dependencies can all be solved by Gradle.
Gradle is a build tool that can help you manage differences, dependencies, compilation, packaging, deployment...You can define the build logic that meets your needs and write it to the
build.gradle
middle for future reuse.Grdle is not a programming language, and it cannot help you implement any actual functions in the software.
-
ant
Ant can automate packaging logic
-
maven
maven
Colleagues who can automate packaging logic can also download jar packages automatically.Gradle
Both capable workmaven
and capable workant
.Gradle
It is not only a configuration script, but several languages behind it:- Groovy Language
- Gradle DSL
- Android DSL
-
The basic composition of Gradle
Project
AndTask
are the two basic concepts of Gradle :Project
, Refers to our build products (such asjar
packages) or implementation products (deploy the application to the production environment)Task
, Refers to the smallest unit of work that cannot be separated and performs construction work
Each construction is made up of one or more
projects
, and each construction is made up ofproject
one or moretask
. -
The composition of the Gradle build system
Any build system is composed of multiple build files:
- Ant consists
build.xml
of - Maven consists
pom.xml
of - Make consists
makefile
of - Gradle consists
build.gradle
settings.gradle
gradle.properties
ofbuild.gradle
The build script defines a module and compiling tasks, which are generally placed in the project's module, or can be placed in the root directory of the project as a global setting for the compilation structure. It is a mustsetting.gradle
It's required. In order to define a multi-project build, you need to create a settings file and place it in the root directory of the source code to specify which projects to include.gradle.properties
Used to configure build properties, not required
- Ant consists
-
Gradle plugin
Gradle 's design philosophy is that all useful features are provided by Gradle plugins.
groovy
Plug-in, which extends theJava
plug-in and adds theGroovy
dependency of compilation ;war
The plug-in is actuallyjava
expanded on the basis of the plug-in to buildWAR
files;Jetty
The plug-in is actuallyWar
expanded on the basis of the plug-in, and the word order user publishes the web application to an interveningJetty
container. -
Gradle running process
You can run a command by gradle Gradle build ,
gradle
command looks for a call in the current directorybuild.gradle
file, thisbuild.gradle
file is called a build script.# 创建文件build.gradle task hello { doLast { println 'Hello World!' } } # 命令行运行 > gradle -q hello # -q是quiet模式,不产生gradle的日志信息 Hello World!
Here, the build script
build.gradle
defines an independenttask
, calledhello
, then added aaction
run when the command linegradle hello
, Gradle execution is calledhello
thetask
, which is carried outtask
ofaction
, thisaction
is a contains some Groovy code闭包closure
.> gradle build
Herebuild
is aplugin
java
built-in tasktask
,gradle clean
,gradle assemble
,gradle check
,gradle properties
ibid.> gradle compile test # 实现一次调用多个`task`,`compile`, `test`会被依次调用。 > gradle dist -x test # 命令行选项-x用来排除某些任务 > gradle --continue # --continue选项,某任务调用失败后继续执行后续任务,以期发现跟多错误 > -b # -b参数用于选择其他目录的构建文件,且settings.gradle将不会生效 > -p # -b是指定脚本,-p是指定脚本所在的目录 > gradle projects # 列出子项目名称列表 > gradle tasks # 列出项目中所有任务 > gradle tasks --all # --all 列出项目中所有任务以及任务之间的依赖关系 > gradle help --task someTask # 显示指定任务的详细信息 > gradle dependencies # 列出项目的依赖列表 > gradle dependencyInsight # 查看指定的依赖 > gradle properties # 获取项目所有属性列表 > gradle --profile # 收集构建期间的信息并保存到build/reports/profile目录下,以构建时间命名 > gradle -i # INFO log > gradle -d # DEBUG log
-
Gradle repository
Gradle will
repository
find various dependent files in one .repository
Is a collection of files, bygroup
,name
,version
finishing classification.Gradle can parse out several different warehouse forms, such as
maven
andivy
, and can understand various ways to enter the warehouse, such as using the local file system or HTTP. -
Project properties||variables
project
Object provides a number of standard attributes:project
,name
,path
,description
,projectDir
,build
,group
,version
,ant
.There are two types of variables in the Gradle build script :
- Local variables (
local
),def
- Expansion variables (
extra
).
- Local variables (
-
Gradle Build Language References
Gradle scripts are configuration scripts.
As the script executes, it configures an object of a particular type.
-
References
Meet gradle again
Guess you like
Origin blog.csdn.net/The_Time_Runner/article/details/113000987
Recommended
Ranking