String selfMergeMode = dominant.getAttribute( SELF_COMBINATION_MODE_ATTRIBUTE ); if ( isEmpty( dominant.getValue() ) ) dominant.setValue( recessive.getValue() ); String[] recessiveAttrs = recessive.getAttributeNames(); for ( String attr : recessiveAttrs ) if ( isEmpty( dominant.getAttribute( attr ) ) ) dominant.setAttribute( attr, recessive.getAttribute( attr ) ); if ( recessive.getChildCount() > 0 ) String childMergeMode = dominant.getAttribute( CHILDREN_COMBINATION_MODE_ATTRIBUTE ); Xpp3Dom[] dominantChildren = dominant.getChildren(); for ( int i = 0, recessiveChildCount = recessive.getChildCount(); i < recessiveChildCount; i++ ) Xpp3Dom recessiveChild = recessive.getChild( i ); dominant.addChild( new Xpp3Dom( recessiveChild ) ); dominant.addChild( aDominantChildren ); Xpp3Dom[] dominantChildren = dominant.getChildren( childName ); if ( dominantChildren.length > 0 )
/** * 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 ); }
protected static Properties toProperties( final Xpp3Dom dom ) { final Properties props = new Properties(); final Xpp3Dom[] children = dom.getChildren(); for ( final Xpp3Dom child : children ) props.put( child.getName(), child.getValue() ); return props; }
private static String checkConfiguration(MavenProject prj, Object conf, String property) { if (conf != null && conf instanceof Xpp3Dom) { Xpp3Dom dom = (Xpp3Dom)conf; Xpp3Dom source = dom.getChild(property); if (source != null) { NBPluginParameterExpressionEvaluator eval = new NBPluginParameterExpressionEvaluator(prj, EmbedderFactory.getProjectEmbedder().getSettings(), new Properties()); try { Object evaluated = eval.evaluate(source.getValue().trim()); return evaluated != null ? ("" + evaluated) : source.getValue().trim(); } catch (ExpressionEvaluationException ex) { Exceptions.printStackTrace(ex); } return source.getValue().trim(); } } return null; }
protected Xpp3Dom getGlobalConfig() { Xpp3Dom config = new Xpp3Dom("configuration"); Xpp3Dom properties = new Xpp3Dom("properties"); config.addChild(properties); for (String name : this.properties.stringPropertyNames()) { Xpp3Dom prop = new Xpp3Dom(name); prop.setValue(this.properties.getProperty(name)); properties.addChild(prop); } Xpp3Dom environment = new Xpp3Dom("environment"); config.addChild(environment); for (String name : this.environment.stringPropertyNames()) { Xpp3Dom env = new Xpp3Dom(name); env.setValue(this.environment.getProperty(name)); environment.addChild(env); } return config; }
protected void buildConfiguration( Xpp3Dom configuration, org.apache.maven.model.v3_0_0.Model v3Model, Properties projectProperties ) throws ProjectConverterException { final String propertyName = "maven.tasklist.taskTag"; String value = projectProperties.getProperty( propertyName ); if ( StringUtils.isNotEmpty( value ) ) { Xpp3Dom tags = new Xpp3Dom( "tags" ); addConfigurationChild( tags, projectProperties, propertyName, "tag" ); configuration.addChild( tags ); } } }
for ( Entry<Object, Object> provide : provides.entrySet() ) Xpp3Dom javahome = dom.getChild( JavaToolchainImpl.KEY_JAVAHOME ); if ( javahome == null ) + JavaToolchainImpl.KEY_JAVAHOME + " configuration element." ); File normal = new File( FileUtils.normalize( javahome.getValue() ) ); if ( normal.exists() ) jtc.setJavaHome( FileUtils.normalize( javahome.getValue() ) );
private String getSourceVersion(BuildBase build) { for (Plugin plugin : build.getPlugins()) { if (!"maven-compiler-plugin".equals(plugin.getArtifactId())) { continue; } Xpp3Dom configuration = (Xpp3Dom) plugin.getConfiguration(); if (configuration != null) { Xpp3Dom source = configuration.getChild("source"); if (source != null) { return source.getValue(); } } break; } return null; }
String selfMergeMode = dominant.getAttribute( SELF_COMBINATION_MODE_ATTRIBUTE ); if ( isEmpty( dominant.getValue() ) ) dominant.setValue( recessive.getValue() ); String[] recessiveAttrs = recessive.getAttributeNames(); for ( String attr : recessiveAttrs ) if ( isEmpty( dominant.getAttribute( attr ) ) ) dominant.setAttribute( attr, recessive.getAttribute( attr ) ); String childMergeMode = dominant.getAttribute( CHILDREN_COMBINATION_MODE_ATTRIBUTE ); Xpp3Dom[] children = recessive.getChildren(); for ( Xpp3Dom recessiveChild : children ) String idValue = recessiveChild.getAttribute( ID_COMBINATION_MODE_ATTRIBUTE ); for ( Xpp3Dom dominantChild : dominant.getChildren() ) if ( idValue.equals( dominantChild.getAttribute( ID_COMBINATION_MODE_ATTRIBUTE ) ) ) childDom = dominant.getChild( recessiveChild.getName() ); dominant.addChild( new Xpp3Dom( recessiveChild ) );
/** * 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 ) ) ); } }
public XmlPlexusConfiguration( Xpp3Dom dom ) { super( dom.getName(), dom.getValue() ); // attrs String[] attributes = dom.getAttributeNames(); for (String attribute : attributes) { setAttribute(attribute, dom.getAttribute(attribute)); } // children int childCount = dom.getChildCount(); for ( int i = 0; i < childCount; i++ ) { addChild( new XmlPlexusConfiguration( dom.getChild( i ) ) ); } }
build.setPlugins(plugins); Optional<Plugin> pluginOptional = plugins.stream().filter(plugin -> plugin.getGroupId().equals(MULE_MAVEN_PLUGIN_GROUP_ID) && plugin.getArtifactId().equals(MULE_MAVEN_PLUGIN_ARTIFACT_ID)).findFirst(); List<Plugin> finalPlugins = plugins; Plugin plugin = pluginOptional.orElseGet(() -> { Plugin muleMavenPlugin = new Plugin(); muleMavenPlugin.setGroupId(MULE_MAVEN_PLUGIN_GROUP_ID); muleMavenPlugin.setArtifactId(MULE_MAVEN_PLUGIN_ARTIFACT_ID); Xpp3Dom configuration = (Xpp3Dom) plugin.getConfiguration(); if (configuration == null) { configuration = new Xpp3Dom("configuration"); plugin.setConfiguration(configuration); Xpp3Dom sharedLibrariesDom = configuration.getChild(SHARED_LIBRARIES_ELEMENT); if (sharedLibrariesDom == null) { sharedLibrariesDom = new Xpp3Dom(SHARED_LIBRARIES_ELEMENT); configuration.addChild(sharedLibrariesDom); Xpp3Dom sharedLibraryDom = new Xpp3Dom("sharedLibrary"); sharedLibrariesDom.addChild(sharedLibraryDom); Xpp3Dom groupIdDom = new Xpp3Dom("groupId"); groupIdDom.setValue(dependency.getGroupId()); sharedLibraryDom.addChild(groupIdDom); Xpp3Dom artifactIdDom = new Xpp3Dom("artifactId"); artifactIdDom.setValue(dependency.getArtifactId()); sharedLibraryDom.addChild(artifactIdDom);
public static String getPluginConfigParameter ( MavenProject project, String parameter, String defaultValue ) { String value = null; for ( Plugin plugin : project.getBuild().getPlugins() ) { if ( plugin.getArtifactId().equals( PluginInfo.getArtifactId() ) ) { Xpp3Dom configuration = getMojoConfiguration( plugin ); if ( configuration != null && configuration.getChild( parameter ) != null ) { value = configuration.getChild( parameter ).getValue() ; } } } // if we got nothing, fall back to the default value return ( StringUtils.isEmpty( value ) ) ? defaultValue : value; }
if ( getBuildPlugins() != null ) for ( Plugin plugin : getBuildPlugins() ) if ( pluginGroupId.equals( plugin.getGroupId() ) && pluginArtifactId.equals( plugin.getArtifactId() ) ) dom = (Xpp3Dom) plugin.getConfiguration(); dom = (Xpp3Dom) execution.getConfiguration(); dom = new Xpp3Dom( dom );
Plugin plugin = new Plugin(); plugin.setGroupId( gs.groupId ); plugin.setArtifactId( gs.artifactId ); plugin.setVersion( gs.version ); PluginExecution execution = new PluginExecution(); execution.setId( getExecutionId( plugin, gs.goal ) ); execution.setPhase( phase ); execution.setPriority( i - mojos.size() ); execution.getGoals().add( gs.goal ); if ( lifecycleConfiguration != null ) execution.setConfiguration( new Xpp3Dom( lifecycleConfiguration ) );
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; }
private String getLayout(MavenProject p) { Plugin plugin = p.getPlugin("com.github.pms1.tppt:tppt-maven-plugin"); Xpp3Dom configuration = (Xpp3Dom) plugin.getConfiguration(); Xpp3Dom layout = configuration != null ? configuration.getChild("layout") : null; if (layout == null) return "@{artifactId}-@{version}-@{timestamp}"; else return layout.getValue(); }
public static void write( XMLWriter xmlWriter, Xpp3Dom dom, boolean escape ) { // TODO: move to XMLWriter? xmlWriter.startElement( dom.getName() ); String[] attributeNames = dom.getAttributeNames(); for ( String attributeName : attributeNames ) { xmlWriter.addAttribute( attributeName, dom.getAttribute( attributeName ) ); } Xpp3Dom[] children = dom.getChildren(); for ( Xpp3Dom aChildren : children ) { write( xmlWriter, aChildren, escape ); } String value = dom.getValue(); if ( value != null ) { if ( escape ) { xmlWriter.writeText( value ); } else { xmlWriter.writeMarkup( value ); } } xmlWriter.endElement(); }