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/. */
5 apply plugin: 'com.android.library'
6 apply plugin: 'kotlin-android'
8 def generatedSrcDir = new File(buildDir, "generated/components/src/main/java")
10 // This gitHash functionality is duplicated in publish.gradle.
12 def stdout = new ByteArrayOutputStream()
14 commandLine 'git', 'rev-parse', '--short', 'HEAD'
15 standardOutput = stdout
17 return stdout.toString().trim()
21 compileSdkVersion config.compileSdkVersion
24 minSdkVersion config.minSdkVersion
25 targetSdkVersion config.targetSdkVersion
27 testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
29 buildConfigField("String", "LIBRARY_VERSION", "\"" + config.componentsVersion + "\"")
30 buildConfigField("String", "APPLICATION_SERVICES_VERSION", "\"" + Versions.mozilla_appservices + "\"")
31 buildConfigField("String", "GLEAN_SDK_VERSION", "\"" + Versions.mozilla_glean + "\"")
32 buildConfigField("String", "GIT_HASH", "\"dev build\"")
38 proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
40 buildConfigField("String", "GIT_HASH", "\"" + getGitHash() + "\"")
47 srcDirs += generatedSrcDir
58 implementation Dependencies.kotlin_stdlib
59 implementation Dependencies.kotlin_coroutines
61 api project(":concept-base")
62 // We expose the app-compat as API so that consumers get access to the Lifecycle classes automatically
63 api Dependencies.androidx_appcompat
65 testImplementation project(':support-test')
67 testImplementation Dependencies.testing_coroutines
68 testImplementation Dependencies.androidx_test_core
69 testImplementation Dependencies.androidx_test_junit
70 testImplementation Dependencies.testing_robolectric
71 testImplementation Dependencies.testing_mockito
75 preBuild.finalizedBy("generateComponentEnum")
79 * Generates a "Components" enum listing all published components.
81 tasks.register("generateComponentEnum") {
83 generatedSrcDir.mkdirs()
85 def file = new File(generatedSrcDir, "Component.kt")
89 file << "package mozilla.components.support.base" << "\n"
91 file << "// Automatically generated file. DO NOT MODIFY" << "\n"
93 file << "enum class Component {" << "\n"
95 file << buildConfig.projects.findAll { project ->
97 }.collect { project ->
98 " " + project.key.replace("-", "_").toUpperCase(Locale.US)
107 apply from: '../../../publish.gradle'
108 ext.configurePublish(config.componentsGroupId, archivesBaseName, project.ext.description)