Sebastian Schuberth
05/16/2025, 3:19 PM@JvmInline
value class ProjectVersion(val version: String)
objects.property<ProjectVersion>().set(ProjectVersion("oink"))
println(objects.property<ProjectVersion>().get().version)
Vampire
05/16/2025, 3:21 PMfoo
, and set its value to oink
.
Then you create a new property instance, let's call it bar
, and query its value.
Why do you expect bar
to have the value you have set on foo
?Sebastian Schuberth
05/16/2025, 3:22 PMVampire
05/16/2025, 3:22 PMval foo = "bar"
val bar = null
assert bar == foo
🙂Sebastian Schuberth
05/16/2025, 3:23 PMSebastian Schuberth
05/16/2025, 3:23 PMVampire
05/16/2025, 3:32 PM"bar"
assert null == "bar"
😄
objects.property<ProjectVersion>()
gives you a property instance.
You then set a value.
And then you discard it.
You probably meant
val foo = objects.property<ProjectVersion>().set(ProjectVersion("oink"))
println(foo.get().version)
(Besides that you of course should never call get()
at configuration time, because that introduces the same bad race-conditions afterEvaluate
gives you.Sebastian Schuberth
05/16/2025, 3:34 PMval foo
in our example. Is there no way to gets it's value from objects
after its creation?Vampire
05/16/2025, 3:34 PMobjects
is just a factory that creates a new property instance for youVampire
05/16/2025, 3:34 PMVampire
05/16/2025, 3:35 PMSebastian Schuberth
05/16/2025, 3:35 PMVampire
05/16/2025, 3:35 PMSebastian Schuberth
05/16/2025, 3:36 PMVampire
05/16/2025, 3:37 PMregister
callVampire
05/16/2025, 3:37 PMSebastian Schuberth
05/16/2025, 3:38 PMVampire
05/16/2025, 3:43 PMVampire
05/16/2025, 3:43 PMSebastian Schuberth
05/16/2025, 3:45 PMVampire
05/16/2025, 3:47 PMChris
05/16/2025, 3:50 PMSebastian Schuberth
05/16/2025, 3:50 PMSebastian Schuberth
05/16/2025, 3:51 PMVampire
05/16/2025, 3:51 PMChris
05/16/2025, 3:51 PMVampire
05/16/2025, 3:52 PMVampire
05/16/2025, 3:52 PMSebastian Schuberth
05/16/2025, 3:55 PMSebastian Schuberth
05/16/2025, 3:55 PM