Kelvin Chung
03/01/2024, 9:10 PMval container: NamedDomainObjectContainer<MyType>
container.configureEach { ... } // 1
container.all { ... } // 2
container.register("myItem") { ... } // 3
Is there an guaranteed order in which a new MyType is run? I'm experiencing a bug where people are expecting the order to be 1,3,2, but it isn't acting that way. (The reason for the order is because block 2 contains a task registration, which requires something set in block 3)Vampire
03/01/2024, 10:31 PMVampire
03/01/2024, 10:31 PMVampire
03/01/2024, 10:32 PMregister creates the new instance, then runs all already registered configuration actions against it and only after that the configuration action given to the register callVampire
03/01/2024, 10:32 PMregister does not actually create the instance, it just registers its creation with a configuration actionVampire
03/01/2024, 10:33 PMKelvin Chung
03/01/2024, 10:38 PMget() on the value set in block 3. eg.
interface MyType {
val myProperty: Property<String>
}
container.configureEach { // 1
myProperty.convention(...)
}
container.all { // 2
tasks.register("$name${myProperty.get()}")
}
container.register("myItem") { // 3
myProperty.set(...)
}
Because 2 runs before 3, the tasks have names that are not what is expected; people might be under the impression that 3 runs before 2.Vampire
03/01/2024, 10:38 PMall and confiugreEach it works like expected.Vampire
03/01/2024, 10:39 PMVampire
03/01/2024, 10:40 PMVampire
03/01/2024, 10:41 PMconfiugreEach before, then a register and then a configureEach after, as soon as the task is realized, for example by an all or by executing the task in question when talking about a task container, the actions are executed in exactly that registered orderKelvin Chung
03/01/2024, 10:44 PMVampire
03/01/2024, 10:44 PMafterEvaluateVampire
03/01/2024, 10:45 PMKelvin Chung
03/01/2024, 10:46 PMMyType has both information and metadata about the tasks being registered. 2 would be "resolving the metadata".
Of course, 2 would, in theory, be available eagerly too.Vampire
03/01/2024, 10:52 PMKelvin Chung
03/01/2024, 10:56 PMKelvin Chung
03/01/2024, 10:57 PMVampire
03/01/2024, 11:06 PMVampire
03/01/2024, 11:09 PMMyType to the container instead of registering.
Or he could instead put the information into the name of the registered item.