diff --git a/build-tools/automation/yaml-templates/build-linux-steps.yaml b/build-tools/automation/yaml-templates/build-linux-steps.yaml index bdc9c6a65c0..448999622c0 100644 --- a/build-tools/automation/yaml-templates/build-linux-steps.yaml +++ b/build-tools/automation/yaml-templates/build-linux-steps.yaml @@ -27,6 +27,10 @@ steps: - template: /build-tools/automation/yaml-templates/log-disk-space.yaml +- template: /build-tools/automation/yaml-templates/cache-gradle.yaml + parameters: + xaSourcePath: ${{ parameters.xaSourcePath }} + - script: make jenkins PREPARE_CI=1 PREPARE_AUTOPROVISION=1 CONFIGURATION=$(XA.Build.Configuration) MSBUILD_ARGS='${{ parameters.makeMSBuildArgs }}' workingDirectory: ${{ parameters.xaSourcePath }} displayName: make jenkins diff --git a/build-tools/automation/yaml-templates/build-macos-steps.yaml b/build-tools/automation/yaml-templates/build-macos-steps.yaml index f9d207ec43f..5c0af7a6ffe 100644 --- a/build-tools/automation/yaml-templates/build-macos-steps.yaml +++ b/build-tools/automation/yaml-templates/build-macos-steps.yaml @@ -30,6 +30,10 @@ steps: - template: /build-tools/automation/yaml-templates/log-disk-space.yaml +- template: /build-tools/automation/yaml-templates/cache-gradle.yaml + parameters: + xaSourcePath: ${{ parameters.xaSourcePath }} + # Prepare and Build everything - script: make jenkins CONFIGURATION=$(XA.Build.Configuration) PREPARE_CI=1 PREPARE_AUTOPROVISION=1 MSBUILD_ARGS='${{ parameters.makeMSBuildArgs }}' workingDirectory: ${{ parameters.xaSourcePath }} diff --git a/build-tools/automation/yaml-templates/build-windows-steps.yaml b/build-tools/automation/yaml-templates/build-windows-steps.yaml index 2227e7ae8fc..c8651b02d76 100644 --- a/build-tools/automation/yaml-templates/build-windows-steps.yaml +++ b/build-tools/automation/yaml-templates/build-windows-steps.yaml @@ -23,6 +23,10 @@ steps: parameters: remove_dotnet: true +- template: /build-tools/automation/yaml-templates/cache-gradle.yaml + parameters: + xaSourcePath: $(System.DefaultWorkingDirectory) + - task: DotNetCoreCLI@2 displayName: Prepare Solution inputs: diff --git a/build-tools/automation/yaml-templates/cache-gradle.yaml b/build-tools/automation/yaml-templates/cache-gradle.yaml new file mode 100644 index 00000000000..289f2d307b2 --- /dev/null +++ b/build-tools/automation/yaml-templates/cache-gradle.yaml @@ -0,0 +1,21 @@ +# Shared Gradle dependency cache template +# Caches Gradle downloads between pipeline runs to avoid transient network +# failures when resolving Maven dependencies. +# +# See: https://learn.microsoft.com/azure/devops/pipelines/release/caching + +parameters: + xaSourcePath: $(System.DefaultWorkingDirectory)/android + +steps: +- script: git submodule status --cached external/Java.Interop > $(Agent.TempDirectory)/java-interop-submodule-hash.txt + workingDirectory: ${{ parameters.xaSourcePath }} + displayName: get Java.Interop submodule hash + +- task: Cache@2 + displayName: cache Gradle downloads + inputs: + key: '"gradle" | "v1" | "$(Agent.OS)" | ${{ parameters.xaSourcePath }}/build-tools/gradle/gradle/wrapper/gradle-wrapper.properties | ${{ parameters.xaSourcePath }}/src/**/build.gradle | $(Agent.TempDirectory)/java-interop-submodule-hash.txt' + restoreKeys: | + "gradle" | "v1" | "$(Agent.OS)" + path: $(HOME)/.gradle/caches