Quantcast
Channel: Gradle Forums - Latest posts
Viewing all articles
Browse latest Browse all 19854

Task 'enabled' vs 'onlyIf'

$
0
0

The enabled property is more eager configuration as you’re setting a boolean. If the property changes later, the boolean will not change. It makes sense to use it if the state is always the same. For example, the distribution plugin creates a zip and tar archive. If you only want the tar in any case, you can disable the zip.

The onlyIf is lazier and executed immediately before the execution of the task. This means that if you’re dependent on properties that might update as your build executes, this is an easier way to evaluate them at the appropriate time. I would also prefer onlyIf for more expensive logic as it only will execute when needed as opposed to at configuration time for any task in the build.


Viewing all articles
Browse latest Browse all 19854

Trending Articles