Skip to content

Commit

Permalink
[gradle] Fix android assets configuration with AGP < 8.1.0.
Browse files Browse the repository at this point in the history
  • Loading branch information
terrakok committed Jun 20, 2024
1 parent be4dfa4 commit bb5623e
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,10 @@ internal fun Project.configureAndroidComposeResources(
)

// addGeneratedSourceDirectory doesn't mark the output directory as assets hence AS Compose Preview doesn't work
addStaticSourceDirectory(copyResources.flatMap { it.outputDirectory.asFile }.get().path)
val outDir = copyResources.flatMap { it.outputDirectory.asFile }.get()
if (outDir.isDirectory) {
addStaticSourceDirectory(outDir.path)
}

// addGeneratedSourceDirectory doesn't run the copyResources task during AS Compose Preview build
tasks.configureEach { task ->
Expand Down Expand Up @@ -117,7 +120,9 @@ internal fun Project.configureAndroidAssetsForPreview() {
tasks.all { task ->
if (task.name == kgpCopyAssetsTaskName) {
task.outputs.files.forEach { file ->
addStaticSourceDirectory(file.path)
if (file.isDirectory) {
addStaticSourceDirectory(file.path)
}
}
}
}
Expand Down

0 comments on commit bb5623e

Please sign in to comment.