Details
Description
Motiviation
Some maven plugins need to be configured by nested elements (e.g. taglist-maven-plugin with tag-configuration). Improve MavenPlugin api to offer a stronger building functionality.
Sample XML
I want to build a configuration like:
<entries> <entry> <key>...</key> <value>...</value> </entry> <entry> <key>...</key> <value>...</value> </entry> </entries>
what the configuration builder in fact does is:
<entries> <entry> <key>...</key> <value>...</value> <key>...</key> <value>...</value> </entry> </entries>
Test-Case
The test-case reproduces problem:
public class MavenPluginBuildConfigTest { private MavenPlugin plugin; @Before public void setUp() { plugin = new MavenPlugin("group", "artifact", "1.0"); } @Test //SUCCESS public void first_level_container() { //SETUP plugin.addParameter("entries/entry", "value1"); plugin.addParameter("entries/entry", "value2"); //ASSERT assertTrue(pluginConfig().contains("<entry>value1</entry>")); assertTrue(pluginConfig().contains("<entry>value2</entry>")); } @Test //FAILS public void second_level_container() { //SETUP plugin.addParameter("entries/entry/key", "key1"); plugin.addParameter("entries/entry/value", "value1"); plugin.addParameter("entries/entry/key", "key2"); plugin.addParameter("entries/entry/value", "value2"); //ASSERT assertTrue(pluginConfig().contains("<entry><key>key1</key><value>value1</value></entry>")); assertTrue(pluginConfig().contains("<entry><key>key2</key><value>value2</value></entry>")); } private String pluginConfig() { //strip whitespace away easier to compare return StringUtils.deleteWhitespace(plugin.getPlugin().getConfiguration().toString()); } }
Issue Links
- is depended upon by
-
SONARPLUGINS-240
Add the matching method management
-
Patch introduces possibility to uniquely address list-containers with special key-index syntax.
Key-Syntax:
Example
would generate:
Please review patch and also its new test-cases. Regression tests of MavenPluginTest are
on green.
Example