- Notifications
You must be signed in to change notification settings - Fork129
EnvFile 3.x is a plugin for JetBrains IDEs that allows you to set environment variables for your run configurations from one or multiple files.
License
ashald/EnvFile
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Env File is a plugin for JetBrains IDEs that allows you to set environment variables for your run configurationsfrom one or multiple files.
- .env
- YAML dictionary
- JSON dictionary(parsed with YAML parser sinceJSON is subset of YAML)
All formats assume that both keys and values are strings.
Expand to see supported run configuration types. Italic means that run configuration is only available in paidversion of the product.PyCharm
- App Engine server
- Behave
- Django server
- Django tests
- Lettuce
- Pyramid server
- Python
- Python docs
- Docutils task
- Sphinx task
- Python test
- Unittests
- Doctests
- Nosetests
- py.test
- Attests
- Tox
IDEA
- Application
- Arquillian JUnit
- Arquillian TestNG
- CloudBees Server
- Cucumber Java
- Gradle (requires "Enable Experimental Integrations")
- GWT Configuration
- Geronimo Server
- Local
- Remote
- GlassFish Server
- Local
- Remote
- Google AppEngine Dev Server
- Grails
- JAR Application
- JBoss Server
- Local
- Remote
- JSR45 Compatible Server
- Local
- Remote
- Jetty Server
- Local
- Remote
- JUnit
- Kotlin
- Kotlin script
- Resin
- Local
- Remote
- Spring Boot
- Spring dmServer
- Spring dmServer (Local)
- Spring dmServer (Remote)
- TestNG
- TomEE Server
- Local
- Remote
- TomCat Server
- Local
- Remote
- WebLogic Server
- Local
- Remote
- WebSphere Server
- Local
- Remote
RubyMine
- Capistrano
- Cucumber
- Gem Command
- IRB Console
- RSpec
- Rack
- Rails
- Rake
- Ruby
- Spork DRb
- Test::Unit/Shoulda/Minitest
- Zeus Server
GoLand
- Go App Engine
- Go Build
- Go Test
Cursive (>=1.8.2)
- Local Clojure REPL
- Clojure Application
- Leiningen
Using IDE built-in plugin system:
- Preferences >Plugins >Browse repositories... >Search for "Env File" >Install Plugin
Manually:
- Download thelatest release and install it manually usingPreferences >Plugins >Install plugin from disk...
Restart IDE.
- Add newRun/Debug configuration:+Add new configuration >...
- Switch toEnvFile tab
- SelectEnable EnvFile checkbox
- SelectSubstitute Environment Variables checkbox (if needed)
- SelectProcess JetBrains path macro references checkbox (if needed)
- SelectIgnore missing files checkbox (if needed)
- SelectEnable experimental integrations checkbox (if needed)
- Click on+ to add a file
- Adjust order as needed
- Even variables defined within run configuration can be processed, ordered and substituted
Hidden files (starting with a dot) are not displayed in Finder onmacOS
by default. To togglehidden files in the Open dialog, pressCOMMAND +SHIFT +..Alternatively, one can either tweakmacOS
to show hidden files or select any file usingstandard Finder dialog and then manually edit path by double-clicking on the entry in the table.
Not all run configurations available in IDEA-based IDEs are implemented similarly. Some of them differ significantly.In certain cases (so far, onlyGradle
has been confirmed) the implementation exposes interfaces to integrate the EnvFile UIbut doesn't provide interfaces for it to actually make its work. Luckily, it was possible to make few assumptions aboutIDEA's internal implementation and make it work. Such integration is very fragile and it's not immediately clear if itwill affect any existing integrations and when it will break. For that reason there is a special option toEnable Experimental Integrations
that can be enabled when desired and should prevent other integrations from breaking.
# This line is ignored since it's a commentSECRET_KEY=hip-hip-env-filesVERSION=1.0
or
# This line is ignored since it's a commentSECRET_KEY hip-hip-env-filesVERSION 1.0
{# JSON doesn't have comments but since JSON is subset of YAML# We parse it with YAML parser and therefore have comments# And even trialling commas in objects :)"SECRET_KEY":"hip-hip-env-files","VERSION":"1.0",# All non-string literals should be enclosed in quotes; btw this is ignored too}
# This line is ignored since it's a commentSECRET_KEY:hip-hip-env-filesVERSION:"1.0"# All non-string literals should be enclosed in quotes; btw this is ignored too
There was a number of requests to support extracting environment variables from bash scripts like:
export SECRET_KEY="hip-hip-env-files"export VERSION="1.0"
The feasible way to do that is yet to be discovered (if any at all) so the plugin does not support that at the moment.On the other hand there is a simple workaround that can be used for the time being. The example bash script from abovecan be split into an.env
file and a generic script that can be used to set environment variables on a command line:
.env
SECRET_KEY="hip-hip-env-files"VERSION="1.0"
set-env.sh
whileread -r line;doexport$line;done< .env
usage
$ . set-env.sh$ echo $VERSION1.0
EnvFile
also supports environment variable substitution. It's optional and disabled by default.Implementation is based onStringSubstitutor so it's the best reference for how it works.
Syntax isderived from Bash but is way more primitive:
A=${FOO} # A="" <- unknown variables replaced by empty stringsB=${FOO:-default} # B="default" <- default values can be set as in BashC=${B} # C="default" <- it's possible to refer to other variables that were previously evaluatedD=$${C} # D="$${C}" <- double dollar serves as an escape characterE=$C $ E="$C" <- curly brackets are required
Environment variables are evaluated in the order they are defined in files.Files are evaluated in the order defined in EnvFile UI.Environment variables defined in run configuration can be ordered relatively to files.Order between environment variables defined in run configuration is not defined.
It is possible to refer to any environment variables that were evaluated previously - within same file or from other sources.
EnvFile
can substitute JetBrains path macro references such as$PROJECT_DIR$
etc. It's optional and disabled by default.For details - see"Working with $PROJECT_DIR$ in plugin configuration options".
- Add more formats (upon requests)
- Add support for other JetBrains products/plugins (upon requests)
- Add more tests (¯\_(ツ)_/¯)
EnvFile uses Gradle for building.
$ ./gradlew cleantest build BUILD SUCCESSFULin 22s 59 actionable tasks: 59 executed $ ls -1 build/distributions Env File-2.1.1-SNAPSHOT.zip
In order to open plugin's project in IDE, just open it as a Gradle project.Then useintelij:runId
on the root of the project to launch an IDEA instance.You can setIDE
env var for the run configuration pointing at IDE folder (IDE Folder/Content
on macOS) to testplugin with different versions.
Any feedback, bug reports and feature requests are highly appreciated!
Feel free to create an issue, contact me usingGithub
or just drop me an email to the address specified inplugin.xml/idea-plugin/vendor@email
.
Copyright (c) 2017 Borys Pierov. See theLICENSE file for license rights and limitations (MIT).
About
EnvFile 3.x is a plugin for JetBrains IDEs that allows you to set environment variables for your run configurations from one or multiple files.