4

I suppose gradle uses build scripts that can be programmed as per the requirements. Is it a declarative or imperative build tool then?

Vivek
  • 11,938
  • 19
  • 92
  • 127

1 Answers1

2

In fact, it's both. Gradle does not force you to be declarative like Maven or imperative like Ant, it can and it will probably be both for you.

According to Gradle's documentation :

Well-designed build scripts consist mostly of declarative configuration rather than imperative logic

As far as you can, use the Gradle's DSL and only use custom conditional blocks when you need to handle specific cases or custom actions.

ToYonos
  • 16,469
  • 2
  • 54
  • 70
  • 4
    Isn't Gradle technically purely imperative? Since it is a Groovy/Kotlin DSL, and Groovy/Kotlin is imperative, definitely not declarative. For example, Gradle code such as `repositories { jcenter(); mavenCentral() }` definitely *looks* and *feels* declarative, but that is just Groovy syntactic sugar for the method call `project.repositories({ jcenter(); mavenCentral() })`, which itself is directly equivalent to `RepositoryHandler rh = project.getRepositories(); rh.jcenter(); rh.mavenCentral()` (and in that specific order). – Anakhand Jan 02 '20 at 23:28