Java Code Examples for org.codehaus.plexus.configuration.PlexusConfiguration#getChildren()
The following examples show how to use
org.codehaus.plexus.configuration.PlexusConfiguration#getChildren() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: OptionallyConfigurableComponentConverter.java From jdmn with Apache License 2.0 | 6 votes |
@SuppressWarnings("unchecked") private Map<String, Object> generateConfigurationMap(PlexusConfiguration configuration) { Map<String, Object> node = new HashMap<>(); for (PlexusConfiguration child : configuration.getChildren()) { // Expand node to a list where duplicate keys exist Object existingNode = node.get(child.getName()); if (existingNode != null) { if (!(existingNode instanceof List)) { List<Object> listNode = new ArrayList<>(); listNode.add(existingNode); node.put(child.getName(), listNode); } List<Object> target = ((List)node.get(child.getName())); target.add(generateChildNode(child)); } else { node.put(child.getName(), generateChildNode(child)); } } return node; }
Example 2
Source File: MojoExecutionService.java From jkube with Eclipse Public License 2.0 | 5 votes |
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; }
Example 3
Source File: AppengineEnhancerMojo.java From appengine-maven-plugin with Apache License 2.0 | 5 votes |
private Xpp3Dom convertPlexusConfiguration(PlexusConfiguration config) { Xpp3Dom xpp3DomElement = new Xpp3Dom(config.getName()); xpp3DomElement.setValue(config.getValue()); for (String name : config.getAttributeNames()) { xpp3DomElement.setAttribute(name, config.getAttribute(name)); } for (PlexusConfiguration child : config.getChildren()) { xpp3DomElement.addChild(convertPlexusConfiguration(child)); } return xpp3DomElement; }
Example 4
Source File: MavenHelper.java From sarl with Apache License 2.0 | 5 votes |
/** Convert a Plexus configuration to its XML equivalent. * * @param config the Plexus configuration. * @return the XML configuration. * @throws PlexusConfigurationException in case of problem. * @since 0.8 */ public Xpp3Dom toXpp3Dom(PlexusConfiguration config) throws PlexusConfigurationException { final Xpp3Dom result = new Xpp3Dom(config.getName()); result.setValue(config.getValue(null)); for (final String name : config.getAttributeNames()) { result.setAttribute(name, config.getAttribute(name)); } for (final PlexusConfiguration child : config.getChildren()) { result.addChild(toXpp3Dom(child)); } return result; }
Example 5
Source File: XmlUtil.java From revapi with Apache License 2.0 | 5 votes |
static void toIndentedString(PlexusConfiguration xml, int indentationSize, int currentDepth, Writer wrt) throws IOException { indent(indentationSize, currentDepth, wrt); boolean hasChildren = xml.getChildCount() > 0; boolean hasContent = xml.getValue() != null && !xml.getValue().isEmpty(); wrt.write('<'); wrt.write(xml.getName()); if (!hasChildren && !hasContent) { wrt.write("/>"); } else { wrt.write('>'); if (hasChildren) { wrt.write('\n'); for (PlexusConfiguration c : xml.getChildren()) { toIndentedString(c, indentationSize, currentDepth + 1, wrt); wrt.append('\n'); } if (!hasContent) { indent(indentationSize, currentDepth, wrt); } } if (hasContent) { escaped(wrt, xml.getValue()); } wrt.write("</"); wrt.write(xml.getName()); wrt.write('>'); } }
Example 6
Source File: Analyzer.java From revapi with Apache License 2.0 | 5 votes |
private PipelineConfiguration.Builder parsePipelineConfigurationXML() { PipelineConfiguration.Builder bld = PipelineConfiguration.builder(); if (pipelineConfiguration == null) { return bld; } for (PlexusConfiguration c : pipelineConfiguration.getChildren()) { switch (c.getName()) { case "analyzers": parseIncludeExclude(c, bld::addAnalyzerExtensionIdInclude, bld::addAnalyzerExtensionIdExclude); break; case "reporters": parseIncludeExclude(c, bld::addReporterExtensionIdInclude, bld::addReporterExtensionIdExclude); break; case "filters": parseIncludeExclude(c, bld::addFilterExtensionIdInclude, bld::addFilterExtensionIdExclude); break; case "transforms": parseIncludeExclude(c, bld::addTransformExtensionIdInclude, bld::addTransformExtensionIdExclude); break; case "transformBlocks": for (PlexusConfiguration b : c.getChildren()) { List<String> blockIds = Stream.of(b.getChildren()) .map(PlexusConfiguration::getValue).collect(toList()); bld.addTransformationBlock(blockIds); } break; } } return bld; }
Example 7
Source File: AppengineEnhancerMojo.java From gcloud-maven-plugin with Apache License 2.0 | 5 votes |
private Xpp3Dom convertPlexusConfiguration(PlexusConfiguration config) { Xpp3Dom xpp3DomElement = new Xpp3Dom(config.getName()); xpp3DomElement.setValue(config.getValue()); for (String name : config.getAttributeNames()) { xpp3DomElement.setAttribute(name, config.getAttribute(name)); } for (PlexusConfiguration child : config.getChildren()) { xpp3DomElement.addChild(convertPlexusConfiguration(child)); } return xpp3DomElement; }
Example 8
Source File: MojoExecutionService.java From docker-maven-plugin with Apache License 2.0 | 5 votes |
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; }
Example 9
Source File: MojoConfigurationProcessor.java From takari-lifecycle with Eclipse Public License 1.0 | 5 votes |
/** * Extract the Mojo specific configuration from the incoming plugin configuration from Maven by looking at an enclosing element with the goal name. Use this and merge it with the default Mojo * configuration and use this to apply values to the Mojo. * * @param goal * @param pluginConfigurationFromMaven * @param defaultMojoConfiguration * @return * @throws ComponentConfigurationException */ PlexusConfiguration extractAndMerge(String goal, PlexusConfiguration pluginConfigurationFromMaven, PlexusConfiguration defaultMojoConfiguration) throws ComponentConfigurationException { // // We need to extract the specific configuration for this goal out of the POM configuration // PlexusConfiguration mojoConfigurationFromPom = new XmlPlexusConfiguration("configuration"); for (PlexusConfiguration element : pluginConfigurationFromMaven.getChildren()) { if (element.getName().equals(goal)) { for (PlexusConfiguration goalConfigurationElements : element.getChildren()) { mojoConfigurationFromPom.addChild(goalConfigurationElements); } } } return new XmlPlexusConfiguration(Xpp3Dom.mergeXpp3Dom(convert(mojoConfigurationFromPom), convert(defaultMojoConfiguration))); }
Example 10
Source File: IteratorMojo.java From iterator-maven-plugin with Apache License 2.0 | 5 votes |
/** * Taken from MojoExecutor of Don Brown. Converts PlexusConfiguration to a Xpp3Dom. * * @param config the PlexusConfiguration. Must not be {@code null}. * @return the Xpp3Dom representation of the PlexusConfiguration */ public 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; }