File: substitute-local-ac.gradle

package info (click to toggle)
thunderbird 1%3A143.0.1-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 4,703,968 kB
  • sloc: cpp: 7,770,492; javascript: 5,943,842; ansic: 3,918,754; python: 1,418,263; xml: 653,354; asm: 474,045; java: 183,079; sh: 111,238; makefile: 20,410; perl: 14,359; objc: 13,059; yacc: 4,583; pascal: 3,405; lex: 1,720; ruby: 999; exp: 762; sql: 715; awk: 580; php: 436; lisp: 430; sed: 69; csh: 10
file content (49 lines) | stat: -rw-r--r-- 2,461 bytes parent folder | download | duplicates (10)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49

def version = null
if (gradle.hasProperty("localProperties.autoPublish.android-components.dir")) {
  //  We're doing local development using the autoPublish system.  This automatically rebuilds and
  //  publishes android-components packages whenever the source changes.
  // This version string will selected the latest build package
  version = '0.0.1-+'
} else if (gradle.hasProperty("localProperties.branchBuild.android-components.version")) {
  //  We're running a branch build.  Here the version is set to the git commit id in
  //  local.properties
  version = gradle.getProperty("localProperties.branchBuild.android-components.version")
} else {
  throw new Exception("substitute-local-appservices.gradle called from unexpected context")
}
logger.lifecycle("[local-ac] adjusting project to use locally published android-components modules (${version})")

// Inject mavenLocal repository. This is where we're expected to publish modules.
repositories {
    mavenLocal()
}

configurations.configureEach { config ->
    if (config.isCanBeResolved()) {
        config.resolutionStrategy { strategy ->
            dependencySubstitution {
                // Linter is broken here and incorrectly suggests to replace
                // all() with configureEach(), which doesn't exist on DependencySubstitutions.
                // https://docs.gradle.org/current/javadoc/org/gradle/api/artifacts/DependencySubstitutions.html
                //noinspection ConfigurationAvoidance
                all { dependency ->
                    if (!(dependency.requested instanceof ModuleComponentSelector)) {
                        // We only care about substituting for a module, not a project.
                        return
                    }

                    // For every org.mozilla.components.* module, substitute its version for '+'.
                    // '+' version tells gradle to resolve the latest available version.
                    // As long as 'mavenLocal' is in the repositories list, gradle should pick out
                    // latest published module during dependency resolution phase.
                    def group = dependency.requested.group
                    if (group == 'org.mozilla.components') {
                        def name = dependency.requested.module
                        dependency.useTarget([group: group, name: name, version: version])
                    }
                }
            }
        }
    }
}