Depressio
Depressio

Reputation: 1379

Sending an environment variable to jetty using jettyRun in Gradle

How might I make an environment variable available to jetty using the gradle plugin? Some of the code it runs in a servlet requires a particular environment variable to be set, but I can't figure out a good way to send it to the jetty process like you can for a JavaExec task (via the environment method).

Also acceptable would be a property. For example, if I were to run some java, I'd include a -Dproperty.name=blah to send it the property.name property.

We can do it for Test and JavaExec tasks... can we do it for the JettyRun task?

Upvotes: 5

Views: 3047

Answers (1)

Peter Niederwieser
Peter Niederwieser

Reputation: 123920

The container managed by the Jetty plugin runs in the Gradle process, so you need to set an environment variable or system property for that process.

The Jetty plugin is also quite outdated and limited, partly for exactly the reason that it runs inside the Gradle process. I recommend to instead give the arquillian-gradle-plugin a try. We think that this plugin paves the way to better Gradle web container support.

Upvotes: 3

Related Questions