4

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?

Nathaniel Waisbrot
  • 19,061
  • 3
  • 65
  • 86
Janek
  • 1,401
  • 2
  • 14
  • 25
  • This -Dproperty means a runtime property, for example -DskipTests. You can provide these in launch configurations not in build path what you can do is provide a classpath variable or builder task in order available it in eclipse build process. – Laksitha Ranasingha May 11 '13 at 17:46
  • That is a good example (-DskipTests). Could you please guide me in more details what classpath variable I should add? skipTests=true? – Janek May 11 '13 at 18:56
  • Which property do you want to use ? – Laksitha Ranasingha May 11 '13 at 19:03
  • It is a custom one, so I guess we can just assume someproperty=true ? – Janek May 11 '13 at 19:17

1 Answers1

6

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).

Community
  • 1
  • 1
mliebelt
  • 14,995
  • 7
  • 50
  • 90
  • 1
    Is there a way to add it to a "default" build? Let's say I am doing a change in a file, save it and eclipse builds it automatically - I would like that it has my -Dsomeproperty set already there. Do you know where is this "default" build configuration stored? – Janek May 11 '13 at 21:49
  • Have added screenshots, corrected the description, and made a suggestion how to provide a default configuration. – mliebelt May 12 '13 at 12:11