I’m grokking Gradle API and found project,convention
accessor. After:
convention.plugins.forEach {name, plug ->
logger.lifecycle("name: {}, plug: {}", name, plug)
}
I wrote:
convention.java.sourceCompatibility = JavaVersion.VERSION_11
logger.lifecycle("conv: {}", convention.getByName("java").sourceCompatibility)
java.sourceCompatibility = JavaVersion.VERSION_1_10
logger.lifecycle("conv: {}", convention.getByName("java").sourceCompatibility)
sourceCompatibility = JavaVersion.VERSION_1_9
logger.lifecycle("conv: {}", convention.getByName("java").sourceCompatibility)
with output:
conv: 11
conv: 1.10
conv: 1.9
What is the proper way to use conventions? Which one:
convention.java.sourceCompatibility = JavaVersion.VERSION_11
java.sourceCompatibility = JavaVersion.VERSION_11
sourceCompatibility = JavaVersion.VERSION_11
Should Gradle users know about project.getConvention()
?