How to define complex Maven properties in the comand line

北慕城南 提交于 2020-05-15 11:34:46

问题


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

?


回答1:


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.



来源:https://stackoverflow.com/questions/40023283/how-to-define-complex-maven-properties-in-the-comand-line

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!