Slackbot
05/02/2023, 2:21 PMChris Lee
05/02/2023, 3:15 PMMatt Groth
05/02/2023, 4:46 PMtask.dependsOn(tasks.withType<Jar>())
.grossws
05/05/2023, 3:38 PMtasks.withType<T>()
isn't a plain collection, it's a TaskCollection
which is a view into TaskContainer
Anyway it should be stable by the time gradle calculates task graph, so changes after TaskExecutionGraph#whenReady
callback is called would either lead to error or just ignored. Obviously some configuration could be done in that callback and afterEvaluate
later when task graph is already frozen.Matt Groth
05/05/2023, 5:10 PMmySet
is not modified after TaskExecutionGraph#whenReady
, then I’m fine?grossws
05/05/2023, 5:24 PMwhenReady
is still part of the project evaluation and task graph should be frozen by the time it's callback is called and evaluation continue afterwards. So projects are partially evaluated, task graph is built, evaluation continue.
Just like with dependency graph, there are points in evaluation process where you still can change dependencies, and there are points in time when it's too late. IIRC Gradle throws an error if you try that with dependencies and has a callback to delineate these phases for deps. Not sure if TaskExecutionGraph#whenReady
is such barrier and if error is thrown in case you try to modify task dependencies too late or if it's just silently ignored.
What I'm saying is that it's totally not ok to modify such a collection after task graph is built. It doesn't mean that it wouldn't be frozen earlier.grossws
05/05/2023, 5:26 PMafterEvaluate
or task's configure
) you would be safe since in that time user could register or create task which affects the graph.grossws
05/05/2023, 5:27 PMSetProperty
instead of mutableSet
since gradle may handle them differently and use normal collection contents eagerlyMatt Groth
05/05/2023, 5:59 PMval mySet = project.objects.domainObjectSet(TaskProvider::class.java);
Matt Groth
05/05/2023, 6:00 PMMatt Groth
05/05/2023, 6:02 PMmySet.whenObjectAdded
or something which throws an error if a certain point has been reached where it is no longer safe to modify. I’m just not sure exactly when that point would be.