Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to define complex Maven properties in the comand line

I'm using the Maven cobertura plugin to retrieve my unit test code covering and I'm using it through the command line:

mvn cobertura:cobertura

What I would like to do is configure the exclusions from command line. As you can see from the official documentation, we can configure an instrumentation user property.

This Instrumentation Configuration object has the below structure:

<instrumentation>
  <excludes>
    <exclude>com/example/dullcode/**/*.class</exclude>
  </excludes>
</instrumentation>

Is there any way to configure a complex object like the above using only the command line in the form of

-Dcobertura.instrumentation.excludes.<something>=com/example/dullcode/**/*.class

?

like image 248
gvdm Avatar asked Oct 26 '25 10:10

gvdm


1 Answers

No, you can't define a complex parameter on the command line. But you can implement a trick to make this work: define a Maven property that you override on the command-line.

You can configure the plugin with:

<instrumentation>
  <excludes>
    <exclude>${cobertura.instrumentation.exclude}</exclude>
  </excludes>
</instrumentation>

then, on the command-line, having

-Dcobertura.instrumentation.exclude=com/example/dullcode/**/*.class

will correctly exclude those classes. And if you don't specify the system property, nothing will be excluded.

like image 164
Tunaki Avatar answered Oct 29 '25 07:10

Tunaki



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!