2

I have a custom plugin and I am writing tests to test it. For this I'm using gradle tooling api (I found that to be the recommended way to test).

One of the test requires me to run a task by setting some environment variable. How do I test this. I do not see ProjectConnection providing a way to set environment variable.

If I have to manually test I would have to do this :

setenv LRG_REPOS foo
gradle verify_lrg -PlrgName=abc

where verify_lrg is task added by my custom plugin.

Currently to solve this, I am running using ProcessBuilder, but would like to know if there is any gradle tooling way (because all other tests are using gradle tooling api)

Sundeep Gupta
  • 1,887
  • 3
  • 24
  • 35
  • What you pass is not an environment variable but a *project property*. It can be probably passed with `withArguments` method defined on `ProjectConnection` class. – Opal Jun 19 '15 at 13:45
  • No.it is environment variable LRGREPOS; I am already passing project property using withArguments – Sundeep Gupta Jun 19 '15 at 17:17
  • No idea then. Just have tried to set it up but it seems impossible for now. – Opal Jun 20 '15 at 06:01
  • Oh. Do you see this as valid enhancement to tooling api? – Sundeep Gupta Jun 20 '15 at 10:36
  • Yes, why not? Why you asking? – Opal Jun 20 '15 at 12:12
  • Oh great. Can I work on this enhancement ? What is the process to contribute (This will be my first opensource contribution, so pls bear if I'm asking something trivial). Thanks – Sundeep Gupta Jun 20 '15 at 19:07
  • Could you please join this room to continue the discussion: http://chat.stackoverflow.com/rooms/81107/gradle-tooling-how-to-set-environment-variable ? – Opal Jun 21 '15 at 08:50

1 Answers1

1

It will be possible to configure environment variables via gradle tooling api since 3.5 version, see details at https://github.com/gradle/gradle/pull/1029 https://github.com/gradle/gradle/blob/446468213543e32a0ce1bce0bbedabcfe925c572/subprojects/tooling-api/src/main/java/org/gradle/tooling/LongRunningOperation.java#L190