-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Getting variables that are defined in the .template but not set in the .env? #42
Comments
@kohenkatz Thanks for reporting issue 😄
Whether it should be provided as a feature of this Gradle plugin is a matter for consideration, but I understand the desire to validate .env files as you have raised. There are other ways to do it, such as providing GitHub Actions or other CI-oriented scripts, in addition to providing it as a feature of this Gradle Plugin. I would like to provide minimum functionality for this Gradle plugin, but what kind of functionality could be nice to have for integrating with validation CI? Any suggestions would be appreciated. (For example I think, outputting checkstyle reports, etc.)
This is a clear functionality that this plugin should provide, so perhaps it could be added to this Gradle plugin. |
Sorry for keeping you waiting for a long time.
https://github.com/uzzu/dotenv-gradle/blob/main/CHANGELOG.md#210---2023-11-26 |
I have been using this plugin for several years for providing various Android Gradle settings, but now I want to extend to also using it to hold settings that are used in the app itself.
Here's the code I came up with to do that:
This adds any environment variable (including from
.env
) that starts withANDROID_
to theBuildConfig
file to allow the app to use it.The problem is that I want to have a sane
null
value for any variable that is defined in.env.template
but is not set with an actual value in.env
. For example, in production I can setANDROID_SENTRY_DSN
to the actual Sentry reporting URL for this app, but in development I need to make sure to leave the key in the.env
file, set to an empty string.Another problem is that I want a way to warn other developers that they are missing values from
.env
(such as when a developer adds a new value). While I could manually keep a list of variables that are required, that introduces an extra maintenance burden of having to add new variables to three places instead of just two: the actual.env
, the.env.template
, and the list in Gradle.I see that
env.allVariables
filters outnull
values. It would be really nice if there was a way to keep the null values for anything that is present in.env.template
as a way to positively show that those are values that we want to see but they are missing? Perhaps a getter forallVariablesWithUndefined
(or similar) that is the same asallVariables
but skips the null check?The text was updated successfully, but these errors were encountered: