Skip to content
This repository has been archived by the owner on Sep 8, 2023. It is now read-only.

Commit

Permalink
Merge pull request #20 from praqma-training/build-phases
Browse files Browse the repository at this point in the history
elaborates on the build-phases kata
  • Loading branch information
michaelin authored Mar 26, 2020
2 parents d9aa4fc + 10bd118 commit 41754d4
Showing 1 changed file with 35 additions and 14 deletions.
49 changes: 35 additions & 14 deletions build-phases/README.md
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?

0 comments on commit 41754d4

Please sign in to comment.