2

I am using Travis CI with is connected to my github account. The builds are always successful but they take a long time as travis will keep downloading the same dependencies for each build. i.e. Downloading normally takes over 5 minutes, but building only takes less than a minute. Is there any configuration on Travis to avoid this downloading of dependencies?

Below is a snippet of what is being downloaded each time:

Starting a Gradle Daemon (subsequent builds will be faster)

Download https://maven.google.com/com/android/tools/build/gradle/3.0.0-alpha2/gradle-3.0.0-alpha2.pom
Download https://jcenter.bintray.com/com/dicedmelon/gradle/jacoco-android/0.1.1/jacoco-android-0.1.1.pom
Download https://maven.google.com/com/android/tools/build/gradle-core/3.0.0-alpha2/gradle-core-3.0.0-alpha2.pom
Download https://jcenter.bintray.com/org/codehaus/groovy/groovy-all/2.4.4/groovy-all-2.4.4.pom

My travis.yml file:

language: android

jdk: oraclejdk8

env:
  global:
    - ANDROID_TARGET=android-25
    - ANDROID_ABI=armeabi-v7a

android:
  components:
  - tools
  - platform-tools
  - build-tools-25.0.2
  - android-25
  - extra-android-m2repository
  - sys-img-${ANDROID_ABI}-${ANDROID_TARGET}

licenses:
  - android-sdk-license-.+
  - '.+'

script:
    - ./gradlew --daemon build jacocoTestReport

after_success:
    - bash <(curl -s https://codecov.io/bash)

Many thanks for any suggestions,

ant2009
  • 27,094
  • 154
  • 411
  • 609
  • 1
    Part of the point of a CI is to do a clean build each time, to ensure that the software can build. Keeping dependencies around kind of defeats the purpose. – Gabe Sechan May 29 '17 at 17:33
  • 2
    [Redownloading dependencies](https://stackoverflow.com/q/13565082/1009132) `./gradlew build --refresh-dependencies` is not the same than to do a [clean build](https://stackoverflow.com/q/29028748/1009132) `./gradlew clean build`. – albodelu May 29 '17 at 20:32

1 Answers1

1

You can use the cache to avoid these downloads, but it's not recommended for Android SDK.

It's documented here for Gradle dependencies:

A peculiarity of dependency caching in Gradle means that to avoid uploading the cache after every build you need to add the following lines to your .travis.yml:

before_cache:
  - rm -f  $HOME/.gradle/caches/modules-2/modules-2.lock
  - rm -fr $HOME/.gradle/caches/*/plugin-resolution/
cache:
  directories:
    - $HOME/.gradle/caches/
    - $HOME/.gradle/wrapper/

You can add other directories to the cache but large files are not recommended.

Jake Lee
  • 7,549
  • 8
  • 45
  • 86
albodelu
  • 7,931
  • 7
  • 41
  • 84