Hi, is someone able to support me by accessing val...
# multiplatform
m
Hi, is someone able to support me by accessing values from my
local.properties
inside my common code base? I need credentials (each dev has its own) to send an REST request. I did in local.properties:
Copy code
username=myName
password=myPassword
I have no idea how I can access them, in my code. In my
build.gradle
I can do something like that:
Copy code
val userName: String = gradleLocalProperties(rootDir).getProperty("username")
val password: String = gradleLocalProperties(rootDir).getProperty("password")
But how can I connect the gradle variables into my code? Do I miss some imports or something similar?
g
local.properties never were available in code, even on android
I believe I saw a gradle plugin which provides something like android build config for Kotlin MPP, but do not remember exact name
m
Thanks for your quick reply. I will have a closer look on the plugin. Is there any other common way manage those kind of credentials? Or simply put my credentials in a kotlin object and put it on the
.gitignore
file?
g
I think it depends on what kind credentials Include username/password to client application by itself sounds not nice, and even something like secret/token is a bit (but not much) better
I don’t think that there is a usual solution. for Android it’s build config, I believe for desktop it usually runtime environment variables and user configs, but if it required to be included during build process, solution like build config is probably the most convinient thing
🙏 1