Is there a way to call task from another task?

I’ve been trying to emebedd my rust project into gradle building. But rust’s release building is platform related. I have many build tasks for each platforms. And I need to decide call one manually. So I thought I can solve this by add an auto-detected task.

At first, I used the dependsOn function. Then I found that it determined the dependency each time I refresh the project, and slow down the sync every time. Then I tried to find a way to make the auto-detected task call another task only when it was called.

Unluckily, I did not find the solution what I want. Dear Mr. Vampire, do you know any information about that?

You cannot call a task.

If you have multiple tasks for multiple platforms you could for example use onlyIf { ... } on the tasks to determine which should be executed and which should be skipped.

If the recognition is costly, you could do the recognition for example once in a shared build service and then check the state in that build service from the onlyIf { ... } closures.