plasmoid/android/build.gradle

56 lines
1.8 KiB
Groovy
Raw Normal View History

2025-02-24 12:57:02 +02:00
allprojects {
repositories {
google()
mavenCentral()
}
}
rootProject.buildDir = "../build"
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
2025-02-24 16:53:45 +02:00
afterEvaluate { project ->
if (project.hasProperty("android")) {
project.android {
2026-06-19 12:51:07 +03:00
compileSdkVersion 36
2025-02-24 16:53:45 +02:00
}
}
}
2025-02-24 12:57:02 +02:00
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
}