How to run task build or test some subprojects in custom task in build.gradle.kts? For example, I have submodules: firstA, secondA, thirdA. I want to run build in custom task for only firstA and thirdA.
settings.gradle.kts
rootProject.name = "myProject"
include(
"modules:firstA",
"modules:secondA",
"modules:thirdA"
)
Go to Run -> Edit Configurations -> Click on + to add a new configuration -> Select Gradle from the list that comes up. Finally select the app, and type in the task that you want to run. Android Studio will even provide autocomplete for the same.
Register a gradle task in the root project, then iterate over the subprojects and filter them by their name, and then depending the task on the test tasks of the subprojects.
Example:
tasks.register("mytest") {
dependsOn(subprojects.mapNotNull {
when (it.name) {
"firstA", "thirdA" -> it.tasks.findByName("test")
else -> null
}
})
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With