android - 构建 Android 总是为每个构建下载依赖项

标签 android continuous-integration travis-ci

我正在使用 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/

相关文章:

java - OpenGL ES 3.0 中的粒子系统优化

java - MongoDB 给出 NullPointerException

github - 在 CLI 中观看 GH Actions 工作流程输出?

php - 如何在 codeception 中的 accespance.suite.yml 文件中定义 browserstack 的安全 key

node.js - npm登录travis后没有api key

android - ExpandableListView 中的 EditText - 打开软键盘时保持焦点

java - 已声明权限仍被拒绝

windows - 在 Bamboo 中,如何将组件库存储库 pull 到固定位置以避免每个分支重复?

continuous-integration - 使用 Teamcity REST API 创建 vcs root

c# - 添加对 Travis-CI 构建的缺失引用