Gradle doesn’t work like this. A task will never run twice in a single Gradle invocation.
Instead of trying to execute a single task twice (with different config) you should create two tasks of the same type but each with different config/dependencies.
Think of the java plugin which adds two JavaCompile tasks, “compileJava” and “compileTestJava”. It does NOT execute the same compile task twice