-
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
Problem with use cases of executing subproject's task with dotenv option by using CLI arguments #67
Comments
(memo) Perhaps the plugin can be resolved all command line arguments by using StartParameter logs
|
I have created a prototype, but it has a lot of problem to resolve this plugins cofigurations. When executing Gradle from the CLI, it's possible to specify tasks for multiple subprojects, but you can't specify -P options for each task individually. This means that you cannot specify different .env file names for each subproject you execute. Determining the expected behavior when CLI arguments are provided is extremely challenging. I could consider supporting |
I think the root cause is the use of Gradle Properties for configuration. However, it's currently unavoidable, as it provides an understandable and minimally necessary functionality for many users. The use of CLI options was unexpected. Apart from this, until I decide to stop using Gradle Properties for configuring this plugin by facing other issues, CLI options will not be supported. |
I have followed this issue and I am a bit unsure how to realize the following: I want to develop a library that will be built in different variants. These variants all use different It used to be possible to simply set How else can one set a different env file to use? Editing |
I have a workaround that is not very clean, but here it goes. In my def envLookup() {
def defaults = [
'API_ENDPOINT': 'http://10.0.2.2:3001/api/v1',
'API_KEY' : 'test',
'VARIANT' : 'default',
'SERVICE' : 'default'
]
def envLookup = [:]
defaults.each { key, value ->
envLookup[key] = env.fetch(key, value)
}
return envLookup
} I can use this, e.g., like:
For actually building the library, I have a Bash script: #!/bin/bash
# trap exit by restoring the original gradle.properties from Git
function cleanup {
echo "Restoring gradle.properties"
git checkout gradle.properties
}
trap cleanup EXIT
# set the envfile to use for building
envFile=$1
gradleOpts="dotenv.filename=$envFile"
# temporarily write the filename setting into gradle.properties (see: https://github.com/uzzu/dotenv-gradle/issues/39)
echo >> gradle.properties
echo "$gradleOpts" >> gradle.properties
# build
./gradlew clean
./gradlew example:assembleRelease
# any other build steps as necessary This will overwrite the |
I'll reopen the issue aside from how to solve it. |
Forked from #39 (comment)
refs: #39 (comment)
I'm still working on how to make the use cases of executing subproject's task with dotenv option by using CLI arguments, but I think the following tests would be good to pass.
Now failing test case
execution log
workaround: Use gradle.properties
The text was updated successfully, but these errors were encountered: