Run gradle build(test) some modules in custom task

How to run task build or test some modules in custom task in build.gradle.kts?
For example, I have modules: firstA, secondA, thirdA. I want to run build in custom task only firstA and thirdA modules.

You wouldn’t actually run those other tasks, but add a task dependency that causes them to run.

For example:

tasks.register("customTask") {
    dependsOn(":firstA:build", ":thirdA:build")