* in the recessive plugin but not in dominant, it will be ignored <b>Important: the artifactId and groupId
* properties are not affected</b>
*/
private MavenPluginAdapter diff(final MavenPlugin dominant, final MavenPlugin recessive)
{
MavenPluginAdapter merged = new MavenPluginAdapter(dominant);
if (Dependencies.areEquivalent(dominant.getCoordinate(), recessive.getCoordinate()))
{
// Version
if (Strings.compare(dominant.getCoordinate().getVersion(), recessive.getCoordinate().getVersion()))
{
// Remove version as dominant and recessive have the same one
merged.setVersion(null);
}
// Extension
if (dominant.isExtensionsEnabled() == recessive.isExtensionsEnabled())
{
// Remove extension as dominant and recessive have the same one
merged.setExtensions(null);
}
// Config
Map<String, String> cfgElmtsRefMap = new HashMap<>();
Configuration mergedConfiguration = merged.getConfig();
if (dominant.getConfig() != null && recessive.getConfig() != null)
{
for (ConfigurationElement e : dominant.getConfig().listConfigurationElements())
{
// FIXME: recursively do a diff of childrens, if any
cfgElmtsRefMap.put(e.getName(), e.toString());
}
for (ConfigurationElement e : recessive.getConfig().listConfigurationElements())
{
if (cfgElmtsRefMap.containsKey(e.getName()))
{
if (Strings.compare(cfgElmtsRefMap.get(e.getName()), e.toString()))
{
// Remove the configuration element as dominant and recessive have the same element
mergedConfiguration.removeConfigurationElement(e.getName());
}
}
}
}
merged.setConfig(mergedConfiguration);
// Executions
Map<String, PluginExecution> dominantExec = new MavenPluginAdapter(dominant).getExecutionsAsMap();
Map<String, PluginExecution> recessiveExec = new MavenPluginAdapter(recessive).getExecutionsAsMap();
Map<String, PluginExecution> mergedExec = merged.getExecutionsAsMap();
if (dominantExec != null && recessiveExec != null)
{
for (Map.Entry<String, PluginExecution> entry : recessiveExec.entrySet())
{
PluginExecution pluginExecutionRecessive = entry.getValue();