我正在使用 Travis CI 并连接到我的 github 帐户。构建总是成功的,但它们需要很长时间,因为 travis 将继续为每个构建下载相同的依赖项。即下载通常需要 5 分钟以上,但构建只需要不到一分钟。 Travis 上是否有任何配置可以避免下载依赖项?
以下是每次下载内容的 fragment :
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
我的 travis.yml 文件:
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)
非常感谢您的任何建议,
最佳答案
您可以使用 the cache为了避免这些下载,但是 it's not recommended适用于 Android SDK。
已记录 here对于 Gradle 依赖项:
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/
您可以将其他目录添加到缓存中,但 large files不推荐。
关于android - 构建 Android 总是为每个构建下载依赖项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44247795/