Caleb Cushing
04/19/2024, 2:03 AMcheckstyleMain
is there an easy way to reverse that to just the source set name? it'd be convenient to reduce this code given feature variants and test suites
tasks.named<Checkstyle>("checkstyleMain") {
configFile = checkstyleConfig("main.xml")
}
Caleb Cushing
04/19/2024, 3:02 AMtasks.withType<Checkstyle>().configureEach {
this.name.substringAfter("checkstyle").replaceFirstChar { it.lowercase() }.let { filename ->
logger.quiet("checkstyleConfig: $filename")
configFile = checkstyleConfig("${filename}.xml")
}
}
Thomas Broyer
04/19/2024, 1:03 PMsourceSets.configureEach {
tasks.named<CheckStyle>(getTaskName("checkstyle", null)) {
// …
}
}
That being said, your approach is also used by code quality plugins: https://github.com/gradle/gradle/blob/057b55410a1b8cb3161ab9c7d4a8a34937f944ac/pla[…]dle/api/plugins/quality/internal/AbstractCodeQualityPlugin.java