Ken Yee
04/06/2022, 8:35 PMfun Project.addTaskToTaskGraph(taskProvider: TaskProvider<*>) =
afterEvaluate {
// A hack to delay adding the task until its dependencies have been configured, but before the graph is
// computed.
(gradle.taskGraph as TaskExecutionGraphInternal).addEntryTasks(listOf(taskProvider.get()))
}
Vampire
04/07/2022, 1:57 AMKen Yee
04/07/2022, 12:28 PMVampire
04/07/2022, 1:36 PM...Internal
is a very strong sign of code-smell. 🙂
If you want to configure tasks, why don't you just do it?
And if you want to disable tasks after things ar configured, use Task.onlyIf
closure which is evaluated at task execution time to check whether the task should run or not.Ken Yee
04/07/2022, 2:14 PMVampire
04/07/2022, 2:20 PMtasks.configureEach { dependsOn(mybootstrapTask) }
César Puerta
04/12/2022, 1:47 PMStartParameter
but I don’t think that’s any better.César Puerta
04/12/2022, 1:48 PMCésar Puerta
04/12/2022, 1:48 PMVampire
04/12/2022, 1:48 PMtasks.configureEach { dependsOn(rootProject.mybootstrapTask) }
?César Puerta
04/12/2022, 1:49 PMCésar Puerta
04/12/2022, 1:50 PMVampire
04/12/2022, 1:50 PMVampire
04/12/2022, 1:51 PMVampire
04/12/2022, 1:51 PMCésar Puerta
04/12/2022, 1:52 PMCésar Puerta
04/12/2022, 1:52 PMVampire
04/12/2022, 1:52 PMCésar Puerta
04/12/2022, 1:53 PMCésar Puerta
04/12/2022, 1:53 PMVampire
04/12/2022, 1:54 PMCésar Puerta
04/12/2022, 1:54 PMCésar Puerta
04/12/2022, 1:55 PMCésar Puerta
04/12/2022, 1:55 PMVampire
04/12/2022, 2:04 PMidea-ext
plugin.
Another possibility for corporate projects would of course be a custom distribution.
There you can basically change any Gradle implementation detail you like, including the possibility to inject such a bootstrap task.César Puerta
04/12/2022, 2:15 PMCésar Puerta
04/12/2022, 2:16 PMVampire
04/12/2022, 2:17 PMVampire
04/12/2022, 2:17 PMCésar Puerta
04/12/2022, 2:18 PMVampire
04/12/2022, 2:18 PMCésar Puerta
04/12/2022, 2:19 PM