-
Notifications
You must be signed in to change notification settings - Fork 137
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make adding the new build field not mandatory
Also adds a helper function that reads the property when it exists using reflection
- Loading branch information
1 parent
f18bfa8
commit 61128a8
Showing
2 changed files
with
16 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
WooCommerce/src/main/kotlin/com/woocommerce/android/util/BuildConfigExt.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.woocommerce.android.util | ||
|
||
import com.woocommerce.android.BuildConfig | ||
|
||
@Suppress("SwallowedException") | ||
inline fun <reified T> getBuildConfigValueOrNull(key: String): T? { | ||
return try { | ||
val field = BuildConfig::class.java.getField(key) | ||
field.get(null) as? T | ||
} catch (e: NoSuchFileException) { | ||
null | ||
} | ||
} |