This message was deleted.
# plugin-development
s
This message was deleted.
f
To put more context, I tried to put the add dependencies stuff outside the
afterEvaluate
but I notice that the extension hasn't been updated by user config if it is outside the
afterEvaluate
.
p
Map the applyDep provider to a Provider<Dependencies> and add this provider to your configuration.
🙏 1
v
Using
afterEvaluate
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 *}*)
👀 1
f
Hi, Thanks Philip, Vampire, for the detailed response. Really appreciated! 🙇
👌 1