How can a specify the Gradle wrapper download loca

2019-07-04 06:49发布

问题:

We moved our project to gradle and we have continuous build on Jenkins. We use the gradle wrapper and the Jenkings gradle plugin.

I recognized by reviewing the console output that gradle will be downloaded on each build:

    11:24:42 Downloading http://services.gradle.org/distributions/gradle-1.5-bin.zip
    11:24:48 ........................................................
    11:24:49 Unzipping /home/workspace/our_build/wrapper/dists/gradle-1.5-bin/9si5v6u7tk37kj5dlsrdcm595/gradle-1.5-bin.zip 
          to /home/workspace/our_build/wrapper/dists/gradle-1.5-bin/9si5v6u7tk37kj5dlsrdcm595

I think the reason is because the accurev plugin will purge always the whole workspace for each run (cannot be disabled).

Is it possible to configure the gradle download location? Is it safe to use a shared location for all jobs? Or is it better to have a location per job?

回答1:

The Wrapper task has several properties allowing its customization. You can specify an alternate URL to download it (distributionUrl). You can also leave the URL as is, but specify where the wrapper must be stored (distributionBase), which would allows storing it outside of the directory which is cleaned up every time by your accurev plugin.

I don't see why it wouldn't be safe to use a shared location. This is what is done by default, since the wrapper is stored in the gradle user home directory.