Skip to content

Commit

Permalink
Add boolean property to allow webp format export
Browse files Browse the repository at this point in the history
  • Loading branch information
Michael Oliveira committed Aug 26, 2024
1 parent 4fefda5 commit 8a1baf5
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ abstract class MultiplatformResourcesPluginExtension {
abstract val resourcesVisibility: Property<MRVisibility>
abstract val iosMinimalDeploymentTarget: Property<String>
abstract val resourcesSourceSets: NamedDomainObjectContainer<SourceDirectorySet>
abstract val allowWebpImageFormat: Property<Boolean>

fun Project.configureCopyXCFrameworkResources(xcFrameworkName: String = name) {
NativeBuildType.values()
Expand All @@ -35,4 +36,5 @@ internal fun MultiplatformResourcesPluginExtension.setupConvention(project: Proj
iosBaseLocalizationRegion.convention("en")
resourcesVisibility.convention(MRVisibility.Public)
iosMinimalDeploymentTarget.convention("9.0")
allowWebpImageFormat.convention(false)
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ internal class ImageGeneratorFactory(
private val outputAssetsDir: File,
private val kotlinPlatformType: KotlinPlatformType,
private val kotlinKonanTarget: () -> KonanTarget,
private val allowWebpImageFormat: Boolean,
private val androidRClassPackage: () -> String,
private val logger: Logger
) {
Expand All @@ -44,7 +45,11 @@ internal class ImageGeneratorFactory(
generator = ImageResourceGenerator(),
platformResourceGenerator = createPlatformImageGenerator(),
filter = {
include("images/**/*.png", "images/**/*.jpg", "images/**/*.svg")
val formats = mutableListOf("images/**/*.png", "images/**/*.jpg", "images/**/*.svg")
if (allowWebpImageFormat) {
formats.add("images/**/*.webp")
}
include(formats)
}
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ abstract class GenerateMultiplatformResourcesTask : DefaultTask() {
@get:Input
abstract val strictLineBreaks: Property<Boolean>

@get:Input
abstract val allowWebpImageFormat: Property<Boolean>

@get:Optional
@get:PathSensitive(PathSensitivity.RELATIVE)
@get:InputFiles
Expand Down Expand Up @@ -229,8 +232,9 @@ abstract class GenerateMultiplatformResourcesTask : DefaultTask() {
outputAssetsDir = outputAssetsDir.get().asFile,
kotlinPlatformType = kotlinPlatformType,
kotlinKonanTarget = ::kotlinKonanTarget,
allowWebpImageFormat = allowWebpImageFormat.get(),
androidRClassPackage = androidRClassPackage::get,
logger = logger
logger = logger,
).create(),
ColorGeneratorFactory(
resourcesVisibility = resourcesVisibility.get(),
Expand Down

0 comments on commit 8a1baf5

Please sign in to comment.