netbeans-gradle-project icon indicating copy to clipboard operation
netbeans-gradle-project copied to clipboard

Setting environment variable in shell script run in Gradle task

Open coder451 opened this issue 8 years ago • 1 comments

I am using the Gradle plugin in Netbeans on Linux. I also do builds outside Netbeans. I have a Gradle task that runs a shell script that needs an environment variable. I have this variable set in my environment, and the task works when run from a command line outside Netbeans. When I run the task from the tasks menu for the project inside Netbeans, it does not see the environment variable. Is there a way to provide that environment variable in the task, using a Netbeans project setting? I should mention that I am using Ubuntu Unity and typically start Netbeans from a desktop icon, so it probably does not inherit the environment variable when it starts..

coder451 avatar Nov 08 '16 12:11 coder451

If you can't make the NB process inherit the variable, then I can't think of any way to access the variable. Unfortunately, I can't even implement such a feature because Gradle's Tooling API is starting the Gradle process and offers no way to adjust the environment variables.

If you are in control of the build, then the best option I can think of is to rely on project properties (and maybe fallback to environment variables if they are not there). It might be good for you anyway, because it makes it easier to override the values of those variables.

kelemen avatar Nov 08 '16 19:11 kelemen