Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sending an environment variable to jetty using jettyRun in Gradle

Tags:

gradle

jetty

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?

like image 316
Depressio Avatar asked Oct 22 '22 04:10

Depressio


1 Answers

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.

like image 145
Peter Niederwieser Avatar answered Oct 24 '22 02:10

Peter Niederwieser