How do I let a task create subtasks based on its c...
# community-support
m
How do I let a task create subtasks based on its configuration? I have a custom task with multiple entrypoints, and I'm trying to make an Exec for each configured entrypoint, but I can't quite figure out how to do it. I tried using
project.afterEvaluate { /* configure extra tasks here */ }
in my task constructor, but that seems to fail because the project is already evaluated.
v
The simple answer is, you do not and should not even try to do something like that. How to do properly what you intend to do can hardly be advised from the given information as it heavily depends on the situation. If you just want to do some
Exec
-like operations as part of your task action, inject the
ExecOperations
service and use its
exec { ... }
method which is practically the same as an
Exec
task, just not as task.
m
It's moreso that in my custom bundling task from buildsrc, people can specify entrypoints, and for each entrypoint, I want to automatically add an exec task for the generated output so executing/testing can be integrated into Gradle.