There's a problem with the convention that's configured for the mainClass property of bootJar and bootWar which means that it can't be read unless resolveMainClassName has already executed. At the moment, it fails like this:
* What went wrong:
Execution failed for task ':reproducer'.
> Failed to query the value of task ':bootJar' property 'mainClass'.
> Querying the mapped value of task ':resolveMainClassName' property 'outputFile' before task ':resolveMainClassName' has completed is not supported
Where the reproducer task is defined like this:
tasks.register("reproducer") {
def mainClass = tasks.named("bootJar").flatMap { it.mainClass }
doFirst {
println mainClass.get()
}
}
If things were wired up properly, reading the property's value would cause resolveMainClassName to execute if needed.
Comment From: wilkinsona
I was mistaken. Things are wired up properly as Gradle knows that it's a mapped property of the :resolveMainClassName task yet it doesn't automatically invoke resolveMainClassName before reproducer. This has to be worked around in the task that's querying the mainClass:
tasks.register("reproducer") {
dependsOn tasks.named("resolveMainClassName")
def mainClass = tasks.named("bootJar").flatMap { it.mainClass }
doFirst {
println mainClass.get()
}
}