我们正在尝试缓存androidbuild作业的所有gradle依赖项。
这是当前失败的方法:

- restore_cache:
    key: android-build-{{ checksum "android/build.gradle" }}-{{ checksum  "android/app/build.gradle" }}
- save_cache:
    paths:
      - ~/.gradle
    key: android-build-{{ checksum "android/build.gradle" }}-{{ checksum  "android/app/build.gradle" }}

最佳答案

这里有一个android配置示例by Circle CI themselves here以及属性的逐步演练。

version: 2
jobs:
  build:
    working_directory: ~/code
    docker:
      - image: circleci/android:api-25-alpha
    environment:
      JVM_OPTS: -Xmx3200m
    steps:
      - checkout
      - restore_cache:
          key: jars-{{ checksum "build.gradle" }}-{{ checksum  "app/build.gradle" }}
#      - run:
#         name: Chmod permissions #if permission for Gradlew Dependencies fail, use this.
#         command: sudo chmod +x ./gradlew
      - run:
          name: Download Dependencies
          command: ./gradlew androidDependencies
      - save_cache:
          paths:
            - ~/.gradle
          key: jars-{{ checksum "build.gradle" }}-{{ checksum  "app/build.gradle" }}
      - run:
          name: Run Tests
          command: ./gradlew lint test
      - store_artifacts:
          path: app/build/reports
          destination: reports
      - store_test_results:
          path: app/build/test-results

值得注意的是,由于子模块的原因,我们在使用缓存时遇到了一些问题,但是上面的内容应该适用于更简单的存储库。

关于android - 如何在CircleCI 2.0上处理Gradle缓存?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/49426896/

10-11 22:24
查看更多