安装
参见 https://gradle.org/install/
Creating New Gradle Builds
Initialize a project
在目录下初始化
gradle init
Create a task
Gradle 提供一些 API,可以通过 Groovy 或 Kotlin-based DSL 创建和配置task。一个项目包含一系列的task,每个用来执行一些基本的操作。
新建task,在build.gradle中,编写以下代码:
task copy(type: Copy, group: "Costom", description: "desc") {
from "src"
into "dest"
}
group description是可选的,不过省略后就不会在report中出现。
执行新建的task:
./gradlew copy
Windows 将
./gradlew换成gradle.bat
Apply a plugin
Gradle 包含一系列的插件。
应用插件,在build.gradle文件最前面:
plugins {
id "base"
}
Explore and debug your build
Discover available tasks
./gradlew tasks
2020-3-8 21:53:34