padraic
(Padraic Renaghan)
May 25, 2022, 11:29pm
1
Following guidance on lazy configuring tasks
Then run a build with --scan
to see results
Shows Created during configuration 14
But then down below none of them say X tasks created on the right side
And opening each in detail, can’t find any that show tasks created
Viewing page source and searching for tasks created
returns nothing
How can I see what these 14 tasks created during configuration are?
See attached screenshot from scan
Vampire
(Björn Kautler)
May 26, 2022, 10:42am
2
For me there is an additional column to the right of “applied to x projects” where it says how many tasks were created immediately or during configuration and then you can expand to see which it were exactly. Maybe you got some bug is it is not the case for you.
padraic
(Padraic Renaghan)
May 26, 2022, 12:50pm
3
I see that column in the HTML of the page, td.ConfigurationTabCodeUnitItem__early-tasks-count
, it exists on every row, but it is empty
padraic
(Padraic Renaghan)
May 26, 2022, 12:54pm
4
Added the below to the root project, seems to work to log when a task is configured… oddly noticing that the tasks being configured I do not expect is the clean
task of every subproject. Any ideas on why this is appreciated
allprojects.forEach { p ->
p.afterEvaluate {
tasks.configureEach {
logger.warn("pcr configuring ${p.name} : ${this.name}")
}
}
}
padraic
(Padraic Renaghan)
May 26, 2022, 1:16pm
5
Running with debugging logging can clearly see the clean
task being “realized”. Having trouble figuring out why that is the case
2022-05-26T09:10:45.826-0400 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationRunner] Build operation 'Register task :annotation:clean' started
2022-05-26T09:10:45.826-0400 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationRunner] Completing Build operation 'Register task :annotation:clean'
2022-05-26T09:10:45.826-0400 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationRunner] Build operation 'Register task :annotation:clean' completed
2022-05-26T09:10:45.867-0400 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationRunner] Build operation 'Realize task :annotation:clean' started
2022-05-26T09:10:45.867-0400 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationRunner] Completing Build operation 'Realize task :annotation:clean'
2022-05-26T09:10:45.867-0400 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationRunner] Build operation 'Realize task :annotation:clean' completed
padraic
(Padraic Renaghan)
May 26, 2022, 3:19pm
6
seems to even happen on the basic gradle demo project so opened an issue
opened 03:16PM - 26 May 22 UTC
a:bug
to-triage
### Expected Behavior
The `clean` task should not be created during configura… tion. It should remain lazy configured, and thus only created when needed in the execution graph.
### Current Behavior
The clean task is always being created during configuration, even when running something that does not use it like `help`
### Context
I am trying to reach complete lazy task configuration. I have been able to do so for all of the tasks I create. The only task I cannot figure out how to act in a lazy configuration manner is the built-in lifecycle `clean` task.
Although the clean task is fast, it still takes time, and defeats the overall Gradle recommendation, guidance, and philosophy of tasks being configured only when needed (lazy).
I am not a Gradle internal expert, but I tried via debugger to figure out what is going on. Seems linked to
* `LifecycleBasePlugin.apply`
* calls `LifecycleBasePlugin.addClean`
* has `buildOutputCleanupRegistry.registerOutputs(clean.map(cl -> cl.getTargetFiles()))`
* `getTargetFiles` adds the clean task reference to the build output cleanup registry
* Later in Gradle processing `DefaultBuildWorkPreparer.finalizeWorkGraph` is invoked
* that has: `buildOutputCleanupRegistry.resolveOutputs()`
* that ends up calling `get()` on the task provider in order to get its outputs
### Steps to Reproduce
create a demo gradle java project [per gradle instructions](https://docs.gradle.org/current/samples/sample_building_java_applications.html)
see attached [demo-gradle.zip](https://github.com/gradle/gradle/files/8780025/demo-gradle.zip)
run `./gradlew --scan help`
[scan result](https://scans.gradle.com/s/dm3tcbx3emsdk/performance/configuration)
note: `created during configuration = 1`
note: the scan report in table at bottom does not show the "1 task created" column, making it difficult to find the task that was created during configuration. The column is in the page html, but is empty for all rows
to try and see what is being created, add this to bottom of `app/build.gradle.kts`
```
afterEvaluate {
tasks.configureEach {
logger.warn("WARN configuring task ${this.name}")
}
}
```
re-run `./gradlew --scan help`
[scan result](https://scans.gradle.com/s/zq5xc7etp3ioa/performance/configuration)
output shows the clean task configured
```
./gradlew --scan help
WARN configuring task clean
> Task :help
...
```
### Your Environment
Mac OS 12.4
JVM: openjdk version "17.0.1" 2021-10-19 LTS
OpenJDK Runtime Environment Corretto-17.0.1.12.1 (build 17.0.1+12-LTS)
OpenJDK 64-Bit Server VM Corretto-17.0.1.12.1 (build 17.0.1+12-LTS, mixed mode, sharing)
Gradle 7.4.2
Build scan URL:
https://scans.gradle.com/s/dm3tcbx3emsdk/performance/configuration
1 Like