This repository has been archived by the owner on Sep 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from praqma-training/build-phases
elaborates on the build-phases kata
- Loading branch information
Showing
1 changed file
with
35 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,44 @@ | ||
# Build phases | ||
# Gradle Kata: Build phases | ||
|
||
## Configuration vs execution time | ||
This kata explores the three stages of a gradle build: | ||
- Initialization | ||
- Configuration | ||
- Execution | ||
|
||
The `build.gradle` script in this exercise contains a property and two tasks: | ||
## Setup | ||
|
||
- `setTheValue` changes the value of `theValue` | ||
- `printTheValue` prints the value of `theValue` | ||
Run `source setup.sh` | ||
|
||
Predict the outcome of the following commands: | ||
This will create a new gradle project in the `exercise` directory and add several tasks to `build.gradle` | ||
|
||
- `./gradlew printTheValue` | ||
- `./gradlew setTheValue printTheValue` | ||
## The task | ||
|
||
Run the commands and note the printed values. | ||
- Examine the `build.gradle` script. It contains a property and two tasks: | ||
|
||
- Q: Did the output match your expectations? If not, what tripped you up? | ||
- `setTheValue` changes the value of `theValue` | ||
- `printTheValue` prints the value of `theValue` | ||
|
||
- Predict the outcome of the following commands: | ||
|
||
- `./gradlew printTheValue` | ||
- `./gradlew setTheValue printTheValue` | ||
|
||
Make a small change to the `build.gradle` such that: | ||
- Run the commands and note the printed values. | ||
|
||
- Q: Did the output match your expectations? If not, what tripped you up? | ||
|
||
- the `printTheValue`-task ends up printing `The value currently is: 200`, | ||
- when run after the `printTheValue` task and | ||
- while still using the `theValue` variable | ||
- Change `printTheValue` so that the `message` is defined inside the doLast block | ||
``` | ||
task 'printTheValue' { | ||
group 'Value' | ||
description 'Prints the value' | ||
doLast { | ||
def message = "The value currently is: ${theValue}" | ||
println message | ||
} | ||
} | ||
``` | ||
|
||
- Run `./gradlew setTheValue printTheValue` again | ||
- Why is the increased `theValue` printed this time, when it wasn't before? |