Eine aufbereitete Darstellung der Quelle

 
     
 
 
Anforderungen  |   Konzepte  |   Entwurf  |   Entwicklung  |   Qualitätssicherung  |   Lebenszyklus  |   Steuerung
 
 
 
 

Benutzer

Quelle  settings.gradle   Sprache: unbekannt

 
Spracherkennung für: .gradle vermutete Sprache: Unknown {[0] [0] [0]} [Methode: Schwerpunktbildung, einfache Gewichte, sechs Dimensionen]

/* 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/. */
import org.yaml.snakeyaml.Yaml

// We prefer `appServicesRootDir` over `rootDir` to help us on the path to the monorepo.
// (They are the same in app-services but different in moz-central)
def appServicesRootDir = gradle.root.hasProperty("mozconfig") ? new File(ext.topsrcdir, "third_party/application-services/") : rootDir

buildscript {
    dependencies {
        classpath 'org.yaml:snakeyaml:2.2'
    }

    if (!gradle.root.hasProperty("mozconfig")) {
        // in app-services
        repositories {
            mavenCentral()
        }
    } else {
        // big copy/paste from mobile/android/shared-settings.gradle.
        gradle.ext.mozconfig = gradle.root.mozconfig

        repositories {
            gradle.mozconfig.substs.GRADLE_MAVEN_REPOSITORIES.each { repository ->
                maven {
                    url = repository
                    if (gradle.mozconfig.substs.ALLOW_INSECURE_GRADLE_REPOSITORIES) {
                        allowInsecureProtocol = true
                    }
                }
            }
        }
    }
}

if (!gradle.root.hasProperty("mozconfig")) {
    rootProject.name = "appservices"
}

def setupProject(name, projectProps, appServicesRootDir) {
    def path = projectProps.path
    def description = projectProps.description
    def artifactId = projectProps.artifactId

    // TODO: Can we remove artifactId?
    if (name != artifactId) {
        throw new GradleException("Project name should match artifactId: $name != $artifactId")
    }

    settings.include(":$name")

    def projectDir = new File(appServicesRootDir, path)
    // tooling-nimbus-gradle gets special treatment, it doesn't exist in the monorepo
    // (and should be removed entirely!)
    if (!projectDir.exists()) {
        if (name != "tooling-nimbus-gradle") {
            throw new GradleException("Project directory does not exist: $projectDir (for project $name)")
        }
        // gradle 9 gets upset if the dir doesn't exist, even if it's not actually used, like this isn't.
        projectDir = appServicesRootDir
    }
    project(":$name").projectDir = projectDir

    // project(...) gives us a skeleton project that we can't set ext.* on
    gradle.beforeProject { project ->
        // applying this plugin to our sub-projects here makes life much easier for m-c.
        // Once in m-c, we can probably just remove all publishing capabilities from these crates entirely?
        project.apply plugin: 'maven-publish'

        // However, the "afterProject" listener iterates over every project and gives us the actual project
        // So, once we filter for the project we care about, we can set whatever we want
        if (project.name == name) {
            project.ext.description = description
            project.ext.artifactId = artifactId
            // Expose the rest of the project properties, mostly for validation reasons.
            project.ext.configProps = projectProps
            project.ext.appServicesRootDir = appServicesRootDir

            if (gradle.hasProperty("mozconfig")) {
                project.buildDir = "${gradle.mozconfig.topobjdir}/gradle/build/app-services/android/$name"
            }
        }
    }
}

def yaml = new Yaml()
def buildconfig = yaml.load(new File(appServicesRootDir, '.buildconfig-android.yml').newInputStream())
buildconfig.projects.each { project ->
    setupProject(project.key, project.value, appServicesRootDir)
}

Properties localProperties = new Properties();
if (file('local.properties').canRead()) {
    localProperties.load(file('local.properties').newDataInputStream())
    localProperties.each { prop ->
        gradle.ext.set("localProperties.${prop.key}", prop.value)
    }
    logger.lifecycle('Local configuration: loaded local.properties')
} else {
    logger.lifecycle('Local configuration: absent local.properties; proceeding as normal.')
}

