...
Code Block |
---|
task helloWorld { doLast { println "Hellow World, version = " + version } } |
Task Dependencies
We can add dependsOn to the task to make it depend on the other.
Code Block |
---|
task copyDocs(type: Copy) {
from "src"
into "build/docs"
include "**/*.md"
includeEmptyDir = false
}
task createZip(type: Zip) {
from "build/docs"
archiveFilename = "docs.zip"
destinationDirectory = file("build/dist")
dependsOn copyDocs
}
|
To see the order without executing the tasks, add --dry-run to the end.
Code Block |
---|
$ gradle hellowWorld --dry-run |
Another way to visualize the gradle tree you can use gradle-task-tree.
See https://github.com/dorongold/gradle-task-tree
Tasks
List all available tasks
Code Block |
---|
$ gradle tasks --all |
Copy Task
Code Block |
---|
task copyDocs(type: Copy) {
from "src"
into "build/docs"
include "**/*.md"
includeEmptyDir = false
} |
Zip
Code Block |
---|
task createZip(type: Zip) {
from "build/docs"
archiveFilename = "docs.zip"
destinationDirectory = file("build/dist")
} |
Lifecycle Phases
Initialization Phase
- evaluates settings file and sets up build
Configuration Phase
- evaluates build scripts and runs configuration logic.
Execution Phase
- executes task actions in correct order.
Configuration Logic
Execution Logic
Dependencies
web-service/build.gradle
Code Block |
---|
dependencies {
implementation project(':utils')
implementation project(':api')
} |