# This Source Code Form is subject to the terms of the Mozilla Public
# License, v. 2.0. If a copy of the MPL was not distributed with this
# file, You can obtain one at http://mozilla.org/MPL/2.0/.
---
loader: android_taskgraph.loader.build_config:components_loader

transforms:
    - android_taskgraph.transforms.build_components:transforms
    - android_taskgraph.transforms.gradle_optimization:transforms
    - taskgraph.transforms.job:transforms
    - taskgraph.transforms.task:transforms

not-for-components:
    - samples-browser   # Their configs are too different, so they're handled in a specific kind

kind-dependencies:
    - toolchain
    - external-gradle-dependencies

task-defaults:
    artifact-template:
        type: file
        name: public/build/{artifact_file_name}
        path: '/builds/worker/checkouts/vcs/android-components/{component_path}/build/maven/org/mozilla/components/{component}/{version}/{artifact_file_name}'
    tests-artifact-template:
        type: directory
        name: public/reports/tests
        path: '/builds/worker/checkouts/vcs/android-components/{component_path}/build/reports/tests'
    lint-artifact-template:
        type: file
        name: public/reports/lint-results-release.html
        path: '/builds/worker/checkouts/vcs/android-components/{component_path}/build/reports/lint-results-release.html'
    text-artifact-template:
        type: file
        name: public/github/customCheckRunText.md
        path: '/builds/worker/github/customCheckRunText.md'
    jacoco-coverage-template:
        type: directory
        name: public/reports/jacoco
        path: '/builds/worker/checkouts/vcs/android-components/{component_path}/build/reports/jacoco'
    attributes:
        code-review:
            by-build-type:
                release: false
                beta: false
                nightly: false
                default: true
    description: Execute Gradle tasks for component "{component}"
    expose-artifacts:
        by-build-type:
            release: true
            beta: true
            nightly: true
            default: false
    fetches:
        toolchain:
            - android-sdk-linux
        external-gradle-dependencies:
            - external-gradle-dependencies.tar.xz
    include-coverage:
        by-build-type:
            release: false
            beta: false
            nightly: false
            default: true
    run:
        gradlew:
            by-build-type:
                release:
                    - ':{component}:assembleRelease'
                    - ':{component}:testRelease'
                    - ':{component}:lintRelease'
                    - ':{component}:publish'
                beta:
                    # /!\ Beta builds are considered Release in gradle
                    - ':{component}:assembleRelease'
                    - ':{component}:testRelease'
                    - ':{component}:lintRelease'
                    - ':{component}:publish'
                nightly:
                    - '-PnightlyVersion={nightlyVersion}'
                    - ':{component}:assembleRelease'
                    - ':{component}:testRelease'
                    - ':{component}:lintRelease'
                    - ':{component}:publish'
                default:
                    by-component:
                        # No lintRelease on this task, gradle task isn't defined
                        tooling-lint:
                            - ':{component}:assemble'
                            - ':{component}:assembleAndroidTest'
                            - ':{component}:test'
                            - ':{component}:lint'
                            - 'githubBuildDetails'
                        # No testRelease on this task, gradle task isn't defined
                        tooling-detekt:
                            - ':{component}:assemble'
                            - ':{component}:assembleAndroidTest'
                            - ':{component}:test'
                            - ':{component}:lintRelease'
                            - 'githubBuildDetails'
                        default:
                            - ':{component}:assemble'
                            - ':{component}:assembleAndroidTest'
                            - ':{component}:testRelease'
                            - ':{component}:lintRelease'
                            - 'githubBuildDetails'
        pre-gradlew:
            - ["cd", "android-components"]
        using: gradlew
        use-caches: false
    run-on-tasks-for:
        by-build-type:
            release: []
            beta: []
            nightly: []
            default:
                - github-pull-request
                - github-pull-request-untrusted
                - github-push
    shipping-phase:
        by-build-type:
            (nightly|beta|release): promote
            default: build
    treeherder:
        kind: build
        symbol:
            by-build-type:
                release: '{treeherder_group}(BR)'
                beta: '{treeherder_group}(BB)'
                nightly: '{treeherder_group}(BN)'
                default: '{treeherder_group}(B)'
        platform: AC-android-all/opt
        tier: 1
    worker-type: b-android-large
    worker:
        chain-of-trust: true
        docker-image: {in-tree: base}
        max-run-time: 1200
