I am confused by gradle build lifecycle
for a few days. Refer tells me
A Gradle build has three distinct phases.
- Initialization
- Configuration
- Execution
Is task creation in the third step? If so, how does gradle
find all tasks
in a project object?
Here is an example.
rootporject
|----app
|----build.gradle
|----checkstyle.gradle
The build.gradle
is as simple as normal.checkstyle.gradle
file has a task. Here is its content.
apply plugin: 'checkstyle'
task checkstyle(type:Checkstyle) {
description 'Runs Checkstyle inspection against girl sourcesets.'
group = 'Code Quality'
configFile rootProject.file('checkstyle.xml')
ignoreFailures = false
showViolations true
classpath = files()
source 'src/main/java'
}
After ./gradlew -q tasks
, there is no task checkstyle
.
But if I remove the definition into build.gradle
, I get it.
Is there anything wrong?Thanks in advance.
From doc
There is a one-to-one relationship between a Project and a build.gradle file.
You haven't applied your other script.
In your build.gradle
you should add an apply from: 'checkstyle.gradle'
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With