Slackbot
09/23/2023, 3:59 AMFathony Teguh Irawan
09/23/2023, 4:00 AMafterEvaluate but I notice that the extension hasn't been updated by user config if it is outside the afterEvaluate.Philip W
09/23/2023, 8:23 AMVampire
09/25/2023, 11:06 AMafterEvaluate is almost always the wrong thing to do. In 98.7 % of the cases it is just symptom treatment like calling SwingUtilities.invokeLater or Platform.runLater to "fix" a GUI problem. It usually just shifts the problem to a later time where it is much harder to reproduce, much harder to debug, and much harder to fix. The main thing afterEvaluate does is introducing timing problems, ordering problems, and race conditions. That's why the Property / Provider APIs were introduced, so that properties can lazily be wired together without the need to do delayed evaluation to give someone the chance to configure the value before you read it. What happens for example if someone sets the value in an afterEvaluate that is evaluated after your afterEvaluate? ...
In your case there are practically two solutions that spring into mind.
1. Don't make applyDeps a property, but a function, then downstream can call that function and you can immediately add the dependency
2. Adding a provider similar to what Philip suggested: dependencies.addProvider("implementation", extension.applyDeps.map *{* if (it) "other.deps:module:1.0.0" else null *}*)Fathony Teguh Irawan
09/26/2023, 4:20 AM