Hi everyone!
Could someone tell me if it is possible to access properties from
gradle.properties
in common code?
If not, how can I set an environment variable and read it on common code?
Thanks in advance
k
Kamil Kalisz
07/10/2020, 11:39 AM
Hi Rita, Could you share your use case ? As i know gradle.properties are compile time available, and are not included into result binary. I donโt know your use case but probably it would be best for you to generate kotlin class in the common code that will contain configuration values from gradle.properties
a
andylamax
07/10/2020, 12:27 PM
This is what I am doing at the moment. By using gradle, I export a json file, that is bundle up in android, or, js, or jvm. From there I can read the variables from the json as my environment variables.
I have defined expect actual methods for reading json into a Map<String,Any> which can be used in MPP
r
Rita Curado
07/10/2020, 1:27 PM
Thanks for the answers ๐ So I should add a new file with the variables I need right?
Rita Curado
07/10/2020, 1:29 PM
Meanwhile I started using an external library called BuildKonfig that let me specify some variables from gradle.properties to be used inside common code