Paul Verest
Paul Verest

Reputation: 63912

How to define Gradle version to use inside build.gradle?

Android new build system requires Gradle 1.10+ version. How to configure that inside build.gradle ?

I am aware that there is some wrapper configuration in other files, but I would like to make it more visible, as my goal is to prevent potential errors (time lost by team mates) in the future.

Compare to maven pom.xml

<prerequisites>
    <maven>3.0</maven>
</prerequisites>

ref Gradle version 1.8 is required. Current version is 1.6

Upvotes: 0

Views: 3096

Answers (3)

Opal
Opal

Reputation: 84786

Hmm.. You can configure the gradle version in a wrapper task

task wrapper(type: Wrapper) {
   gradleVersion = '1.4'
}

This assures You that (when using wrapper) all users will have the same version. There's no need for version checking, parsing and other..

Upvotes: 0

Paul Verest
Paul Verest

Reputation: 63912

Thank to the Peter who is likely working for GradleWare and is authoritative source.

Direct answer to the question is

assert gradle.gradleVersion >= "1.10" // android plugin 0.9 requires Gradle 1.10, 1.11

Updating Nodeclipse/Enide build.gradle template for classic Android project

Upvotes: 0

Peter Niederwieser
Peter Niederwieser

Reputation: 123910

You cannot configure the Gradle version in build.gradle. Instead, you'll have to configure the Gradle wrapper as explained in the link you gave. For additional information see the Gradle Wrapper chapter in the Gradle User Guide.

Configuring the Gradle Wrapper does not check that the correct Gradle version is used as in the POM snippet above, but it bootstraps the correct Gradle version for everyone that runs Gradle via the Gradle Wrapper (which includes the IDE), which is much more powerful. It would be easy to additionally check for the correct Gradle version in build.gradle (e.g. assert gradle.gradleVersion == "1.10"), but typically this shouldn't be necessary.

Upvotes: 2

Related Questions