plasmoid/android/build.gradle
2025-02-24 16:53:45 +02:00

55 lines
1.8 KiB
Groovy

allprojects {
repositories {
google()
mavenCentral()
}
}
rootProject.buildDir = "../build"
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
afterEvaluate { project ->
if (project.hasProperty("android")) {
project.android {
compileSdkVersion 34
}
}
}
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
}