Gradle wrapper version management

Hi all,

Using gradle wrapper I am trying to compile source code using two different versions. I am facing a problem when I tried to compile source code with lower version of gradle after upgrading to higher version.

Something like below

Case #1
Step 1 -> Setup gradle wrapper using 1.12 version
Step 2 -> Compile source code

Case #2
Step 1-> Upgrade gradle wrapper to next level i.e., 2.0 by updating gradle-wrapper.properties file and wrapper task.
Step 2-> Compile source code

Case #3
Step 1-> Downgrade gradle wrapper to 1.12 version. No changes were made to gradle-wrapper.properties file.
So I have updated wrapper task to use 1.12 version.

But while compilation I had noticed that gradle wrapper is using the latest entry in gradle-wrapper.properties file i.e., 2.0 instead of 1.12 version specified in wrapper task.

Could someone clarify me whether gradle wrapper works as expected with lowers version after upgrading to higher versions without any changes to gradle-wrapper.properties file?

The wrapper task does not do anything to the build. It is only used to upgrade the wrapper. The version used for the build is determined only by the gradle-wrapper.properties.

To change the version, you can just use gradle wrapper --gradle-version 2.11 instead of having the wrapper task configuration in your build script.

Stefan,
Agreed with you on upgrading the wrapper with “gradle wrapper
–gradle-version 2.11” command.

After upgrading to 2.11 version is that not possible to work with earlier
or older version of gradle, by having both OLD and NEW (2.11) versions in
gradle-wrapper.properties file?

What is your use case, why would you switch back?

If you want to switch back, just run the command again with the old version.

gradle is internally invoked from ANT scripts. So executing gradle wrapper
command multiple times manually is not an option for me.

But can you confirm the following behavior of gradle wrapper,

gradle wrapper can be upgrade wrapper to latest versions by updating
gradle-wrapper.properties file but can’t tell wrapper to pick a specific
version from multiple versions available in properties file?

Indeed this is not possible. And I don’t see any use case for it.

Why would you want to call the same build with different versions?

Thanks Stefan for your time and patience.