Slackbot
04/28/2023, 10:21 PMNicholas Doglio
04/28/2023, 10:22 PMThe 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()
?Chris Lee
04/28/2023, 10:23 PMNicholas Doglio
04/28/2023, 10:23 PMMykola Markov
04/28/2023, 11:11 PMtasks.register('projectVersion') {
doLast {
println "${project.version}"
}
}
to get project version we can call:
./gradlew projectVersion
Thomas Broyer
04/28/2023, 11:50 PMNicholas Doglio
04/29/2023, 1:49 AMNicholas Doglio
04/29/2023, 1:50 AMtoString
instead of just exposing the computed value? I can't seem to find anything around the advantages in my googling 🤔Chris Lee
04/29/2023, 7:49 AMtoString
allows you to defer the computation until the first use of the version.