Janek
Janek

Reputation: 1491

How do I set a system property for compiling in Eclipse?

When I build my project from the command line with Maven, I can pass in a property using

-Dsomeproperty=true

For example:

 mvn clean package -Dsomeproperty=true

How do I do the same when building in Eclipse?

Upvotes: 9

Views: 40640

Answers (1)

mliebelt
mliebelt

Reputation: 15525

You have to do the following steps (and sorry, I have no environment to prove it, just from documentation):

  1. Create a maven build by choosing on the selected pom of your project Run > Maven...
  2. Enter the relevant goal, and press add in the arguments table.
  3. Enter there your system property as name: someproperty and value: true.
  4. Then start your maven build by pressing Run.

See the following resources for details:

After having access to an Eclipse again, here are some screenshots:

  • enter image description here
  • enter image description here

The first shows how to configure an existing build (in Eclipse named a run configuration) with the relevant property. and the second shows the command that is then triggered (with the include -Dsomeproperty=true).

I do not know if there is an easy way to configure the default run configuration. You may provide an empty one, enter there the parameter, and copy then that run configuration adding the additional parameters later. The copy button is on the left top the second one (with the red rectangle marking it).

Upvotes: 10

Related Questions