Is there any callback in kotlin gradle plugin that...
# gradle
m
Is there any callback in kotlin gradle plugin that I can hook into to get the multiplatform targets a project defines? Context: in a plugin I need to register some tasks, one per target. so, I'm querying the targets like this when applying the plugin:
Copy code
project.extensions.getByType(KotlinMultiplatformExtension::class.java).targets
but the problem is only common/metadata target is available at this point and other targets are populated later on. I can get targets I want if I queried the targets in
afterEvaluate{ ... }
but I know that this a bad solution, so I'm asking if there is a better way. for example, Android gradle plugin provide something similar with
onVariants{ ... }
callback that one can hook into and read variants available for that android project.
a
Isn't
targets.configureEach {}
enough? The action will be called for all targets added before and after the call.
thank you color 1
m
You're right Albert it worked, I missed that. Thanks so much.