public static Object cloneConfiguration( Object configuration ) { if ( configuration == null ) { return null; } return new Xpp3Dom( (Xpp3Dom) configuration ); }
private Xpp3Dom newDom( String name, String value ) { Xpp3Dom dom = new Xpp3Dom( name ); dom.setValue( value ); return dom; }
/** * Merge two DOMs. Copy the dominant DOM so the original one is left unchanged. * <p> * Use this method instead of a direct call to {@link Xpp3Dom#mergeXpp3Dom(Xpp3Dom, Xpp3Dom)}. * Profiles are dominant, thus they are merge targets, but they may be merged in several times * (e.g. if they are inherited). So with the second merge, you don't get the profile's original * DOM, but an already merged one. * * @param dominant Dominant DOM * @param recessive Recessive DOM * @return Merged DOM */ private Xpp3Dom merge( Xpp3Dom dominant, Xpp3Dom recessive ) { Xpp3Dom dominantCopy = ( dominant == null ) ? null : new Xpp3Dom( dominant ); return Xpp3Dom.mergeXpp3Dom( dominantCopy, recessive ); }
/** * Method clone. * * @return ConfigurationContainer */ public ConfigurationContainer clone() { try { ConfigurationContainer copy = (ConfigurationContainer) super.clone(); if ( this.configuration != null ) { copy.configuration = new org.codehaus.plexus.util.xml.Xpp3Dom( (org.codehaus.plexus.util.xml.Xpp3Dom) this.configuration ); } if ( copy.locations != null ) { copy.locations = new java.util.LinkedHashMap( copy.locations ); } return copy; } catch ( java.lang.Exception ex ) { throw (java.lang.RuntimeException) new java.lang.UnsupportedOperationException( getClass().getName() + " does not support clone()" ).initCause( ex ); } } //-- ConfigurationContainer clone()
/** * Method clone. * * @return Server */ public Server clone() { try { Server copy = (Server) super.clone(); if ( this.configuration != null ) { copy.configuration = new org.codehaus.plexus.util.xml.Xpp3Dom( (org.codehaus.plexus.util.xml.Xpp3Dom) this.configuration ); } return copy; } catch ( java.lang.Exception ex ) { throw (java.lang.RuntimeException) new java.lang.UnsupportedOperationException( getClass().getName() + " does not support clone()" ).initCause( ex ); } } //-- Server clone()
/** * Method clone. * * @return ToolchainModel */ public ToolchainModel clone() { try { ToolchainModel copy = (ToolchainModel) super.clone(); if ( this.provides != null ) { copy.provides = (java.util.Properties) this.provides.clone(); } if ( this.configuration != null ) { copy.configuration = new org.codehaus.plexus.util.xml.Xpp3Dom( (org.codehaus.plexus.util.xml.Xpp3Dom) this.configuration ); } return copy; } catch ( java.lang.Exception ex ) { throw (java.lang.RuntimeException) new java.lang.UnsupportedOperationException( getClass().getName() + " does not support clone()" ).initCause( ex ); } } //-- ToolchainModel clone()
copy.goals = new org.codehaus.plexus.util.xml.Xpp3Dom( (org.codehaus.plexus.util.xml.Xpp3Dom) this.goals );
private Xpp3Dom convert( ReportSet reportSet ) { Xpp3Dom dom = new Xpp3Dom( "reportSet" ); addDom( dom, "id", reportSet.getId() ); Xpp3Dom configuration = (Xpp3Dom) reportSet.getConfiguration(); if ( configuration != null ) { configuration = new Xpp3Dom( configuration ); dom.addChild( configuration ); } if ( !reportSet.getReports().isEmpty() ) { Xpp3Dom reports = new Xpp3Dom( "reports" ); for ( String report : reportSet.getReports() ) { addDom( reports, "report", report ); } dom.addChild( reports ); } return dom; }
dom = new Xpp3Dom( dom );
/** * Copy constructor with alternative name. */ public Xpp3Dom( Xpp3Dom src, String name ) { this.name = name; int childCount = src.getChildCount(); childList = new ArrayList<Xpp3Dom>( childCount ); childMap = new HashMap<String, Xpp3Dom>( childCount << 1 ); setValue( src.getValue() ); String[] attributeNames = src.getAttributeNames(); for ( String attributeName : attributeNames ) { setAttribute( attributeName, src.getAttribute( attributeName ) ); } for ( int i = 0; i < childCount; i++ ) { addChild( new Xpp3Dom( src.getChild( i ) ) ); } }
private Xpp3Dom convert( ReportPlugin plugin ) { Xpp3Dom dom = new Xpp3Dom( "reportPlugin" ); addDom( dom, "groupId", plugin.getGroupId() ); addDom( dom, "artifactId", plugin.getArtifactId() ); addDom( dom, "version", plugin.getVersion() ); Xpp3Dom configuration = (Xpp3Dom) plugin.getConfiguration(); if ( configuration != null ) { configuration = new Xpp3Dom( configuration ); dom.addChild( configuration ); } if ( !plugin.getReportSets().isEmpty() ) { Xpp3Dom reportSets = new Xpp3Dom( "reportSets" ); for ( ReportSet reportSet : plugin.getReportSets() ) { Xpp3Dom rs = convert( reportSet ); reportSets.addChild( rs ); } dom.addChild( reportSets ); } return dom; }
public static Xpp3Dom convert( MojoDescriptor mojoDescriptor ) { Xpp3Dom dom = new Xpp3Dom( "configuration" ); PlexusConfiguration c = mojoDescriptor.getMojoConfiguration(); PlexusConfiguration[] ces = c.getChildren(); if ( ces != null ) { for ( PlexusConfiguration ce : ces ) { String value = ce.getValue( null ); String defaultValue = ce.getAttribute( "default-value", null ); if ( value != null || defaultValue != null ) { Xpp3Dom e = new Xpp3Dom( ce.getName() ); e.setValue( value ); if ( defaultValue != null ) { e.setAttribute( "default-value", defaultValue ); } dom.addChild( e ); } } } return dom; }
private void expand( List<Plugin> plugins ) { for ( Plugin plugin : plugins ) { Xpp3Dom pluginConfiguration = (Xpp3Dom) plugin.getConfiguration(); if ( pluginConfiguration != null ) { for ( PluginExecution execution : plugin.getExecutions() ) { Xpp3Dom executionConfiguration = (Xpp3Dom) execution.getConfiguration(); executionConfiguration = Xpp3Dom.mergeXpp3Dom( executionConfiguration, new Xpp3Dom( pluginConfiguration ) ); execution.setConfiguration( executionConfiguration ); } } } }
protected void mergeToolchainModelConfiguration( ToolchainModel target, ToolchainModel source ) { Xpp3Dom src = (Xpp3Dom) source.getConfiguration(); if ( src != null ) { Xpp3Dom tgt = (Xpp3Dom) target.getConfiguration(); if ( tgt == null ) { tgt = Xpp3Dom.mergeXpp3Dom( new Xpp3Dom( src ), tgt ); } else { tgt = Xpp3Dom.mergeXpp3Dom( tgt, src ); } target.setConfiguration( tgt ); } }
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 ); } }
@Override public void expandPluginConfiguration( Model model, ModelBuildingRequest request, ModelProblemCollector problems ) { Reporting reporting = model.getReporting(); if ( reporting != null ) { for ( ReportPlugin reportPlugin : reporting.getPlugins() ) { Xpp3Dom parentDom = (Xpp3Dom) reportPlugin.getConfiguration(); if ( parentDom != null ) { for ( ReportSet execution : reportPlugin.getReportSets() ) { Xpp3Dom childDom = (Xpp3Dom) execution.getConfiguration(); childDom = Xpp3Dom.mergeXpp3Dom( childDom, new Xpp3Dom( parentDom ) ); execution.setConfiguration( childDom ); } } } } }
private Xpp3Dom toXpp3Dom(PlexusConfiguration config) { Xpp3Dom result = new Xpp3Dom(config.getName()); result.setValue(config.getValue(null)); for (String name : config.getAttributeNames()) { result.setAttribute(name, config.getAttribute(name)); } for (PlexusConfiguration child : config.getChildren()) { result.addChild(toXpp3Dom(child)); } return result; }
@Override public void configure( MavenProject project, MojoExecution mojoExecution, boolean allowPluginLevelConfig ) { String g = mojoExecution.getGroupId(); String a = mojoExecution.getArtifactId(); Plugin plugin = findPlugin( g, a, project.getBuildPlugins() ); if ( plugin == null && project.getPluginManagement() != null ) { plugin = findPlugin( g, a, project.getPluginManagement().getPlugins() ); } if ( plugin != null ) { PluginExecution pluginExecution = findPluginExecution( mojoExecution.getExecutionId(), plugin.getExecutions() ); Xpp3Dom pomConfiguration = null; if ( pluginExecution != null ) { pomConfiguration = (Xpp3Dom) pluginExecution.getConfiguration(); } else if ( allowPluginLevelConfig ) { pomConfiguration = (Xpp3Dom) plugin.getConfiguration(); } Xpp3Dom mojoConfiguration = ( pomConfiguration != null ) ? new Xpp3Dom( pomConfiguration ) : null; mojoConfiguration = Xpp3Dom.mergeXpp3Dom( mojoExecution.getConfiguration(), mojoConfiguration ); mojoExecution.setConfiguration( mojoConfiguration ); } }