File: build.gradle

package info (click to toggle)
firefox 147.0.4-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 4,683,532 kB
  • sloc: cpp: 7,607,356; javascript: 6,533,348; ansic: 3,775,236; python: 1,415,508; xml: 634,561; asm: 438,949; java: 186,241; sh: 62,760; makefile: 18,079; objc: 13,092; perl: 12,808; yacc: 4,583; cs: 3,846; pascal: 3,448; lex: 1,720; ruby: 1,003; php: 436; lisp: 258; awk: 247; sql: 66; sed: 54; csh: 10; exp: 6
file content (119 lines) | stat: -rw-r--r-- 4,087 bytes parent folder | download | duplicates (2)
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
/* 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/. */

apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'

def generatedSrcDir = new File(layout.buildDirectory.get().asFile, "generated/components/src/main/java")

android {
    defaultConfig {
        def appServicesVersion = ApplicationServicesConfig.version
        if (gradle.hasProperty("localProperties.branchBuild.application-services.version")) {
            appServicesVersion = gradle["localProperties.branchBuild.application-services.version"]
        }

        buildConfigField("String", "LIBRARY_VERSION", "\"" + config.componentsVersion + "\"")
        buildConfigField("String", "APPLICATION_SERVICES_VERSION", "\"" + appServicesVersion + "\"")
        buildConfigField("String", "GLEAN_SDK_VERSION", "\"" + project.ext.gleanVersion + "\"")
        if (gradle.mozconfig.substs.MOZ_INCLUDE_SOURCE_INFO) {
            buildConfigField("String", "VCS_HASH", "\"" + gradle.mozconfig.source_repo.MOZ_SOURCE_STAMP + "\"")
        } else {
            buildConfigField("String", "VCS_HASH", "\"\"")
        }
    }

    sourceSets {
        main {
            java {
                srcDirs += generatedSrcDir
            }
        }
    }

    buildFeatures {
        viewBinding = true
        buildConfig = true
    }

    namespace = 'mozilla.components.support.base'

}

dependencies {
    api project(":components:concept-base")

    // We expose the app-compat as API so that consumers get access to the Lifecycle classes automatically
    api libs.androidx.appcompat

    implementation project(':components:concept-fetch')

    implementation libs.androidx.activity
    implementation libs.androidx.core.ktx
    implementation libs.androidx.lifecycle.viewmodel
    implementation libs.kotlinx.coroutines

    testImplementation project(':components:support-test')

    testImplementation libs.androidx.test.core
    testImplementation libs.androidx.test.junit
    testImplementation libs.kotlinx.coroutines.test
    testImplementation libs.robolectric
}

/**
 * Generates a "Components" enum listing all published components.
 */
tasks.register("generateComponentEnum") {
    def buildConfigCache = buildConfig
    def publishedProjects = buildConfigCache.projects.findAll { project ->
        project.value.publish
    }
    def file = new File(generatedSrcDir, "Component.kt")

    inputs.property("publishedProjects", publishedProjects.collect { project ->
        project.key + ":" + project.value.publish
    }.sort())

    outputs.file(file)
    
    doLast {
        generatedSrcDir.mkdirs()

        def content = new StringBuilder()
        content << "/* This Source Code Form is subject to the terms of the Mozilla Public\n" +
                " * License, v. 2.0. If a copy of the MPL was not distributed with this\n" +
                " * file, You can obtain one at http://mozilla.org/MPL/2.0/. */\n"

        content << "package mozilla.components.support.base" << "\n"
        content << "\n"
        content << "// Automatically generated file. DO NOT MODIFY" << "\n"
        content << "\n"
        content << "enum class Component {" << "\n"

        content << publishedProjects.collect { project ->
            "    " + project.key.replaceFirst(/^components:/, "").replace("-", "_").toUpperCase(Locale.US)
        }.join(", \n")

        content << "\n"
        content << "}\n"
        content << "\n"

        file.text = content.toString()
    }
}

afterEvaluate {
    tasks.matching { it.name.startsWith("compile") && it.name.endsWith("Kotlin") }.configureEach {
        dependsOn("generateComponentEnum")
    }

    tasks.matching { it.name == "sourceReleaseJar" || it.name == "sourcesJar" }.configureEach {
        dependsOn("generateComponentEnum")
    }
}

apply from: '../../../common-config.gradle'
apply from: '../../../publish.gradle'
ext.configurePublish(config.componentsGroupId, project.name, project.ext.description)