rnett
07/02/2025, 12:03 AMKotlinBaseExtension.sourceSets.configureEach { ... }
. However, the source sets appear to be configured/resolved before the build script is ran, meaning setting properties in my extension isn't reflected in the configuration since the added configuration runs first. Is this known or expected behaviour? I can probably slap an afterEvaluate
on it but I'd prefer to avoid that if possible since it's a whole can of worms.rnett
07/02/2025, 12:07 AMimplementation(myProperty.map{ ifIit) REAL_DEPENDENCY else null })
but this still seems pretty ugly and I'm surprised it's necessaryVampire
07/02/2025, 7:39 AMVampire
07/02/2025, 7:42 AMafterEvaluates
is almost never the way to go. The main benefits of using it are timing problems, ordering problems, and race conditions as you seem to know. 🙂
If you would not have been able to use a Provider
to add the dependency, for example because you wanted to register a task based on the property, there would be other tactics, like always registering the task but skipping it in onlyIf { ... }
checking the property, or not using a property in the extension, but instead have a function which your user calls and which then uses the argument and does the necessary logic in its body.