diff --git a/.github/workflows/default.yml b/.github/workflows/default.yml index 74031623..e0c87f00 100644 --- a/.github/workflows/default.yml +++ b/.github/workflows/default.yml @@ -214,6 +214,7 @@ jobs: - name: Upload screenshot tests result uses: actions/upload-artifact@v4 + if: ${{ always() }} with: name: screenshots path: "${{ github.workspace }}/**/build/*AndroidTest/" diff --git a/easylauncher/src/main/kotlin/com/project/starter/easylauncher/plugin/EasyLauncherPlugin.kt b/easylauncher/src/main/kotlin/com/project/starter/easylauncher/plugin/EasyLauncherPlugin.kt index 54203c77..380a7bb4 100644 --- a/easylauncher/src/main/kotlin/com/project/starter/easylauncher/plugin/EasyLauncherPlugin.kt +++ b/easylauncher/src/main/kotlin/com/project/starter/easylauncher/plugin/EasyLauncherPlugin.kt @@ -28,18 +28,24 @@ class EasyLauncherPlugin : Plugin { } } - val manifestBySourceSet = mutableMapOf() - val resSourceDirectoriesBySourceSet = mutableMapOf>() - - @Suppress("UnstableApiUsage") - androidComponents.finalizeDsl { common -> - common.sourceSets - .mapNotNull { sourceSet -> sourceSet.manifest.srcFile?.let { sourceSet.name to it } } - .forEach { manifestBySourceSet[it.first] = it.second } - - common.sourceSets - .map { sourceSet -> sourceSet.name to sourceSet.res.srcDirs } - .forEach { resSourceDirectoriesBySourceSet[it.first] = it.second } + lateinit var manifestBySourceSet: Map + lateinit var resSourceDirectoriesBySourceSet: Map> + + if (!agpVersion.canUseVariantManifestSources || !agpVersion.canAccessStaticVariantSources) { + @Suppress("UnstableApiUsage") + androidComponents.finalizeDsl { common -> + if (!agpVersion.canUseVariantManifestSources) { + manifestBySourceSet = common.sourceSets + .mapNotNull { sourceSet -> sourceSet.manifest.srcFile?.let { sourceSet.name to it } } + .toMap() + } + + if (!agpVersion.canAccessStaticVariantSources) { + resSourceDirectoriesBySourceSet = common.sourceSets + .map { sourceSet -> sourceSet.name to sourceSet.res.srcDirs } + .toMap() + } + } } androidComponents.onVariants { variant -> @@ -107,15 +113,22 @@ class EasyLauncherPlugin : Plugin { } } - val resSourceDirectories = resSourceDirectoriesBySourceSet - .mapNotNull { (name, files) -> - if (relevantSourcesSets.contains(name)) { - files - } else { - null - } + val resSourceDirectories = if (agpVersion.canAccessStaticVariantSources) { + variant.sources.res?.static?.map { outer -> outer.flatten().map { inner -> inner.asFile } } + ?: project.provider { emptyList() } + } else { + project.provider { + resSourceDirectoriesBySourceSet + .mapNotNull { (name, files) -> + if (relevantSourcesSets.contains(name)) { + files + } else { + null + } + } + .flatten() } - .flatten() + } val capitalisedVariantName = variant.name.replaceFirstChar(Char::titlecase) val task = project.tasks.register("easylauncher$capitalisedVariantName", EasyLauncherTask::class.java) { @@ -124,7 +137,8 @@ class EasyLauncherPlugin : Plugin { it.resourceDirectories.set(resSourceDirectories) it.filters.set(filters) it.customIconNames.set(customIconNames) - it.minSdkVersion.set(variant.minSdkCompat(agpVersion)) + @Suppress("DEPRECATION") + it.minSdkVersion.set(if (agpVersion.canUseNewMinSdk) variant.minSdk.apiLevel else variant.minSdkVersion.apiLevel) } if (agpVersion.canUseNewResources) { @@ -164,9 +178,7 @@ class EasyLauncherPlugin : Plugin { private val AndroidPluginVersion.canUseVariantManifestSources get() = this >= AndroidPluginVersion(8, 3, 0) private val AndroidPluginVersion.hasDebuggableProperty get() = this >= AndroidPluginVersion(8, 3, 0) private val AndroidPluginVersion.canUseNewResources get() = this >= AndroidPluginVersion(7, 4).beta(2) + private val AndroidPluginVersion.canAccessStaticVariantSources get() = this >= AndroidPluginVersion(8, 4).alpha(13) private val AndroidPluginVersion.hasBrokenResourcesMerging get() = this >= AndroidPluginVersion(7, 3).alpha(1) + private val AndroidPluginVersion.canUseNewMinSdk get() = this >= AndroidPluginVersion(8, 1, 0) } - -@Suppress("DEPRECATION") -private fun Variant.minSdkCompat(agpVersion: AndroidPluginVersion) = - if (agpVersion >= AndroidPluginVersion(8, 1)) minSdk.apiLevel else minSdkVersion.apiLevel diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index dc2b3526..94b33659 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -2,7 +2,7 @@ gradle-starter = "0.71.0" gradle-gradlepublish = "1.2.1" gradle-doctor = "0.9.2" -google-agp = "8.3.0" +google-agp = "8.4.0-alpha13" gradle-jacocotestkit = "1.0.12" mavencentral-junit = "5.10.2" mavencentral-assertj = "3.25.3"