Skip to content

Commit d254452

Browse files
committed
Fix undefined tags crashing the plugin
1 parent 90f12b3 commit d254452

File tree

5 files changed

+18
-6
lines changed

5 files changed

+18
-6
lines changed

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
3434
### Security
3535
- No security issues fixed!
3636

37+
## [2.1.1] - 2021-05-06
38+
### Fixed
39+
- Fix undefined tags crashing the plugin
40+
3741
## [2.1.0] - 2021-05-05
3842
### Added
3943
- Add `tags` parameter to `poEditorConfig` block to add PoEditor tags:
@@ -264,7 +268,8 @@ res_dir_path -> resDirPath
264268
### Added
265269
- Initial release.
266270

267-
[Unreleased]: https://github.com/hyperdevs-team/poeditor-android-gradle-plugin/compare/2.1.0...HEAD
271+
[Unreleased]: https://github.com/hyperdevs-team/poeditor-android-gradle-plugin/compare/2.1.1...HEAD
272+
[2.1.1]: https://github.com/hyperdevs-team/poeditor-android-gradle-plugin/compare/2.1.0...2.1.1
268273
[2.1.0]: https://github.com/hyperdevs-team/poeditor-android-gradle-plugin/compare/2.0.0...2.1.0
269274
[2.0.0]: https://github.com/hyperdevs-team/poeditor-android-gradle-plugin/compare/1.4.2...2.0.0
270275
[1.4.2]: https://github.com/hyperdevs-team/poeditor-android-gradle-plugin/compare/1.4.1...1.4.2

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ buildscript {
1818
maven { url "https://jitpack.io" }
1919
}
2020
dependencies {
21-
classpath "com.github.hyperdevs-team:poeditor-android-gradle-plugin:2.1.0"
21+
classpath "com.github.hyperdevs-team:poeditor-android-gradle-plugin:2.1.1"
2222
}
2323
}
2424
```
@@ -33,7 +33,7 @@ buildscript {
3333
maven("https://jitpack.io")
3434
}
3535
dependencies {
36-
classpath("com.github.hyperdevs-team:poeditor-android-gradle-plugin:2.1.0")
36+
classpath("com.github.hyperdevs-team:poeditor-android-gradle-plugin:2.1.1")
3737
}
3838
}
3939
```

src/main/kotlin/com/hyperdevs/poeditor/gradle/PoEditorPluginExtension.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ open class PoEditorPluginExtension @Inject constructor(objects: ObjectFactory, p
142142
* NOTE: added for Gradle Groovy DSL compatibility. Check the note on
143143
* https://docs.gradle.org/current/userguide/lazy_configuration.html#lazy_properties for more details.
144144
*
145-
* Gradle Kotlin DSL users must use `defaultResPath.set(value)`.
145+
* Gradle Kotlin DSL users must use `tags.set(value)`.
146146
*/
147147
fun setTags(value: List<String>) = tags.set(value)
148148
}

src/main/kotlin/com/hyperdevs/poeditor/gradle/tasks/ImportPoEditorStringsTask.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ abstract class ImportPoEditorStringsTask
5454
defaultResPath = extension.defaultResPath.get()
5555
tags = extension.tags.get()
5656
} catch (e: Exception) {
57+
logger.error("Import configuration failed", e)
58+
5759
throw IllegalArgumentException(
5860
"You don't have the config '${extension.name}' properly set-up in your '$POEDITOR_CONFIG_NAME' block " +
5961
"or you don't have your main '$DEFAULT_PLUGIN_NAME' config properly set-up.\n" +

src/main/kotlin/com/hyperdevs/poeditor/gradle/utils/ExtensionsUtils.kt

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ private fun <T> Collection<KProperty1<T, *>>.linkProperties(parent: T, child: T,
8080
val parentFallback = property.get(parent) as ListProperty<Nothing>
8181
if (value !== parentFallback) {
8282
value.set(originalProperty.map {
83-
it.takeUnless { it.isEmpty() }!!
83+
it.takeUnless { it.isEmpty() }.sneakyNull()
8484
}.orElse(parentFallback))
8585
} else {
8686
value.set(originalProperty)
@@ -100,4 +100,9 @@ internal fun List<PoEditorPluginExtension>.mapToExtensionMergeHolder(project: Pr
100100
// match its constructor
101101
uninitializedCopy = project.objects.newInstance(project.objects, UUID.randomUUID().toString()))
102102
}
103-
}
103+
}
104+
105+
// 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
106+
// TODO: remove after https://github.com/gradle/gradle/issues/12388
107+
@Suppress("UNCHECKED_CAST")
108+
private fun <T> T?.sneakyNull() = this as T

0 commit comments

Comments
 (0)