ajoberstar / reckon

Infer a project's version from your Git repository.
Apache License 2.0
185 stars 28 forks source link

Optional creation of version resource #107

Closed sschuberth closed 5 years ago

sschuberth commented 5 years ago

How about some setting that would make reckon create a simple text file or properties file as a resource so applications could also easily use the reckoned version at runtime by reading that resource?

ajoberstar commented 5 years ago

Gradle makes this easy enough that I'd rather not put it in the plugin. Something like this should work.

task writeVersion(type: WriteProperties) {
  outputFile = project.layout.buildDirectory().file('version.properties')
  property 'version', { project.version }
}
processResources.from writeVersion
sschuberth commented 5 years ago

Agreed. This initially came to my mind as (due to a lack of examples) I wasn't aware that reckon actually does set the Gradle-native project.version property. I was searching for a reckon-specific property that I could write to a file and did not find one. Later, I found that I could call reckon.reckonVersion(), but of course using a property that is only evaluated once is much better.

Long story short, now that I'm aware that the project.version property can be used, I totally agree it's better to leave to the user what to do with that version property, and whether to write it to a file or not.