Skip to content

Commit

Permalink
Handle a case when a module group name is empty in Gradle Plugin.
Browse files Browse the repository at this point in the history
And change error reporting to warning for unknown resource type
  • Loading branch information
terrakok committed Dec 6, 2023
1 parent 94bda44 commit dfaeced
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ abstract class GenerateResClassTask : DefaultTask() {
val type = try {
ResourceType.fromString(typeString)
} catch (e: Exception) {
logger.error("e: Error: $path", e)
logger.warn("w: Skip file: $path\n${e.message}")
return null
}
listOf(ResourceItem(type, qualifiers, file.nameWithoutExtension.asUnderscoredIdentifier(), path))
Expand All @@ -100,4 +100,4 @@ abstract class GenerateResClassTask : DefaultTask() {
internal fun String.asUnderscoredIdentifier(): String =
lowercase()
.replace('-', '_')
.let { if (it.first().isDigit()) "_$it" else it }
.let { if (it.isNotEmpty() && it.first().isDigit()) "_$it" else it }
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ class ResourcesTest : GradlePluginTestBase() {
file("expected/Res.kt")
)
check.logContains("""
java.lang.IllegalStateException: Unknown resource type: ignored
Unknown resource type: ignored
""".trimIndent())
}

Expand Down

0 comments on commit dfaeced

Please sign in to comment.