Browse Source

Fix android font bundling and add tests

k.tskh/font-dup-fix
Konstantin Tskhovrebov 10 months ago
parent
commit
7c0e29ca62
  1. 2
      gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/resources/ResourcesGenerator.kt
  2. 14
      gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/tests/integration/ResourcesTest.kt

2
gradle-plugins/compose/src/main/kotlin/org/jetbrains/compose/resources/ResourcesGenerator.kt

@ -171,7 +171,7 @@ internal abstract class CopyAndroidFontsToAssetsTask : DefaultTask() {
fileSystem.copy { fileSystem.copy {
it.includeEmptyDirs = false it.includeEmptyDirs = false
it.from(from) it.from(from)
it.exclude("**/font*/*") it.include("**/font*/*")
it.into(outputDirectory) it.into(outputDirectory)
} }
} }

14
gradle-plugins/compose/src/test/kotlin/org/jetbrains/compose/test/tests/integration/ResourcesTest.kt

@ -5,6 +5,8 @@ import org.jetbrains.compose.test.utils.assertEqualTextFiles
import org.jetbrains.compose.test.utils.assertNotEqualTextFiles import org.jetbrains.compose.test.utils.assertNotEqualTextFiles
import org.jetbrains.compose.test.utils.checks import org.jetbrains.compose.test.utils.checks
import org.junit.jupiter.api.Test import org.junit.jupiter.api.Test
import java.util.zip.ZipEntry
import java.util.zip.ZipFile
import kotlin.io.path.Path import kotlin.io.path.Path
class ResourcesTest : GradlePluginTestBase() { class ResourcesTest : GradlePluginTestBase() {
@ -115,6 +117,18 @@ class ResourcesTest : GradlePluginTestBase() {
gradle("build").checks { gradle("build").checks {
check.taskSuccessful(":copyDebugFontsToAndroidAssets") check.taskSuccessful(":copyDebugFontsToAndroidAssets")
check.taskSuccessful(":copyReleaseFontsToAndroidAssets") check.taskSuccessful(":copyReleaseFontsToAndroidAssets")
val debugApk = file("build/outputs/apk/debug/resources_test-debug.apk")
assert(debugApk.exists())
val debugZip = ZipFile(debugApk)
assert(debugZip.getEntry("font/emptyFont.otf") != null)
assert(debugZip.getEntry("assets/font/emptyFont.otf") != null)
val releaseApk = file("build/outputs/apk/release/resources_test-release-unsigned.apk")
assert(releaseApk.exists())
val releaseZip = ZipFile(releaseApk)
assert(releaseZip.getEntry("font/emptyFont.otf") != null)
assert(releaseZip.getEntry("assets/font/emptyFont.otf") != null)
} }
} }

Loading…
Cancel
Save