Resolve namespace issues for compatibility with Gradle 8.0 and above. * In compliance with the requirement to specify a namespace for each module, we have eliminated package names from manifests and introduced namespace declarations in the Gradle files. * Considering the presence of multiple apps in the custom app, we configured the namespace during the creation of product flavors. * To enhance clarity and understanding, comprehensive comments have been added.

This commit is contained in:
MohitMaliFtechiz 2023-11-22 19:11:02 +05:30 committed by Kelson
parent 0f65ebeff9
commit 2a9bbe71b3
5 changed files with 23 additions and 8 deletions

View File

@ -20,6 +20,9 @@ fun generateVersionName() = "${Config.versionMajor}.${Config.versionMinor}.${Con
val apkPrefix get() = System.getenv("TAG") ?: "kiwix"
android {
// Added namespace in response to Gradle 8.0 and above.
// This is now specified in the Gradle configuration instead of declaring
// it directly in the AndroidManifest file.
namespace = "org.kiwix.kiwixmobile"
defaultConfig {
base.archivesName.set(apkPrefix)

View File

@ -43,9 +43,18 @@ class AllProjectConfigurer {
target.plugins.apply("androidx.navigation.safeargs")
}
fun configureBaseExtension(target: Project) {
fun configureBaseExtension(target: Project, isLibrary: Boolean) {
target.configureExtension<BaseExtension> {
namespace = ""
// The namespace cannot be directly set in `LibraryExtension`.
// The core module is configured as a library for both Kiwix and custom apps.
// Therefore, we set the namespace in `BaseExtension` for the core module,
// based on the boolean value of `isLibrary`. This value is passed from the
// `KiwixConfigurationPlugin`. If the current plugin is `LibraryPlugin`,
// indicating it is the core module, then this value will be true,
// and we set the namespace accordingly.
if (isLibrary) {
namespace = "org.kiwix.kiwixmobile.core"
}
setCompileSdkVersion(Config.compileSdk)
defaultConfig {
minSdk = Config.minSdk

View File

@ -33,10 +33,10 @@ class KiwixConfigurationPlugin : Plugin<Project> {
target.plugins.all {
when (this) {
is LibraryPlugin -> {
doDefaultConfiguration(target)
doDefaultConfiguration(target, true)
}
is AppPlugin -> {
doDefaultConfiguration(target)
doDefaultConfiguration(target, false)
appConfigurer.configure(target)
}
}
@ -47,8 +47,8 @@ class KiwixConfigurationPlugin : Plugin<Project> {
allProjectConfigurer.configureJacoco(target)
}
private fun doDefaultConfiguration(target: Project) {
allProjectConfigurer.configureBaseExtension(target)
private fun doDefaultConfiguration(target: Project, isLibrary: Boolean) {
allProjectConfigurer.configureBaseExtension(target, isLibrary)
allProjectConfigurer.configureCommonExtension(target)
}
}

View File

@ -30,6 +30,10 @@ android {
productFlavors.apply {
CustomApps.createDynamically(project.file("src"), this)
all {
// Added namespace for every custom app to make it compatible with gradle 8.0 and above.
// This is now specified in the Gradle configuration instead of declaring
// it directly in the AndroidManifest file.
namespace = "org.kiwix.kiwixcustom$name"
File("$projectDir/src", "$name/$name.zim").let {
createDownloadTask(it)
createPublishApkWithExpansionTask(it, applicationVariants)

View File

@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="org.kiwix.kiwixmobile.custom">
xmlns:tools="http://schemas.android.com/tools">
<application