// Configurations
Map<String, String> cfgExecElmtsRefMap = new HashMap<String, String>();
if (pluginExecutionRecessive.getConfiguration() != null
&& pluginExecutionDominant.getConfiguration() != null)
{
Configuration pluginExecutionRecessiveCfg = new ConfigurationImpl(
(Xpp3Dom) pluginExecutionRecessive.getConfiguration());
Configuration pluginExecutionDominantCfg = new ConfigurationImpl(
(Xpp3Dom) pluginExecutionDominant.getConfiguration());
Configuration pluginExecutionMergedCfg = new ConfigurationImpl(
(Xpp3Dom) pluginExecutionMerged.getConfiguration());
for (ConfigurationElement e : pluginExecutionDominantCfg.listConfigurationElements())
{
// FIXME: recursively do a diff of childrens, if any
cfgExecElmtsRefMap.put(e.getName(), e.toString());
}
for (ConfigurationElement e : pluginExecutionRecessiveCfg.listConfigurationElements())
{
if (cfgExecElmtsRefMap.containsKey(e.getName()))
{
if (Strings.areEqual(cfgExecElmtsRefMap.get(e.getName()), e.toString()))
{
// Remove the execution configuration element as dominant and recessive have the same
// element
pluginExecutionMergedCfg.removeConfigurationElement(e.getName());
}
}
}
if (!pluginExecutionMergedCfg.hasConfigurationElements())
{
pluginExecutionMerged.setConfiguration(null);
}
try
{
pluginExecutionMerged.setConfiguration(Xpp3DomBuilder.build(
new ByteArrayInputStream(pluginExecutionMergedCfg.toString().getBytes()), "UTF-8"));
}
catch (Exception ex)
{
throw new RuntimeException("Exception while parsing configuration", ex);
}