Skip to content
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

support env files for Gradle Run/Debug configurations (IDEA 2017.2) #38

Closed
jack-kerouac opened this issue Jul 31, 2017 · 10 comments
Closed
Labels

Comments

@jack-kerouac
Copy link

With IntelliJ IDEA 2017.2, environment variables are supported for Gradle Run/Debug configurations: https://www.jetbrains.com/idea/whatsnew/#v2017-2-gradle.

It would be great if the "EnvFile" tab would also be available for Gradle configurations.

@ashald
Copy link
Owner

ashald commented Aug 19, 2017

Cannot say for sure yet but it seems that it might be possible - take some time to figure out available integration points...

@LutzStrobel
Copy link

LutzStrobel commented Jan 24, 2018

I use Idea 2017.3.3 and env version 2.1.0.
The env-file tab is available but does not have any effect.
The variables used are asfollows:
EXT_DATABASE_PASSWORD=cde
EXT_DATABASE_PORT=5432
EXT_DATABASE_SCHEMA=cde
EXT_DATABASE_USER=cde
...

Whats up with my doing?

@ashald
Copy link
Owner

ashald commented Mar 7, 2018

I just tried it with 2017.3.4 and it worked fine. Did you verify that both the plugin and the file are enabled?
enabled

Also, I wonder if it might be related to the content of your file and parser used. My test file looked exactly this way:

EXT_DATABASE_PASSWORD=cde
EXT_DATABASE_PORT=5432
EXT_DATABASE_SCHEMA=cde
EXT_DATABASE_USER=cde

@ashald ashald added the question label Mar 7, 2018
@ashald
Copy link
Owner

ashald commented Mar 7, 2018

Ah, wait, I used an Application run configuration.

Can you please provide me with a minimal Gradle project I can use to run some simple app that prints its environment?

@LutzStrobel
Copy link

I will try it to morrow in the morning.

@mertvetsky
Copy link

mertvetsky commented Aug 30, 2018

I met same problem: running by gradle tasks do not uses file for env import on IDEA community 2018.2

How check it:

  1. Create new gradle project with java
  2. Edit build.gradle like this (just add application plugin and mainClassName):
plugins {
    id 'java'
    id 'application'
}

group 'mert'
version '1.0-SNAPSHOT'

sourceCompatibility = 1.8

repositories {
    mavenCentral()
}

dependencies {
    testCompile group: 'junit', name: 'junit', version: '4.12'
}

mainClassName="App"
  1. Create file ./src/main/java/App.java:
public class App {
    public static void main(String[] args) {
        System.out.print(System.getenv().getOrDefault("FOO", "EMPTY"));
    }
}
  1. Run application/run task from gradle sidebar
  2. Then edit created Run/Debug config for import file with parameter FOO=BAR

PS
When this project runs by "play button" opposite main method it works fine.

@yelhouti
Copy link

Same issue here, any ETA on this please?

@ashald
Copy link
Owner

ashald commented May 24, 2019

@yelhouti contributions are welcome!

@ashald ashald closed this as completed in bc335d7 May 24, 2019
@ashald
Copy link
Owner

ashald commented May 24, 2019

Actually, I was able to figure out a hack to make it work. See https://github.com/ashald/EnvFile#experimental-integrations for details.

I just released v3.2.0 and it may take up to 2 days for JetBrains to process the release, in meantime you can download release directly and install it manually from https://github.com/ashald/EnvFile/releases/tag/v3.2.0

Kudos to @mertvetsky for reproduction steps!

May242019123614

@yelhouti
Copy link

great thank you very much :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants