How to add a resValue from the environment in Gradle Kotlin DSL?


I am trying to add a resource value from the environment on my machine via resValue using the Gradle Kotlin DSL. My issue is that the desired variable, BearerToken is unresolved. The value is stored in my Mac’s Users/myuser/.gradle/ file.

In regular Kotlin DSL, the below worked just fine

resValue 'string', "bearer_token", BearerToken

I am converting to the Gradle Kotlin DSL, and have the following

resValue("string", "bearer_token", BearerToken)

Gradle sync failed and reported that BearerToken is unresolved. There aren’t any other APIs I can use.

I tried using System.getenv("BearerToken") and it did not work either.

Does anyone know what the issue may be?


I havn’t tried this. But properties end up in the map. So instead of System.getenv try:"BearerToken")

Answered By – Larusso

Leave a Comment