# Evolving the Gradle API to reduce configuration time

DevFeed: [Evolving the Gradle API to reduce configuration time](<https://devfeed.tech/articles/evolving-the-gradle-api-to-reduce-configuration-time-24683.md>)

Original publisher: [Read original article](<https://blog.gradle.org/preview-avoiding-task-configuration-time>)

Author: Sterling Greene

Published: 2018-07-09T04:00:00Z

Content type: release

Language: en

Sources: [The Gradle Blog](<https://devfeed.tech/sources/the-gradle-blog.md>)

Topics: [Gradle](<https://devfeed.tech/topics/gradle.md>), [configuration](<https://devfeed.tech/topics/configuration.md>), [API](<https://devfeed.tech/topics/api.md>), [Code](<https://devfeed.tech/topics/code.md>)

Tags: [build](<https://devfeed.tech/tags/build.md>), [code](<https://devfeed.tech/tags/code.md>), [configuration](<https://devfeed.tech/tags/configuration.md>), [feature](<https://devfeed.tech/tags/feature.md>), [gradle](<https://devfeed.tech/tags/gradle.md>), [preview](<https://devfeed.tech/tags/preview.md>)

## AI overview

Gradle introduces a preview Tasks API for build scripts and plugins. The API can delay or avoid configuring tasks that will not run, potentially reducing build configuration time, and is intended to eventually replace the existing API.

## Source excerpt

This post introduces a new API for declaring and configuring Gradle Tasks in build scripts and plugins. We intend for this new API to eventually replace the existing API because it allows Gradle to avoid configuring unnecessary build logic. Use of the new API will become the default recommendation soon, but the existing API will go through our usual deprecation process over several major releases. We are asking early adopters to try out the new Gradle Tasks API to iron out any issues and gather feedback. We've created a new user manual chapter to give a quick introduction to the feature and explains some guidelines for migrating your build to use the new API. We welcome any feedback you may have about this API. You can leave feedback on this Gradle issue. Preview of new Gradle Tasks API in Gradle 4.9 One of the major differences between the existing and new Gradle Tasks API is whether or not Gradle spends the time to create Task instances and run configuration code. The new API allows Gradle to delay or completely avoid configuring tasks that will never be executed in a build. For example, when compiling code, Gradle does not need to configure tasks that run tests. The time spent creating and configuring tasks that are never used is a contributor to overall Gradle configuration time. Configuration time affects every build, so making it faster is good for everyone. The existing API also eagerly creates Task instances as soon as possible. This can make the ordering of plugins more fragile. The new API is intended to make the relationship between a Task and something that needs it more explicit by passing around a Provider for a Task. We have also seen in some builds that configuring particular tasks are very expensive because they reach out to webservices, they run git status or they need to parse something. If those tasks are rarely used, every build is paying the price to configure that task. The new API allows plugin or build authors to declare the expensive tasks