protected void mergeConfigurationContainer_Configuration( ConfigurationContainer target, ConfigurationContainer source, boolean sourceDominant, Map<Object, Object> context ) { Xpp3Dom src = (Xpp3Dom) source.getConfiguration(); if ( src != null ) { Xpp3Dom tgt = (Xpp3Dom) target.getConfiguration(); if ( sourceDominant || tgt == null ) { tgt = Xpp3Dom.mergeXpp3Dom( new Xpp3Dom( src ), tgt ); } else { tgt = Xpp3Dom.mergeXpp3Dom( tgt, src ); } target.setConfiguration( tgt ); } }
/** * Method updateConfigurationContainer * * @param value * @param element * @param counter * @param xmlTag */ protected void updateConfigurationContainer( ConfigurationContainer value, String xmlTag, Counter counter, Element element ) { boolean shouldExist = value != null; Element root = updateElement( counter, element, xmlTag, shouldExist ); if ( shouldExist ) { Counter innerCount = new Counter( counter.getDepth() + 1 ); findAndReplaceSimpleElement( innerCount, root, "inherited", value.getInherited(), null ); findAndReplaceXpp3DOM( innerCount, root, "configuration", (Xpp3Dom) value.getConfiguration() ); } }
protected void mergeConfigurationContainer_Inherited( ConfigurationContainer target, ConfigurationContainer source, boolean sourceDominant, Map<Object, Object> context ) { String src = source.getInherited(); if ( src != null ) { if ( sourceDominant || target.getInherited() == null ) { target.setInherited( src ); target.setLocation( "inherited", source.getLocation( "inherited" ) ); } } }
/** * Go through the plugin / plugin-execution configurations and find references to the <code>skip</code> parameter for the given Maven plugin * instance. */ private List<SkipReference> findSkipRefs( final Plugin plugin, final Project project ) throws ManipulationException { if ( plugin == null ) { return Collections.emptyList(); } final Map<ConfigurationContainer, String> configs = new LinkedHashMap<>(); Object configuration = plugin.getConfiguration(); if ( configuration != null ) { configs.put( plugin, configuration.toString() ); } final List<PluginExecution> executions = plugin.getExecutions(); if ( executions != null ) { for ( final PluginExecution execution : executions ) { configuration = execution.getConfiguration(); if ( configuration != null ) { configs.put( execution, configuration.toString() ); } } } final List<SkipReference> result = new ArrayList<>(); for ( final Map.Entry<ConfigurationContainer, String> entry : configs.entrySet() ) { try { final Document doc = galleyWrapper.parseXml( entry.getValue() ); final NodeList children = doc.getDocumentElement() .getChildNodes(); if ( children != null ) { for ( int i = 0; i < children.getLength(); i++ ) { final Node n = children.item( i ); if ( n.getNodeName() .equals( SKIP_NODE ) ) { result.add( new SkipReference( entry.getKey(), n ) ); } } } } catch ( final GalleyMavenXMLException e ) { throw new ManipulationException( "Unable to parse config for plugin: %s in: %s", e, plugin.getId(), project.getId() ); } } return result; }
public SkipReference( final ConfigurationContainer container, final Node node ) { this.container = container; this.node = node; }
public ConfigurationContainer getContainer() { return container; }
protected void mergeConfigurationContainer( ConfigurationContainer target, ConfigurationContainer source, boolean sourceDominant, Map<Object, Object> context ) { mergeConfigurationContainer_Inherited( target, source, sourceDominant, context ); mergeConfigurationContainer_Configuration( target, source, sourceDominant, context ); }