I’m currently working on a Flutter project and I tend to use VSCode, this is my configuration:
Json:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "UAT",
"request": "launch",
"type": "dart",
"program": "lib/main.dart",
"preLaunchTask": "UAT",
"args": [
"--target",
"lib/main.dart",
"--dart-define-from-file=env.json",
],
}
]
}
Which basically runs a task that has this command:
Json:
"command": "setup.sh uat",
Thing is that I’m trying to find a way for my colleges using AndroidStudio to get a similar experience by using the runConfigurations
in AndroidStudio
I have tried adding external tools, and it worked just fine… But you cannot add them to git because it’s stored locally, so it refers to a tool u don’t have
I also thought about adding it to build.gradle
, but I do not manage to get it working
Is there any advice u guys could give me?
Thanks! 🙂
2
Answers
After some tries I managed to get a build.gradle task which is in fact checked into the vcs :')
What i did was:
Created .idea/runConfigurations/whatever.xml
So if I wanted to define a variable I'd just use a regular dart define and also a dart-define-from-file just as an example
The important part is inside the ...
I just created another build.gradle under
android/scripts/
(Wanted to have it separate from the main build.gradle)In that script you can do something like:
And this will run the script with the argument u passed as -Penv (in this case, "qa")
one last thing u would need to do is to modify the /android/settings.gradle` to actually add this sub-folder
just add at the very bottom:
I’ve created a script that takes the ".vscode/launch.json" and based on it (and the preLaunchTask it might have) it generates both ".idea/runConfigurations/[config].xml’s" and some scripts, that get’s added to my Makefile (if you use command line tool or want to run it from pipelines)