Skip to content

Commit

Permalink
Fix undefined tags crashing the plugin
Browse files Browse the repository at this point in the history
  • Loading branch information
adriangl committed May 5, 2021
1 parent 90f12b3 commit d254452
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 6 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Security
- No security issues fixed!

## [2.1.1] - 2021-05-06
### Fixed
- Fix undefined tags crashing the plugin

## [2.1.0] - 2021-05-05
### Added
- Add `tags` parameter to `poEditorConfig` block to add PoEditor tags:
Expand Down Expand Up @@ -264,7 +268,8 @@ res_dir_path -> resDirPath
### Added
- Initial release.

[Unreleased]: https://github.com/hyperdevs-team/poeditor-android-gradle-plugin/compare/2.1.0...HEAD
[Unreleased]: https://github.com/hyperdevs-team/poeditor-android-gradle-plugin/compare/2.1.1...HEAD
[2.1.1]: https://github.com/hyperdevs-team/poeditor-android-gradle-plugin/compare/2.1.0...2.1.1
[2.1.0]: https://github.com/hyperdevs-team/poeditor-android-gradle-plugin/compare/2.0.0...2.1.0
[2.0.0]: https://github.com/hyperdevs-team/poeditor-android-gradle-plugin/compare/1.4.2...2.0.0
[1.4.2]: https://github.com/hyperdevs-team/poeditor-android-gradle-plugin/compare/1.4.1...1.4.2
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ buildscript {
maven { url "https://jitpack.io" }
}
dependencies {
classpath "com.github.hyperdevs-team:poeditor-android-gradle-plugin:2.1.0"
classpath "com.github.hyperdevs-team:poeditor-android-gradle-plugin:2.1.1"
}
}
```
Expand All @@ -33,7 +33,7 @@ buildscript {
maven("https://jitpack.io")
}
dependencies {
classpath("com.github.hyperdevs-team:poeditor-android-gradle-plugin:2.1.0")
classpath("com.github.hyperdevs-team:poeditor-android-gradle-plugin:2.1.1")
}
}
```
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ open class PoEditorPluginExtension @Inject constructor(objects: ObjectFactory, p
* NOTE: added for Gradle Groovy DSL compatibility. Check the note on
* https://docs.gradle.org/current/userguide/lazy_configuration.html#lazy_properties for more details.
*
* Gradle Kotlin DSL users must use `defaultResPath.set(value)`.
* Gradle Kotlin DSL users must use `tags.set(value)`.
*/
fun setTags(value: List<String>) = tags.set(value)
}
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ abstract class ImportPoEditorStringsTask
defaultResPath = extension.defaultResPath.get()
tags = extension.tags.get()
} catch (e: Exception) {
logger.error("Import configuration failed", e)

throw IllegalArgumentException(
"You don't have the config '${extension.name}' properly set-up in your '$POEDITOR_CONFIG_NAME' block " +
"or you don't have your main '$DEFAULT_PLUGIN_NAME' config properly set-up.\n" +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ private fun <T> Collection<KProperty1<T, *>>.linkProperties(parent: T, child: T,
val parentFallback = property.get(parent) as ListProperty<Nothing>
if (value !== parentFallback) {
value.set(originalProperty.map {
it.takeUnless { it.isEmpty() }!!
it.takeUnless { it.isEmpty() }.sneakyNull()
}.orElse(parentFallback))
} else {
value.set(originalProperty)
Expand All @@ -100,4 +100,9 @@ internal fun List<PoEditorPluginExtension>.mapToExtensionMergeHolder(project: Pr
// match its constructor
uninitializedCopy = project.objects.newInstance(project.objects, UUID.randomUUID().toString()))
}
}
}

// Extracted from gradle-play-publisher: https://github.com/Triple-T/gradle-play-publisher/blob/bffc26cb41efc79babdb3ac7dbefcb1d9816f928/play/plugin/src/main/kotlin/com/github/triplet/gradle/play/internal/Extensions.kt#L125
// TODO: remove after https://github.com/gradle/gradle/issues/12388
@Suppress("UNCHECKED_CAST")
private fun <T> T?.sneakyNull() = this as T

0 comments on commit d254452

Please sign in to comment.