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
|
/* 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 {
minSdkVersion = config.minSdkVersion
compileSdk = config.compileSdkVersion
targetSdkVersion = config.targetSdkVersion
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
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", "\"" + libs.versions.mozilla.glean.get() + "\"")
if (gradle.mozconfig.substs.MOZ_INCLUDE_SOURCE_INFO) {
buildConfigField("String", "VCS_HASH", "\"" + gradle.mozconfig.source_repo.MOZ_SOURCE_STAMP + "\"")
} else {
buildConfigField("String", "VCS_HASH", "\"\"")
}
}
buildTypes {
release {
minifyEnabled = false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets {
main {
java {
srcDirs += generatedSrcDir
}
}
}
buildFeatures {
viewBinding = true
buildConfig = true
}
namespace = 'mozilla.components.support.base'
}
dependencies {
implementation libs.kotlin.coroutines
implementation libs.androidx.activity
implementation libs.androidx.core.ktx
implementation libs.androidx.lifecycle.viewmodel
implementation project(':concept-fetch')
api project(":concept-base")
// We expose the app-compat as API so that consumers get access to the Lifecycle classes automatically
api libs.androidx.appcompat
testImplementation project(':support-test')
testImplementation libs.testing.coroutines
testImplementation libs.androidx.test.core
testImplementation libs.androidx.test.junit
testImplementation libs.testing.robolectric
}
preBuild.finalizedBy("generateComponentEnum")
/**
* Generates a "Components" enum listing all published components.
*/
tasks.register("generateComponentEnum") {
def buildConfigCache = buildConfig
doLast {
generatedSrcDir.mkdirs()
def file = new File(generatedSrcDir, "Component.kt")
file.delete()
file.createNewFile()
file << "/* 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"
file << "package mozilla.components.support.base" << "\n"
file << "\n"
file << "// Automatically generated file. DO NOT MODIFY" << "\n"
file << "\n"
file << "enum class Component {" << "\n"
file << buildConfigCache.projects.findAll { project ->
project.value.publish
}.collect { project ->
" " + project.key.replace("-", "_").toUpperCase(Locale.US)
}.join(", \n")
file << "\n"
file << "}\n"
file << "\n"
}
}
apply from: '../../../android-lint.gradle'
apply from: '../../../publish.gradle'
ext.configurePublish(config.componentsGroupId, project.name, project.ext.description)
|