I am trying to make a plugin aiming to cnfigure a project more simply. Therefore, I need to obtain a plugin’s version for setting.gradle, and use this version to configure other settings.
something like following in setting.gradle.kts
plugins {
id("com.xxxx") version "1.1.0"
}
then I want to obtain this “1.1.0”, and apply it to other place which will use this version.
The easiest and safest way is to generate the version into a file at build time that you then can read at execution time.
For example a properties file with a placeholder that you fill using expand on the processResources task and maybe an accompanying class that reads and interprets the file.
Oh, I see. Create a resource file before compile task, then using IO to read data from it. Classic! Though, I thought there may be some official ways to solve this, like org.springframework.boot did.