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

Commit 41754d4

Browse files
authored
Merge pull request #20 from praqma-training/build-phases
elaborates on the build-phases kata
2 parents d9aa4fc + 10bd118 commit 41754d4

File tree

1 file changed

+35
-14
lines changed

1 file changed

+35
-14
lines changed

build-phases/README.md

Lines changed: 35 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,44 @@
1-
# Build phases
1+
# Gradle Kata: Build phases
22

3-
## Configuration vs execution time
3+
This kata explores the three stages of a gradle build:
4+
- Initialization
5+
- Configuration
6+
- Execution
47

5-
The `build.gradle` script in this exercise contains a property and two tasks:
8+
## Setup
69

7-
- `setTheValue` changes the value of `theValue`
8-
- `printTheValue` prints the value of `theValue`
10+
Run `source setup.sh`
911

10-
Predict the outcome of the following commands:
12+
This will create a new gradle project in the `exercise` directory and add several tasks to `build.gradle`
1113

12-
- `./gradlew printTheValue`
13-
- `./gradlew setTheValue printTheValue`
14+
## The task
1415

15-
Run the commands and note the printed values.
16+
- Examine the `build.gradle` script. It contains a property and two tasks:
1617

17-
- Q: Did the output match your expectations? If not, what tripped you up?
18+
- `setTheValue` changes the value of `theValue`
19+
- `printTheValue` prints the value of `theValue`
20+
21+
- Predict the outcome of the following commands:
22+
23+
- `./gradlew printTheValue`
24+
- `./gradlew setTheValue printTheValue`
1825

19-
Make a small change to the `build.gradle` such that:
26+
- Run the commands and note the printed values.
27+
28+
- Q: Did the output match your expectations? If not, what tripped you up?
2029

21-
- the `printTheValue`-task ends up printing `The value currently is: 200`,
22-
- when run after the `printTheValue` task and
23-
- while still using the `theValue` variable
30+
- Change `printTheValue` so that the `message` is defined inside the doLast block
31+
```
32+
task 'printTheValue' {
33+
group 'Value'
34+
description 'Prints the value'
35+
36+
doLast {
37+
def message = "The value currently is: ${theValue}"
38+
println message
39+
}
40+
}
41+
```
42+
43+
- Run `./gradlew setTheValue printTheValue` again
44+
- Why is the increased `theValue` printed this time, when it wasn't before?

0 commit comments

Comments
 (0)