This message was deleted.
# community-support
s
This message was deleted.
n
@Chris Lee Sorry moving thread here since i realized i posted in the wrong channel 🙃
The closest you can get is to provide some object representing the version on doing your computation (lazily, once) in toString().
Could you expand on this? Essentially have a POJO that contains all the info and do the computation in
toString()
?
c
That’s correct. It isn’t pretty.
👍 1
n
Thank you, I'll play around with that 🫡
👍 1
m
@Nicholas Doglio we are using custom plugin which used internally nebula plugin to calculate version based on tags, available release branches and branch where you are. we are calling it like:
Copy code
tasks.register('projectVersion') {
	doLast {
		println "${project.version}"
	}
}
to get project version we can call:
Copy code
./gradlew projectVersion
t
n
@Thomas Broyer thats very close to what I ended up with!
One thing I'm a little confused about is why I'm overriding
toString
instead of just exposing the computed value? I can't seem to find anything around the advantages in my googling 🤔
c
using
toString
allows you to defer the computation until the first use of the version.
thank you 1
til 1