Hello!
I am new to CI. I am trying to build an ordinary android application from github.
My idea to build applications like if they are in my local folder. I mean i want to cache entire project (including not only dependencies, but done Gradle tasks too)
If i run project it with Cirlce CI i get:
Task :app:preBuild
Task :app:preDebugBuild
Task :app:compileDebugAidl
Task :app:compileDebugRenderscript
Task :app:generateDebugBuildConfig
Task :app:checkDebugAarMetadata
Task :app:generateDebugResValues
Task :app:generateDebugResources
Task :app:createDebugCompatibleScreenManifests
Task :app:extractDeepLinksDebug
Task :app:processDebugMainManifest
Task :app:mergeDebugResources
Task :app:processDebugManifest
Task :app:javaPreCompileDebug
…etc
it takes about 1 min.
it works cool. thank you. i know that CI runs builds clear, so all tasks are in this list. But if i run build again, I expect CI to cache all previous steps to recieve like this :
Task :app:preBuild UP-TO-DATE
Task :app:preDebugBuild UP-TO-DATE
Task :app:compileDebugAidl UP-TO-DATE
Task :app:compileDebugRenderscript UP-TO-DATE
Task :app:generateDebugBuildConfig UP-TO-DATE
Task :app:checkDebugAarMetadata UP-TO-DATE
Task :app:generateDebugResValues UP-TO-DATE
Task :app:generateDebugResources UP-TO-DATE
Task :app:createDebugCompatibleScreenManifests UP-TO-DATE
Task :app:extractDeepLinksDebug UP-TO-DATE
Task :app:processDebugMainManifest UP-TO-DATE
Task :app:mergeDebugResources UP-TO-DATE
Task :app:processDebugManifest UP-TO-DATE
Task :app:javaPreCompileDebug UP-TO-DATE
…etc
I expect to recive builds that take few seconds.
here is my config
version: 2.1
orbs:
android: circleci/android@0.2.1
jobs:
build:
executor: android/android
working_directory: ~/code
environment:
JVM_OPTS: -Xmx3200m
GRADLE_OPTS: '-Dorg.gradle.jvmargs="-Xmx1024m" -Dkotlin.compiler.execution.strategy=in-process'
steps:
- checkout
- restore_cache:
key: jars-{{ checksum "build.gradle" }}-{{ checksum "app/build.gradle" }}
- run:
command: chmod +x ./gradlew
- restore_cache:
key: myBuildFolder
- run:
name: Download Dependencies
command: ./gradlew androidDependencies --build-cache -PpreDexEnable=false --no-daemon --max-workers=2
- save_cache:
paths:
- ~/.gradle
key: jars-{{ checksum "build.gradle" }}-{{ checksum "app/build.gradle" }}
- run:
command: ./gradlew :app:assembleDebug --build-cache -PpreDexEnable=false --no-daemon --max-workers=2
- save_cache:
key: myBuildFolder
paths:
- /home/circleci/code/app/build
- run:
command: |
mkdir -p ~/artifacts
cp app/build/outputs/apk/debug/app-debug.apk ~/artifacts
- store_artifacts:
path: ~/artifacts
Here I try to save app/build folder for future gradle runs with save_cache: key: myBuildFolder but it doesn’t seem to work at all: every build constantly runs all steps from the very begining.
So, could you please to help me to fix my config to get cached builds?
Thanks!!!