def calcVersion(buildconfig) {
    def local = gradle.rootProject.findProperty("local")

    if (gradle.hasProperty("mozconfig")) {
        // We are in m-c - XXX - this is temporary - once in m-c this will not be called, but this seems sane for now?
        def buildid = file("${gradle.mozconfig.topobjdir}/buildid.h").getText('utf-8').split()[2]
        return "${gradle.mozconfig.substs.MOZ_APP_VERSION}-${buildid}"
    } else if (gradle.rootProject.hasProperty("nightlyVersion")) {
        // We are in app-services but building a "nightly" version to be consumed by Fenix.
        return gradle.rootProject.nightlyVersion
    } else if(local) {
        // We are doing a local publish
        return '0.0.1-SNAPSHOT'
    } else {
        // A normal build from app-services.
        return new File(rootDir, 'version.txt').getText().trim()
    }
}

def calcGroupId(buildconfig) {
    if (gradle.rootProject.hasProperty("nightlyVersion")) {
        return buildconfig.groupId + ".nightly"
    } else {
        return buildconfig.groupId
    }
}

// This is a copy of the `Config` object used in moz-central (but with the addition of ndkVersion for UniFFI)
// This is only used when not in mozilla-central - on m-c the existing Config class is used.
// In the short term we should keep them in sync.
// Once in moz-central we should remove this.
class Config {
    // This "componentsVersion" number is defined in "version.txt" and should follow
    // semantic versioning (MAJOR.MINOR.PATCH). See https://semver.org/
    public final String componentsVersion
    public final String componentsGroupId
    public final Integer jvmTargetCompatibility
    public final Integer compileSdkMajorVersion
    public final Integer compileSdkMinorVersion
    public final Integer minSdkVersion
    public final Integer targetSdkVersion
    public final String ndkVersion

    Config(
            String componentsVersion,
            String componentsGroupId,
            Integer jvmTargetCompatibility,
            Integer compileSdkMajorVersion,
            Integer compileSdkMinorVersion,
            Integer minSdkVersion,
            Integer targetSdkVersion,
            String ndkVersion
    ) {
        this.componentsVersion = componentsVersion
        this.componentsGroupId = componentsGroupId
        this.jvmTargetCompatibility = jvmTargetCompatibility
        this.compileSdkMajorVersion = compileSdkMajorVersion
        this.compileSdkMinorVersion = compileSdkMinorVersion
        this.minSdkVersion = minSdkVersion
        this.targetSdkVersion = targetSdkVersion
        this.ndkVersion = ndkVersion
    }
}

gradle.projectsLoaded { ->
    if (gradle.hasProperty("mozconfig")) {
        gradle.rootProject.tasks.register("generateUniffiBindings")
    }

    // Wait until root project is "loaded" before we set "config"
    // Note that since this is set on "rootProject.ext", it will be "in scope" during the evaluation of all projects'
    // gradle files. This means that they can just access "config.<value>", and it'll function properly
    if (!gradle.hasProperty("mozconfig")) {
        gradle.rootProject.ext.config = new Config(
            // You can use -Plocal=true to help with mavenLocal publishing workflow.
            // It makes a fake version number that's smaller than any published version,
            // which can be depended on specifically by the ./build-scripts/substitute-local-appservices.gradle
            // but which is unlikely to be depended on by accident otherwise.
            calcVersion(buildconfig), // version,
            calcGroupId(buildconfig), // componentsGroupId
            17, // jvmTargetCompatibility,
            36, // compileSdkMajorVersion,
            1,  // compileSdkMinorVersion,
            26, // minSdkVersion,
            36, // targetSdkVersion,
            "29.0.14206865", // ndkVersion - Keep it in sync in TC Dockerfile.
        )
    }
}

[Dauer der Verarbeitung: 0.47 Sekunden]

                                                                                                                                                                                                                                                                                                                                                                                                     


Neuigkeiten

     Aktuelles
     Motto des Tages

Open Source Software

     Quellcodebibliothek
     Eigene Quellcodes
     Fremde Quellcodes
     Suchen

Jenseits des Üblichen ....
    

Besucherstatistik

Besucherstatistik

Statistik
#Sources=141584
#Domains=752002