DEV Community

Discussion on: Tony's rules for Gradle plugin authors

Collapse
 
autonomousapps profile image
Tony Robalik

You should set things like isCanBeConsumed = true when creating the configuration, so the question of whether to call get() on that Provider is moot.

That said, it's important to understand that, specifically with Configurations, they really aren't ever lazy. This is a case where the "rule" becomes a "guideline." Configurations are always eager, so it's basically OK to use create() and all {} for this type of container.

Also totally missing how map and flatMap differ.

flatMap is when you're mapping over another Provider, so it just "flattens" the provider chain.

I have a spot where I need to see if a configuration exists already, and if not create it.

You can use maybeCreate() for this use-case.

Collapse
 
prenagha profile image
Padraic Renaghan

Thanks for the follow-up