tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

build.gradle (6611B)


      1 /* This Source Code Form is subject to the terms of the Mozilla Public
      2 * License, v. 2.0. If a copy of the MPL was not distributed with this
      3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
      4 
      5 buildscript {
      6    repositories {
      7        mavenLocal()
      8 
      9        gradle.mozconfig.substs.GRADLE_MAVEN_REPOSITORIES.each { repository ->
     10            maven {
     11                url = repository
     12                if (gradle.mozconfig.substs.ALLOW_INSECURE_GRADLE_REPOSITORIES) {
     13                    allowInsecureProtocol = true
     14                }
     15            }
     16        }
     17    }
     18 
     19    dependencies {
     20        classpath libs.mozilla.glean.gradle.plugin
     21    }
     22 }
     23 
     24 plugins {
     25    alias(libs.plugins.python.envs.plugin)
     26    id 'org.mozilla.nimbus-gradle-plugin'
     27 }
     28 
     29 apply plugin: 'com.android.library'
     30 apply plugin: 'kotlin-android'
     31 
     32 android {
     33    packaging {
     34        resources {
     35            excludes += ['META-INF/LICENSE.md', 'META-INF/LICENSE-notice.md']
     36        }
     37    }
     38 
     39    buildFeatures {
     40        buildConfig = true
     41    }
     42 
     43    namespace = 'mozilla.components.browser.engine.gecko'
     44 }
     45 
     46 // Set configuration for the Glean parser to extract metrics.yaml
     47 // file from AAR dependencies of this project rather than look
     48 // for it into the project directory.
     49 ext.allowMetricsFromAAR = true
     50 
     51 dependencies {
     52    if (findProject(":geckoview") != null) {
     53        api project(':geckoview')
     54    } else {
     55        api getGeckoViewDependency()
     56    }
     57 
     58    // We only compile against Glean. It's up to the app to add those dependencies
     59    // if it wants to collect GeckoView telemetry through the Glean SDK.
     60    compileOnly libs.mozilla.glean
     61 
     62    implementation project(':components:concept-engine')
     63    implementation project(':components:concept-fetch')
     64    implementation(project(':components:service-nimbus')) {
     65        exclude group: 'org.mozilla.telemetry', module: 'glean-native'
     66    }
     67    implementation project(':components:support-ktx')
     68    implementation project(':components:support-utils')
     69 
     70    implementation libs.androidx.core.ktx
     71    implementation libs.androidx.datastore.preferences
     72    implementation libs.androidx.lifecycle.livedata
     73    implementation libs.androidx.paging
     74    implementation libs.kotlinx.coroutines
     75 
     76    testImplementation project(':components:support-test')
     77    testImplementation project(':components:tooling-fetch-tests')
     78 
     79    testImplementation libs.androidx.test.core
     80    testImplementation libs.androidx.test.junit
     81    testImplementation libs.androidx.work.testing
     82    testImplementation libs.kotlinx.coroutines.test
     83    testImplementation libs.mockwebserver
     84    testImplementation libs.mozilla.glean
     85    testImplementation libs.robolectric
     86 
     87    androidTestImplementation project(':components:tooling-fetch-tests')
     88 
     89    androidTestImplementation libs.androidx.test.core
     90    androidTestImplementation libs.androidx.test.rules
     91    androidTestImplementation libs.androidx.test.runner
     92 }
     93 
     94 ext {
     95    gleanNamespace = "mozilla.telemetry.glean"
     96    gleanPythonEnvDir = gradle.mozconfig.substs.GRADLE_GLEAN_PARSER_VENV
     97 }
     98 apply plugin: "org.mozilla.telemetry.glean-gradle-plugin"
     99 apply from: '../../../common-config.gradle'
    100 apply from: '../../../publish.gradle'
    101 nimbus {
    102    // The path to the Nimbus feature manifest file
    103    manifestFile = "geckoview.fml.yaml"
    104 
    105    channels = [
    106            debug: "debug",
    107            release: "release",
    108    ]
    109 
    110    // This is an optional value, and updates the plugin to use a copy of application
    111    // services. The path should be relative to the root project directory.
    112    // *NOTE*: This example will not work for all projects, but should work for Fenix, Focus, and Android Components
    113    applicationServicesDir = gradle.hasProperty('localProperties.autoPublish.application-services.dir')
    114            ? gradle.getProperty('localProperties.autoPublish.application-services.dir') : null
    115 }
    116 ext.configurePublish(config.componentsGroupId, project.name, project.ext.description)
    117 
    118 // Non-official versions are like "61.0a1", where "a1" is the milestone.
    119 // This simply strips that off, leaving "61.0" in this example.
    120 def getAppVersionWithoutMilestone() {
    121    return gradle.mozconfig.substs.MOZ_APP_VERSION.replaceFirst(/a[0-9]/, "")
    122 }
    123 
    124 // Mimic Python: open(os.path.join(buildconfig.topobjdir, 'buildid.h')).readline().split()[2]
    125 def getBuildId() {
    126    if (System.env.MOZ_BUILD_DATE) {
    127        if (System.env.MOZ_BUILD_DATE.length() == 14) {
    128            return System.env.MOZ_BUILD_DATE
    129        }
    130        logger.warn("Ignoring invalid MOZ_BUILD_DATE: ${System.env.MOZ_BUILD_DATE}")
    131    }
    132    return file("${gradle.mozconfig.topobjdir}/buildid.h").getText('utf-8').split()[2]
    133 }
    134 
    135 def getVersionNumber() {
    136    def appVersion = getAppVersionWithoutMilestone()
    137    def parts = appVersion.split('\\.')
    138    def version = parts[0] + "." + parts[1] + "." + getBuildId()
    139 
    140    if (!gradle.mozconfig.substs.MOZILLA_OFFICIAL && !gradle.mozconfig.substs.MOZ_ANDROID_FAT_AAR_ARCHITECTURES) {
    141        // Use -SNAPSHOT versions locally to enable the local GeckoView substitution flow.
    142        version += "-SNAPSHOT"
    143    }
    144 
    145    return version
    146 }
    147 
    148 def getArtifactSuffix() {
    149    def suffix = ""
    150 
    151    // Release artifacts don't specify the channel, for the sake of simplicity.
    152    if (gradle.mozconfig.substs.MOZ_UPDATE_CHANNEL != 'release') {
    153        suffix += "-${gradle.mozconfig.substs.MOZ_UPDATE_CHANNEL}"
    154    }
    155 
    156    return suffix
    157 }
    158 
    159 def computeArtifactId() {
    160    def id = "geckoview" + getArtifactSuffix()
    161 
    162    if (!gradle.mozconfig.substs.MOZ_ANDROID_GECKOVIEW_LITE) {
    163        id += "-omni"
    164    }
    165 
    166    if (gradle.mozconfig.substs.MOZILLA_OFFICIAL && !gradle.mozconfig.substs.MOZ_ANDROID_FAT_AAR_ARCHITECTURES) {
    167        // In automation, per-architecture artifacts identify
    168        // the architecture; multi-architecture artifacts don't.
    169        // When building locally, we produce a "skinny AAR" with
    170        // one target architecture masquerading as a "fat AAR"
    171        // to enable Gradle composite builds to substitute this
    172        // project into consumers easily.
    173        id += "-${gradle.mozconfig.substs.ANDROID_CPU_ARCH}"
    174    }
    175 
    176    return id
    177 }
    178 
    179 def getGeckoViewDependency() {
    180    // on try, relax geckoview version pin to allow for --use-existing-task
    181    if ('https://hg.mozilla.org/try' == System.env.GECKO_HEAD_REPOSITORY) {
    182        rootProject.logger.lifecycle("Getting geckoview on try: ${computeArtifactId()}:+")
    183        return "org.mozilla.geckoview:${computeArtifactId()}:+"
    184    }
    185    rootProject.logger.lifecycle("Getting geckoview: ${computeArtifactId()}:${getVersionNumber()}")
    186    return "org.mozilla.geckoview:${computeArtifactId()}:${getVersionNumber()}"
    187 }