plasmoid/android/build.gradle
randogoth dc7af87493 init
2025-02-24 12:57:02 +02:00

48 lines
1.7 KiB
Groovy

allprojects {
repositories {
google()
mavenCentral()
}
}
rootProject.buildDir = "../build"
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
project.evaluationDependsOn(':app') // Ensure dependencies are evaluated correctly
plugins.withId('com.android.library') {
extensions.configure(com.android.build.gradle.LibraryExtension) { android ->
// Retrieve the manifest file path
def manifestFile = android.sourceSets.main.manifest.srcFile
// Attempt to retrieve the package name from AndroidManifest.xml
def packageName = null
if (manifestFile.exists()) {
def manifestContent = new XmlParser().parse(file(manifestFile))
packageName = manifestContent.@package
}
// Ensure namespace is set with fallback logic
if (!android.hasProperty("namespace") || android.namespace == null || android.namespace.isEmpty()) {
if (packageName) {
println ">> Derived Namespace for: '${project.name}' to '${packageName}'"
android.namespace = packageName
} else {
// Set a default namespace if packageName is null
def defaultNamespace = "com.example.${project.name}"
println "?? Made up Namespace for: '${project.name}' to '${defaultNamespace}'"
android.namespace = defaultNamespace
}
}
}
}
}
tasks.register("clean", Delete) {
delete rootProject.buildDir
}