mirror of https://github.com/apache/maven.git
[MNG-7660] Rename Dom to XmlNode in the v4 api (#946)
* Rename Dom to XmlNode and Xpp3Dom to XmlNodeImpl * Use XmlNodeBuilder instead of DomBuilder
This commit is contained in:
parent
7b00069388
commit
a00a44f75b
|
@ -23,7 +23,7 @@ import java.util.Optional;
|
||||||
import org.apache.maven.api.annotations.Experimental;
|
import org.apache.maven.api.annotations.Experimental;
|
||||||
import org.apache.maven.api.annotations.Nonnull;
|
import org.apache.maven.api.annotations.Nonnull;
|
||||||
import org.apache.maven.api.model.Plugin;
|
import org.apache.maven.api.model.Plugin;
|
||||||
import org.apache.maven.api.xml.Dom;
|
import org.apache.maven.api.xml.XmlNode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A {@code MojoExecution}
|
* A {@code MojoExecution}
|
||||||
|
@ -40,5 +40,5 @@ public interface MojoExecution {
|
||||||
String getGoal();
|
String getGoal();
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
Optional<Dom> getConfiguration();
|
Optional<XmlNode> getConfiguration();
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,8 +55,8 @@
|
||||||
#set ( $dummy = $imports.add( "java.util.Map" ) )
|
#set ( $dummy = $imports.add( "java.util.Map" ) )
|
||||||
#set ( $dummy = $types.put( $field, "Map<String, String>" ) )
|
#set ( $dummy = $types.put( $field, "Map<String, String>" ) )
|
||||||
#elseif ( $field.type == "DOM" )
|
#elseif ( $field.type == "DOM" )
|
||||||
#set ( $dummy = $imports.add( "org.apache.maven.api.xml.Dom" ) )
|
#set ( $dummy = $imports.add( "org.apache.maven.api.xml.XmlNode" ) )
|
||||||
#set ( $dummy = $types.put( $field, "Dom" ) )
|
#set ( $dummy = $types.put( $field, "XmlNode" ) )
|
||||||
#else
|
#else
|
||||||
#set ( $fieldType = ${types.getOrDefault($field.type,$field.type)} )
|
#set ( $fieldType = ${types.getOrDefault($field.type,$field.type)} )
|
||||||
#set ( $idx = $fieldType.lastIndexOf('.') )
|
#set ( $idx = $fieldType.lastIndexOf('.') )
|
||||||
|
|
|
@ -55,8 +55,8 @@
|
||||||
#set ( $dummy = $imports.add( "java.util.Map" ) )
|
#set ( $dummy = $imports.add( "java.util.Map" ) )
|
||||||
#set ( $dummy = $types.put( $field, "Map<String, String>" ) )
|
#set ( $dummy = $types.put( $field, "Map<String, String>" ) )
|
||||||
#elseif ( $field.type == "DOM" )
|
#elseif ( $field.type == "DOM" )
|
||||||
#set ( $dummy = $imports.add( "org.apache.maven.api.xml.Dom" ) )
|
#set ( $dummy = $imports.add( "org.apache.maven.api.xml.XmlNode" ) )
|
||||||
#set ( $dummy = $types.put( $field, "Dom" ) )
|
#set ( $dummy = $types.put( $field, "XmlNode" ) )
|
||||||
#else
|
#else
|
||||||
#set ( $fieldType = ${types.getOrDefault($field.type,$field.type)} )
|
#set ( $fieldType = ${types.getOrDefault($field.type,$field.type)} )
|
||||||
#set ( $idx = $fieldType.lastIndexOf('.') )
|
#set ( $idx = $fieldType.lastIndexOf('.') )
|
||||||
|
|
|
@ -55,8 +55,8 @@
|
||||||
#set ( $dummy = $imports.add( "java.util.Map" ) )
|
#set ( $dummy = $imports.add( "java.util.Map" ) )
|
||||||
#set ( $dummy = $types.put( $field, "Map<String, String>" ) )
|
#set ( $dummy = $types.put( $field, "Map<String, String>" ) )
|
||||||
#elseif ( $field.type == "DOM" )
|
#elseif ( $field.type == "DOM" )
|
||||||
#set ( $dummy = $imports.add( "org.apache.maven.api.xml.Dom" ) )
|
#set ( $dummy = $imports.add( "org.apache.maven.api.xml.XmlNode" ) )
|
||||||
#set ( $dummy = $types.put( $field, "Dom" ) )
|
#set ( $dummy = $types.put( $field, "XmlNode" ) )
|
||||||
#else
|
#else
|
||||||
#set ( $fieldType = ${types.getOrDefault($field.type,$field.type)} )
|
#set ( $fieldType = ${types.getOrDefault($field.type,$field.type)} )
|
||||||
#set ( $idx = $fieldType.lastIndexOf('.') )
|
#set ( $idx = $fieldType.lastIndexOf('.') )
|
||||||
|
|
|
@ -35,7 +35,7 @@ import org.apache.maven.api.annotations.ThreadSafe;
|
||||||
@Experimental
|
@Experimental
|
||||||
@ThreadSafe
|
@ThreadSafe
|
||||||
@Immutable
|
@Immutable
|
||||||
public interface Dom {
|
public interface XmlNode {
|
||||||
|
|
||||||
String CHILDREN_COMBINATION_MODE_ATTRIBUTE = "combine.children";
|
String CHILDREN_COMBINATION_MODE_ATTRIBUTE = "combine.children";
|
||||||
|
|
||||||
|
@ -90,21 +90,21 @@ public interface Dom {
|
||||||
String getAttribute(@Nonnull String name);
|
String getAttribute(@Nonnull String name);
|
||||||
|
|
||||||
@Nonnull
|
@Nonnull
|
||||||
List<Dom> getChildren();
|
List<XmlNode> getChildren();
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
Dom getChild(String name);
|
XmlNode getChild(String name);
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
Object getInputLocation();
|
Object getInputLocation();
|
||||||
|
|
||||||
default Dom merge(@Nullable Dom source) {
|
default XmlNode merge(@Nullable XmlNode source) {
|
||||||
return merge(source, (Boolean) null);
|
return merge(source, (Boolean) null);
|
||||||
}
|
}
|
||||||
|
|
||||||
Dom merge(@Nullable Dom source, @Nullable Boolean childMergeOverride);
|
XmlNode merge(@Nullable XmlNode source, @Nullable Boolean childMergeOverride);
|
||||||
|
|
||||||
Dom clone();
|
XmlNode clone();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Merge recessive into dominant and return either {@code dominant}
|
* Merge recessive into dominant and return either {@code dominant}
|
||||||
|
@ -116,12 +116,13 @@ public interface Dom {
|
||||||
* @return the merged node
|
* @return the merged node
|
||||||
*/
|
*/
|
||||||
@Nullable
|
@Nullable
|
||||||
static Dom merge(@Nullable Dom dominant, @Nullable Dom recessive) {
|
static XmlNode merge(@Nullable XmlNode dominant, @Nullable XmlNode recessive) {
|
||||||
return merge(dominant, recessive, null);
|
return merge(dominant, recessive, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
static Dom merge(@Nullable Dom dominant, @Nullable Dom recessive, @Nullable Boolean childMergeOverride) {
|
static XmlNode merge(
|
||||||
|
@Nullable XmlNode dominant, @Nullable XmlNode recessive, @Nullable Boolean childMergeOverride) {
|
||||||
if (recessive == null) {
|
if (recessive == null) {
|
||||||
return dominant;
|
return dominant;
|
||||||
}
|
}
|
|
@ -36,14 +36,14 @@ import java.util.Map;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.apache.maven.RepositoryUtils;
|
import org.apache.maven.RepositoryUtils;
|
||||||
import org.apache.maven.api.xml.Dom;
|
import org.apache.maven.api.xml.XmlNode;
|
||||||
import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager;
|
import org.apache.maven.artifact.handler.manager.ArtifactHandlerManager;
|
||||||
import org.apache.maven.bridge.MavenRepositorySystem;
|
import org.apache.maven.bridge.MavenRepositorySystem;
|
||||||
import org.apache.maven.eventspy.internal.EventSpyDispatcher;
|
import org.apache.maven.eventspy.internal.EventSpyDispatcher;
|
||||||
import org.apache.maven.execution.MavenExecutionRequest;
|
import org.apache.maven.execution.MavenExecutionRequest;
|
||||||
import org.apache.maven.feature.Features;
|
import org.apache.maven.feature.Features;
|
||||||
|
import org.apache.maven.internal.xml.XmlNodeImpl;
|
||||||
import org.apache.maven.internal.xml.XmlPlexusConfiguration;
|
import org.apache.maven.internal.xml.XmlPlexusConfiguration;
|
||||||
import org.apache.maven.internal.xml.Xpp3Dom;
|
|
||||||
import org.apache.maven.model.ModelBase;
|
import org.apache.maven.model.ModelBase;
|
||||||
import org.apache.maven.model.building.TransformerContext;
|
import org.apache.maven.model.building.TransformerContext;
|
||||||
import org.apache.maven.repository.internal.MavenRepositorySystemUtils;
|
import org.apache.maven.repository.internal.MavenRepositorySystemUtils;
|
||||||
|
@ -254,11 +254,11 @@ public class DefaultRepositorySystemSessionFactory {
|
||||||
authSelector.add(server.getId(), authBuilder.build());
|
authSelector.add(server.getId(), authBuilder.build());
|
||||||
|
|
||||||
if (server.getConfiguration() != null) {
|
if (server.getConfiguration() != null) {
|
||||||
Dom dom = ((org.codehaus.plexus.util.xml.Xpp3Dom) server.getConfiguration()).getDom();
|
XmlNode dom = ((org.codehaus.plexus.util.xml.Xpp3Dom) server.getConfiguration()).getDom();
|
||||||
List<Dom> children = dom.getChildren().stream()
|
List<XmlNode> children = dom.getChildren().stream()
|
||||||
.filter(c -> !"wagonProvider".equals(c.getName()))
|
.filter(c -> !"wagonProvider".equals(c.getName()))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
dom = new Xpp3Dom(dom.getName(), null, null, children, null);
|
dom = new XmlNodeImpl(dom.getName(), null, null, children, null);
|
||||||
PlexusConfiguration config = XmlPlexusConfiguration.toPlexusConfiguration(dom);
|
PlexusConfiguration config = XmlPlexusConfiguration.toPlexusConfiguration(dom);
|
||||||
configProps.put("aether.connector.wagon.config." + server.getId(), config);
|
configProps.put("aether.connector.wagon.config." + server.getId(), config);
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ import java.util.Optional;
|
||||||
|
|
||||||
import org.apache.maven.api.MojoExecution;
|
import org.apache.maven.api.MojoExecution;
|
||||||
import org.apache.maven.api.model.Plugin;
|
import org.apache.maven.api.model.Plugin;
|
||||||
import org.apache.maven.api.xml.Dom;
|
import org.apache.maven.api.xml.XmlNode;
|
||||||
import org.codehaus.plexus.util.xml.Xpp3Dom;
|
import org.codehaus.plexus.util.xml.Xpp3Dom;
|
||||||
|
|
||||||
public class DefaultMojoExecution implements MojoExecution {
|
public class DefaultMojoExecution implements MojoExecution {
|
||||||
|
@ -52,7 +52,7 @@ public class DefaultMojoExecution implements MojoExecution {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Optional<Dom> getConfiguration() {
|
public Optional<XmlNode> getConfiguration() {
|
||||||
return Optional.of(delegate.getConfiguration()).map(Xpp3Dom::getDom);
|
return Optional.of(delegate.getConfiguration()).map(Xpp3Dom::getDom);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,9 +33,9 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.apache.maven.api.xml.Dom;
|
import org.apache.maven.api.xml.XmlNode;
|
||||||
import org.apache.maven.execution.MavenSession;
|
import org.apache.maven.execution.MavenSession;
|
||||||
import org.apache.maven.internal.xml.Xpp3Dom;
|
import org.apache.maven.internal.xml.XmlNodeImpl;
|
||||||
import org.apache.maven.lifecycle.DefaultLifecycles;
|
import org.apache.maven.lifecycle.DefaultLifecycles;
|
||||||
import org.apache.maven.lifecycle.Lifecycle;
|
import org.apache.maven.lifecycle.Lifecycle;
|
||||||
import org.apache.maven.lifecycle.LifecycleMappingDelegate;
|
import org.apache.maven.lifecycle.LifecycleMappingDelegate;
|
||||||
|
@ -291,23 +291,23 @@ public class DefaultLifecycleExecutionPlanCalculator implements LifecycleExecuti
|
||||||
MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor();
|
MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor();
|
||||||
|
|
||||||
org.codehaus.plexus.util.xml.Xpp3Dom config = mojoExecution.getConfiguration();
|
org.codehaus.plexus.util.xml.Xpp3Dom config = mojoExecution.getConfiguration();
|
||||||
Dom executionConfiguration = config != null ? config.getDom() : null;
|
XmlNode executionConfiguration = config != null ? config.getDom() : null;
|
||||||
if (executionConfiguration == null) {
|
if (executionConfiguration == null) {
|
||||||
executionConfiguration = new Xpp3Dom("configuration");
|
executionConfiguration = new XmlNodeImpl("configuration");
|
||||||
}
|
}
|
||||||
|
|
||||||
Dom defaultConfiguration = getMojoConfiguration(mojoDescriptor);
|
XmlNode defaultConfiguration = getMojoConfiguration(mojoDescriptor);
|
||||||
|
|
||||||
List<Dom> children = new ArrayList<>();
|
List<XmlNode> children = new ArrayList<>();
|
||||||
if (mojoDescriptor.getParameters() != null) {
|
if (mojoDescriptor.getParameters() != null) {
|
||||||
for (Parameter parameter : mojoDescriptor.getParameters()) {
|
for (Parameter parameter : mojoDescriptor.getParameters()) {
|
||||||
Dom parameterConfiguration = executionConfiguration.getChild(parameter.getName());
|
XmlNode parameterConfiguration = executionConfiguration.getChild(parameter.getName());
|
||||||
|
|
||||||
if (parameterConfiguration == null) {
|
if (parameterConfiguration == null) {
|
||||||
parameterConfiguration = executionConfiguration.getChild(parameter.getAlias());
|
parameterConfiguration = executionConfiguration.getChild(parameter.getAlias());
|
||||||
}
|
}
|
||||||
|
|
||||||
Dom parameterDefaults = defaultConfiguration.getChild(parameter.getName());
|
XmlNode parameterDefaults = defaultConfiguration.getChild(parameter.getName());
|
||||||
|
|
||||||
if (parameterConfiguration != null) {
|
if (parameterConfiguration != null) {
|
||||||
parameterConfiguration = parameterConfiguration.merge(parameterDefaults, Boolean.TRUE);
|
parameterConfiguration = parameterConfiguration.merge(parameterDefaults, Boolean.TRUE);
|
||||||
|
@ -323,7 +323,7 @@ public class DefaultLifecycleExecutionPlanCalculator implements LifecycleExecuti
|
||||||
attributes.put("implementation", parameter.getImplementation());
|
attributes.put("implementation", parameter.getImplementation());
|
||||||
}
|
}
|
||||||
|
|
||||||
parameterConfiguration = new Xpp3Dom(
|
parameterConfiguration = new XmlNodeImpl(
|
||||||
parameter.getName(),
|
parameter.getName(),
|
||||||
parameterConfiguration.getValue(),
|
parameterConfiguration.getValue(),
|
||||||
attributes,
|
attributes,
|
||||||
|
@ -334,12 +334,12 @@ public class DefaultLifecycleExecutionPlanCalculator implements LifecycleExecuti
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Dom finalConfiguration = new Xpp3Dom("configuration", null, null, children, null);
|
XmlNode finalConfiguration = new XmlNodeImpl("configuration", null, null, children, null);
|
||||||
|
|
||||||
mojoExecution.setConfiguration(finalConfiguration);
|
mojoExecution.setConfiguration(finalConfiguration);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Dom getMojoConfiguration(MojoDescriptor mojoDescriptor) {
|
private XmlNode getMojoConfiguration(MojoDescriptor mojoDescriptor) {
|
||||||
return MojoDescriptorCreator.convert(mojoDescriptor).getDom();
|
return MojoDescriptorCreator.convert(mojoDescriptor).getDom();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -490,7 +490,7 @@ public class DefaultLifecycleExecutionPlanCalculator implements LifecycleExecuti
|
||||||
MojoExecution forkedExecution =
|
MojoExecution forkedExecution =
|
||||||
new MojoExecution(forkedMojoDescriptor, mojoExecution.getExecutionId());
|
new MojoExecution(forkedMojoDescriptor, mojoExecution.getExecutionId());
|
||||||
|
|
||||||
Xpp3Dom forkedConfiguration = (Xpp3Dom) execution.getConfiguration();
|
XmlNodeImpl forkedConfiguration = (XmlNodeImpl) execution.getConfiguration();
|
||||||
|
|
||||||
forkedExecution.setConfiguration(forkedConfiguration);
|
forkedExecution.setConfiguration(forkedConfiguration);
|
||||||
|
|
||||||
|
@ -500,14 +500,14 @@ public class DefaultLifecycleExecutionPlanCalculator implements LifecycleExecuti
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Xpp3Dom phaseConfiguration = (Xpp3Dom) phase.getConfiguration();
|
XmlNodeImpl phaseConfiguration = (XmlNodeImpl) phase.getConfiguration();
|
||||||
|
|
||||||
if (phaseConfiguration != null) {
|
if (phaseConfiguration != null) {
|
||||||
for (MojoExecution forkedExecution : forkedExecutions) {
|
for (MojoExecution forkedExecution : forkedExecutions) {
|
||||||
org.codehaus.plexus.util.xml.Xpp3Dom config = forkedExecution.getConfiguration();
|
org.codehaus.plexus.util.xml.Xpp3Dom config = forkedExecution.getConfiguration();
|
||||||
|
|
||||||
if (config != null) {
|
if (config != null) {
|
||||||
Dom forkedConfiguration = config.getDom();
|
XmlNode forkedConfiguration = config.getDom();
|
||||||
|
|
||||||
forkedConfiguration = phaseConfiguration.merge(forkedConfiguration);
|
forkedConfiguration = phaseConfiguration.merge(forkedConfiguration);
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ import java.util.Map;
|
||||||
import java.util.NoSuchElementException;
|
import java.util.NoSuchElementException;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.apache.maven.api.xml.Dom;
|
import org.apache.maven.api.xml.XmlNode;
|
||||||
import org.apache.maven.lifecycle.DefaultLifecycles;
|
import org.apache.maven.lifecycle.DefaultLifecycles;
|
||||||
import org.apache.maven.lifecycle.LifeCyclePluginAnalyzer;
|
import org.apache.maven.lifecycle.LifeCyclePluginAnalyzer;
|
||||||
import org.apache.maven.lifecycle.Lifecycle;
|
import org.apache.maven.lifecycle.Lifecycle;
|
||||||
|
@ -196,7 +196,7 @@ public class DefaultLifecyclePluginAnalyzer implements LifeCyclePluginAnalyzer {
|
||||||
execution.setLocation("phase", location);
|
execution.setLocation("phase", location);
|
||||||
execution.setLocation("goals", location);
|
execution.setLocation("goals", location);
|
||||||
|
|
||||||
Dom lifecycleConfiguration = mojo.getConfiguration();
|
XmlNode lifecycleConfiguration = mojo.getConfiguration();
|
||||||
if (lifecycleConfiguration != null) {
|
if (lifecycleConfiguration != null) {
|
||||||
execution.setConfiguration(new Xpp3Dom(lifecycleConfiguration));
|
execution.setConfiguration(new Xpp3Dom(lifecycleConfiguration));
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,8 +26,8 @@ import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import org.apache.maven.api.xml.Dom;
|
import org.apache.maven.api.xml.XmlNode;
|
||||||
import org.apache.maven.internal.xml.Xpp3Dom;
|
import org.apache.maven.internal.xml.XmlNodeImpl;
|
||||||
import org.apache.maven.lifecycle.MojoExecutionConfigurator;
|
import org.apache.maven.lifecycle.MojoExecutionConfigurator;
|
||||||
import org.apache.maven.model.Plugin;
|
import org.apache.maven.model.Plugin;
|
||||||
import org.apache.maven.model.PluginExecution;
|
import org.apache.maven.model.PluginExecution;
|
||||||
|
@ -67,7 +67,7 @@ public class DefaultMojoExecutionConfigurator implements MojoExecutionConfigurat
|
||||||
PluginExecution pluginExecution =
|
PluginExecution pluginExecution =
|
||||||
findPluginExecution(mojoExecution.getExecutionId(), plugin.getExecutions());
|
findPluginExecution(mojoExecution.getExecutionId(), plugin.getExecutions());
|
||||||
|
|
||||||
Dom pomConfiguration = null;
|
XmlNode pomConfiguration = null;
|
||||||
|
|
||||||
if (pluginExecution != null) {
|
if (pluginExecution != null) {
|
||||||
pomConfiguration = pluginExecution.getDelegate().getConfiguration();
|
pomConfiguration = pluginExecution.getDelegate().getConfiguration();
|
||||||
|
@ -75,11 +75,11 @@ public class DefaultMojoExecutionConfigurator implements MojoExecutionConfigurat
|
||||||
pomConfiguration = plugin.getDelegate().getConfiguration();
|
pomConfiguration = plugin.getDelegate().getConfiguration();
|
||||||
}
|
}
|
||||||
|
|
||||||
Dom mojoConfiguration = mojoExecution.getConfiguration() != null
|
XmlNode mojoConfiguration = mojoExecution.getConfiguration() != null
|
||||||
? mojoExecution.getConfiguration().getDom()
|
? mojoExecution.getConfiguration().getDom()
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
Dom mergedConfiguration = Xpp3Dom.merge(mojoConfiguration, pomConfiguration);
|
XmlNode mergedConfiguration = XmlNodeImpl.merge(mojoConfiguration, pomConfiguration);
|
||||||
|
|
||||||
mojoExecution.setConfiguration(mergedConfiguration);
|
mojoExecution.setConfiguration(mergedConfiguration);
|
||||||
|
|
||||||
|
|
|
@ -28,9 +28,9 @@ import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.StringTokenizer;
|
import java.util.StringTokenizer;
|
||||||
|
|
||||||
import org.apache.maven.api.xml.Dom;
|
import org.apache.maven.api.xml.XmlNode;
|
||||||
import org.apache.maven.execution.MavenSession;
|
import org.apache.maven.execution.MavenSession;
|
||||||
import org.apache.maven.internal.xml.Xpp3Dom;
|
import org.apache.maven.internal.xml.XmlNodeImpl;
|
||||||
import org.apache.maven.model.Plugin;
|
import org.apache.maven.model.Plugin;
|
||||||
import org.apache.maven.plugin.BuildPluginManager;
|
import org.apache.maven.plugin.BuildPluginManager;
|
||||||
import org.apache.maven.plugin.InvalidPluginDescriptorException;
|
import org.apache.maven.plugin.InvalidPluginDescriptorException;
|
||||||
|
@ -99,14 +99,14 @@ public class MojoDescriptorCreator {
|
||||||
public static org.codehaus.plexus.util.xml.Xpp3Dom convert(MojoDescriptor mojoDescriptor) {
|
public static org.codehaus.plexus.util.xml.Xpp3Dom convert(MojoDescriptor mojoDescriptor) {
|
||||||
PlexusConfiguration c = mojoDescriptor.getMojoConfiguration();
|
PlexusConfiguration c = mojoDescriptor.getMojoConfiguration();
|
||||||
|
|
||||||
List<Dom> children = new ArrayList<>();
|
List<XmlNode> children = new ArrayList<>();
|
||||||
PlexusConfiguration[] ces = c.getChildren();
|
PlexusConfiguration[] ces = c.getChildren();
|
||||||
if (ces != null) {
|
if (ces != null) {
|
||||||
for (PlexusConfiguration ce : ces) {
|
for (PlexusConfiguration ce : ces) {
|
||||||
String value = ce.getValue(null);
|
String value = ce.getValue(null);
|
||||||
String defaultValue = ce.getAttribute("default-value", null);
|
String defaultValue = ce.getAttribute("default-value", null);
|
||||||
if (value != null || defaultValue != null) {
|
if (value != null || defaultValue != null) {
|
||||||
Xpp3Dom e = new Xpp3Dom(
|
XmlNodeImpl e = new XmlNodeImpl(
|
||||||
ce.getName(),
|
ce.getName(),
|
||||||
value,
|
value,
|
||||||
defaultValue != null ? Collections.singletonMap("default-value", defaultValue) : null,
|
defaultValue != null ? Collections.singletonMap("default-value", defaultValue) : null,
|
||||||
|
@ -117,7 +117,7 @@ public class MojoDescriptorCreator {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Xpp3Dom dom = new Xpp3Dom("configuration", null, null, children, null);
|
XmlNodeImpl dom = new XmlNodeImpl("configuration", null, null, children, null);
|
||||||
return new org.codehaus.plexus.util.xml.Xpp3Dom(dom);
|
return new org.codehaus.plexus.util.xml.Xpp3Dom(dom);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,7 +20,7 @@ package org.apache.maven.lifecycle.mapping;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.maven.api.xml.Dom;
|
import org.apache.maven.api.xml.XmlNode;
|
||||||
import org.apache.maven.model.Dependency;
|
import org.apache.maven.model.Dependency;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -31,14 +31,14 @@ import org.apache.maven.model.Dependency;
|
||||||
public class LifecycleMojo {
|
public class LifecycleMojo {
|
||||||
|
|
||||||
private String goal;
|
private String goal;
|
||||||
private Dom configuration;
|
private XmlNode configuration;
|
||||||
private List<Dependency> dependencies;
|
private List<Dependency> dependencies;
|
||||||
|
|
||||||
public String getGoal() {
|
public String getGoal() {
|
||||||
return goal;
|
return goal;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Dom getConfiguration() {
|
public XmlNode getConfiguration() {
|
||||||
return configuration;
|
return configuration;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,7 +50,7 @@ public class LifecycleMojo {
|
||||||
this.goal = goal;
|
this.goal = goal;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setConfiguration(Dom configuration) {
|
public void setConfiguration(XmlNode configuration) {
|
||||||
this.configuration = configuration;
|
this.configuration = configuration;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,7 @@ import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.maven.api.xml.Dom;
|
import org.apache.maven.api.xml.XmlNode;
|
||||||
import org.apache.maven.model.Plugin;
|
import org.apache.maven.model.Plugin;
|
||||||
import org.apache.maven.plugin.descriptor.MojoDescriptor;
|
import org.apache.maven.plugin.descriptor.MojoDescriptor;
|
||||||
|
|
||||||
|
@ -102,7 +102,7 @@ public class MojoExecution {
|
||||||
this.executionId = null;
|
this.executionId = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public MojoExecution(MojoDescriptor mojoDescriptor, Dom configuration) {
|
public MojoExecution(MojoDescriptor mojoDescriptor, XmlNode configuration) {
|
||||||
this.mojoDescriptor = mojoDescriptor;
|
this.mojoDescriptor = mojoDescriptor;
|
||||||
this.configuration = new org.codehaus.plexus.util.xml.Xpp3Dom(configuration);
|
this.configuration = new org.codehaus.plexus.util.xml.Xpp3Dom(configuration);
|
||||||
this.executionId = null;
|
this.executionId = null;
|
||||||
|
@ -141,7 +141,7 @@ public class MojoExecution {
|
||||||
this.configuration = configuration;
|
this.configuration = configuration;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setConfiguration(Dom configuration) {
|
public void setConfiguration(XmlNode configuration) {
|
||||||
this.configuration = configuration != null ? new org.codehaus.plexus.util.xml.Xpp3Dom(configuration) : null;
|
this.configuration = configuration != null ? new org.codehaus.plexus.util.xml.Xpp3Dom(configuration) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -42,7 +42,7 @@ import java.util.stream.Collectors;
|
||||||
import java.util.zip.ZipEntry;
|
import java.util.zip.ZipEntry;
|
||||||
|
|
||||||
import org.apache.maven.RepositoryUtils;
|
import org.apache.maven.RepositoryUtils;
|
||||||
import org.apache.maven.api.xml.Dom;
|
import org.apache.maven.api.xml.XmlNode;
|
||||||
import org.apache.maven.artifact.Artifact;
|
import org.apache.maven.artifact.Artifact;
|
||||||
import org.apache.maven.classrealm.ClassRealmManager;
|
import org.apache.maven.classrealm.ClassRealmManager;
|
||||||
import org.apache.maven.execution.MavenSession;
|
import org.apache.maven.execution.MavenSession;
|
||||||
|
@ -559,7 +559,7 @@ public class DefaultMavenPluginManager implements MavenPluginManager {
|
||||||
((Mojo) mojo).setLog(new MojoLogWrapper(mojoLogger));
|
((Mojo) mojo).setLog(new MojoLogWrapper(mojoLogger));
|
||||||
}
|
}
|
||||||
|
|
||||||
Dom dom = mojoExecution.getConfiguration() != null
|
XmlNode dom = mojoExecution.getConfiguration() != null
|
||||||
? mojoExecution.getConfiguration().getDom()
|
? mojoExecution.getConfiguration().getDom()
|
||||||
: null;
|
: null;
|
||||||
|
|
||||||
|
|
|
@ -28,8 +28,8 @@ import java.util.List;
|
||||||
import java.util.jar.JarFile;
|
import java.util.jar.JarFile;
|
||||||
import java.util.zip.ZipEntry;
|
import java.util.zip.ZipEntry;
|
||||||
|
|
||||||
import org.apache.maven.api.xml.Dom;
|
import org.apache.maven.api.xml.XmlNode;
|
||||||
import org.apache.maven.internal.xml.Xpp3DomBuilder;
|
import org.apache.maven.internal.xml.XmlNodeBuilder;
|
||||||
import org.codehaus.plexus.util.ReaderFactory;
|
import org.codehaus.plexus.util.ReaderFactory;
|
||||||
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
|
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
|
||||||
|
|
||||||
|
@ -86,9 +86,9 @@ public class ExtensionDescriptorBuilder {
|
||||||
public ExtensionDescriptor build(InputStream is) throws IOException {
|
public ExtensionDescriptor build(InputStream is) throws IOException {
|
||||||
ExtensionDescriptor extensionDescriptor = new ExtensionDescriptor();
|
ExtensionDescriptor extensionDescriptor = new ExtensionDescriptor();
|
||||||
|
|
||||||
Dom dom;
|
XmlNode dom;
|
||||||
try {
|
try {
|
||||||
dom = Xpp3DomBuilder.build(ReaderFactory.newXmlReader(is));
|
dom = XmlNodeBuilder.build(ReaderFactory.newXmlReader(is));
|
||||||
} catch (XmlPullParserException e) {
|
} catch (XmlPullParserException e) {
|
||||||
throw new IOException(e.getMessage(), e);
|
throw new IOException(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
@ -104,13 +104,13 @@ public class ExtensionDescriptorBuilder {
|
||||||
return extensionDescriptor;
|
return extensionDescriptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<String> parseStrings(Dom dom) {
|
private List<String> parseStrings(XmlNode dom) {
|
||||||
List<String> strings = null;
|
List<String> strings = null;
|
||||||
|
|
||||||
if (dom != null) {
|
if (dom != null) {
|
||||||
strings = new ArrayList<>();
|
strings = new ArrayList<>();
|
||||||
|
|
||||||
for (Dom child : dom.getChildren()) {
|
for (XmlNode child : dom.getChildren()) {
|
||||||
String string = child.getValue();
|
String string = child.getValue();
|
||||||
if (string != null) {
|
if (string != null) {
|
||||||
string = string.trim();
|
string = string.trim();
|
||||||
|
|
|
@ -28,7 +28,7 @@ import java.util.HashSet;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.maven.AbstractCoreMavenComponentTestCase;
|
import org.apache.maven.AbstractCoreMavenComponentTestCase;
|
||||||
import org.apache.maven.api.xml.Dom;
|
import org.apache.maven.api.xml.XmlNode;
|
||||||
import org.apache.maven.execution.MavenSession;
|
import org.apache.maven.execution.MavenSession;
|
||||||
import org.apache.maven.execution.MojoExecutionEvent;
|
import org.apache.maven.execution.MojoExecutionEvent;
|
||||||
import org.apache.maven.execution.MojoExecutionListener;
|
import org.apache.maven.execution.MojoExecutionListener;
|
||||||
|
@ -309,7 +309,7 @@ public class LifecycleExecutorTest extends AbstractCoreMavenComponentTestCase {
|
||||||
MavenSession session = createMavenSession(pom);
|
MavenSession session = createMavenSession(pom);
|
||||||
MojoDescriptor mojoDescriptor = mojoDescriptorCreator.getMojoDescriptor(
|
MojoDescriptor mojoDescriptor = mojoDescriptorCreator.getMojoDescriptor(
|
||||||
"org.apache.maven.its.plugins:maven-it-plugin:0.1:java", session, session.getCurrentProject());
|
"org.apache.maven.its.plugins:maven-it-plugin:0.1:java", session, session.getCurrentProject());
|
||||||
Dom dom = MojoDescriptorCreator.convert(mojoDescriptor).getDom();
|
XmlNode dom = MojoDescriptorCreator.convert(mojoDescriptor).getDom();
|
||||||
System.out.println(dom);
|
System.out.println(dom);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import org.apache.maven.execution.MavenSession;
|
import org.apache.maven.execution.MavenSession;
|
||||||
import org.apache.maven.internal.xml.Xpp3Dom;
|
import org.apache.maven.internal.xml.XmlNodeImpl;
|
||||||
import org.apache.maven.lifecycle.DefaultLifecycles;
|
import org.apache.maven.lifecycle.DefaultLifecycles;
|
||||||
import org.apache.maven.lifecycle.LifecycleNotFoundException;
|
import org.apache.maven.lifecycle.LifecycleNotFoundException;
|
||||||
import org.apache.maven.lifecycle.LifecyclePhaseNotFoundException;
|
import org.apache.maven.lifecycle.LifecyclePhaseNotFoundException;
|
||||||
|
@ -219,7 +219,7 @@ public class LifecycleExecutionPlanCalculatorStub implements LifecycleExecutionP
|
||||||
final Plugin plugin = mojoDescriptor.getPluginDescriptor().getPlugin();
|
final Plugin plugin = mojoDescriptor.getPluginDescriptor().getPlugin();
|
||||||
plugin.setLocation("version", new InputLocation(12, 34, defaultBindings));
|
plugin.setLocation("version", new InputLocation(12, 34, defaultBindings));
|
||||||
MojoExecution result = new MojoExecution(plugin, goal, executionId);
|
MojoExecution result = new MojoExecution(plugin, goal, executionId);
|
||||||
result.setConfiguration(new Xpp3Dom(executionId + "-" + goal));
|
result.setConfiguration(new XmlNodeImpl(executionId + "-" + goal));
|
||||||
result.setMojoDescriptor(mojoDescriptor);
|
result.setMojoDescriptor(mojoDescriptor);
|
||||||
result.setLifecyclePhase(mojoDescriptor.getPhase());
|
result.setLifecyclePhase(mojoDescriptor.getPhase());
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,7 @@ package org.apache.maven.project.canonical;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.apache.maven.api.xml.Dom;
|
import org.apache.maven.api.xml.XmlNode;
|
||||||
import org.apache.maven.model.Plugin;
|
import org.apache.maven.model.Plugin;
|
||||||
import org.apache.maven.model.PluginExecution;
|
import org.apache.maven.model.PluginExecution;
|
||||||
import org.apache.maven.project.AbstractMavenProjectTestCase;
|
import org.apache.maven.project.AbstractMavenProjectTestCase;
|
||||||
|
@ -69,7 +69,7 @@ public class CanonicalProjectBuilderTest extends AbstractMavenProjectTestCase {
|
||||||
|
|
||||||
assertEquals("1.0", plugin.getVersion());
|
assertEquals("1.0", plugin.getVersion());
|
||||||
|
|
||||||
Dom configuration = plugin.getDelegate().getConfiguration();
|
XmlNode configuration = plugin.getDelegate().getConfiguration();
|
||||||
|
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"src/conf/plexus.conf",
|
"src/conf/plexus.conf",
|
||||||
|
|
|
@ -25,7 +25,7 @@ import java.util.stream.Collectors;
|
||||||
import org.apache.commons.jxpath.ri.QName;
|
import org.apache.commons.jxpath.ri.QName;
|
||||||
import org.apache.commons.jxpath.ri.model.NodeIterator;
|
import org.apache.commons.jxpath.ri.model.NodeIterator;
|
||||||
import org.apache.commons.jxpath.ri.model.NodePointer;
|
import org.apache.commons.jxpath.ri.model.NodePointer;
|
||||||
import org.apache.maven.internal.xml.Xpp3Dom;
|
import org.apache.maven.internal.xml.XmlNodeImpl;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An attribute iterator for JXPath to support <code>Xpp3Dom</code>.
|
* An attribute iterator for JXPath to support <code>Xpp3Dom</code>.
|
||||||
|
@ -36,7 +36,7 @@ class Xpp3DomAttributeIterator implements NodeIterator {
|
||||||
|
|
||||||
private NodePointer parent;
|
private NodePointer parent;
|
||||||
|
|
||||||
private Xpp3Dom node;
|
private XmlNodeImpl node;
|
||||||
|
|
||||||
private List<Map.Entry<String, String>> attributes;
|
private List<Map.Entry<String, String>> attributes;
|
||||||
|
|
||||||
|
@ -46,7 +46,7 @@ class Xpp3DomAttributeIterator implements NodeIterator {
|
||||||
|
|
||||||
public Xpp3DomAttributeIterator(NodePointer parent, QName qname) {
|
public Xpp3DomAttributeIterator(NodePointer parent, QName qname) {
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
this.node = (Xpp3Dom) parent.getNode();
|
this.node = (XmlNodeImpl) parent.getNode();
|
||||||
|
|
||||||
this.attributes = this.node.getAttributes().entrySet().stream()
|
this.attributes = this.node.getAttributes().entrySet().stream()
|
||||||
.filter(a -> a.getKey().equals(qname.getName()) || "*".equals(qname.getName()))
|
.filter(a -> a.getKey().equals(qname.getName()) || "*".equals(qname.getName()))
|
||||||
|
|
|
@ -27,7 +27,7 @@ import org.apache.commons.jxpath.ri.compiler.NodeTest;
|
||||||
import org.apache.commons.jxpath.ri.compiler.NodeTypeTest;
|
import org.apache.commons.jxpath.ri.compiler.NodeTypeTest;
|
||||||
import org.apache.commons.jxpath.ri.model.NodeIterator;
|
import org.apache.commons.jxpath.ri.model.NodeIterator;
|
||||||
import org.apache.commons.jxpath.ri.model.NodePointer;
|
import org.apache.commons.jxpath.ri.model.NodePointer;
|
||||||
import org.apache.maven.api.xml.Dom;
|
import org.apache.maven.api.xml.XmlNode;
|
||||||
import org.codehaus.plexus.util.StringUtils;
|
import org.codehaus.plexus.util.StringUtils;
|
||||||
import org.codehaus.plexus.util.xml.Xpp3Dom;
|
import org.codehaus.plexus.util.xml.Xpp3Dom;
|
||||||
|
|
||||||
|
@ -42,21 +42,21 @@ class Xpp3DomNodeIterator implements NodeIterator {
|
||||||
|
|
||||||
private NodeTest test;
|
private NodeTest test;
|
||||||
|
|
||||||
private Dom node;
|
private XmlNode node;
|
||||||
|
|
||||||
private List<Dom> children;
|
private List<XmlNode> children;
|
||||||
|
|
||||||
private List<Dom> filteredChildren = new ArrayList<>();
|
private List<XmlNode> filteredChildren = new ArrayList<>();
|
||||||
|
|
||||||
private int filteredIndex;
|
private int filteredIndex;
|
||||||
|
|
||||||
private Dom child;
|
private XmlNode child;
|
||||||
|
|
||||||
private int position;
|
private int position;
|
||||||
|
|
||||||
public Xpp3DomNodeIterator(NodePointer parent, NodeTest test, boolean reverse, NodePointer startWith) {
|
public Xpp3DomNodeIterator(NodePointer parent, NodeTest test, boolean reverse, NodePointer startWith) {
|
||||||
this.parent = parent;
|
this.parent = parent;
|
||||||
this.node = (Dom) parent.getNode();
|
this.node = (XmlNode) parent.getNode();
|
||||||
this.children = this.node.getChildren();
|
this.children = this.node.getChildren();
|
||||||
if (startWith != null) {
|
if (startWith != null) {
|
||||||
Xpp3Dom startWithNode = (Xpp3Dom) startWith.getNode();
|
Xpp3Dom startWithNode = (Xpp3Dom) startWith.getNode();
|
||||||
|
@ -93,14 +93,14 @@ class Xpp3DomNodeIterator implements NodeIterator {
|
||||||
|
|
||||||
private void filterChildren(int position) {
|
private void filterChildren(int position) {
|
||||||
for (; position > filteredChildren.size() && filteredIndex < children.size(); filteredIndex++) {
|
for (; position > filteredChildren.size() && filteredIndex < children.size(); filteredIndex++) {
|
||||||
Dom child = children.get(filteredIndex);
|
XmlNode child = children.get(filteredIndex);
|
||||||
if (testNode(child)) {
|
if (testNode(child)) {
|
||||||
filteredChildren.add(child);
|
filteredChildren.add(child);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean testNode(Dom node) {
|
private boolean testNode(XmlNode node) {
|
||||||
if (test == null) {
|
if (test == null) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ import org.apache.commons.jxpath.ri.QName;
|
||||||
import org.apache.commons.jxpath.ri.compiler.NodeTest;
|
import org.apache.commons.jxpath.ri.compiler.NodeTest;
|
||||||
import org.apache.commons.jxpath.ri.model.NodeIterator;
|
import org.apache.commons.jxpath.ri.model.NodeIterator;
|
||||||
import org.apache.commons.jxpath.ri.model.NodePointer;
|
import org.apache.commons.jxpath.ri.model.NodePointer;
|
||||||
import org.apache.maven.api.xml.Dom;
|
import org.apache.maven.api.xml.XmlNode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A node pointer for JXPath to support <code>Xpp3Dom</code>.
|
* A node pointer for JXPath to support <code>Xpp3Dom</code>.
|
||||||
|
@ -34,26 +34,26 @@ import org.apache.maven.api.xml.Dom;
|
||||||
*/
|
*/
|
||||||
class Xpp3DomNodePointer extends NodePointer {
|
class Xpp3DomNodePointer extends NodePointer {
|
||||||
|
|
||||||
private Dom node;
|
private XmlNode node;
|
||||||
|
|
||||||
public Xpp3DomNodePointer(Dom node) {
|
public Xpp3DomNodePointer(XmlNode node) {
|
||||||
super(null);
|
super(null);
|
||||||
this.node = node;
|
this.node = node;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Xpp3DomNodePointer(NodePointer parent, Dom node) {
|
public Xpp3DomNodePointer(NodePointer parent, XmlNode node) {
|
||||||
super(parent);
|
super(parent);
|
||||||
this.node = node;
|
this.node = node;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int compareChildNodePointers(NodePointer pointer1, NodePointer pointer2) {
|
public int compareChildNodePointers(NodePointer pointer1, NodePointer pointer2) {
|
||||||
Dom node1 = (Dom) pointer1.getBaseValue();
|
XmlNode node1 = (XmlNode) pointer1.getBaseValue();
|
||||||
Dom node2 = (Dom) pointer2.getBaseValue();
|
XmlNode node2 = (XmlNode) pointer2.getBaseValue();
|
||||||
if (node1 == node2) {
|
if (node1 == node2) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
for (Dom child : node.getChildren()) {
|
for (XmlNode child : node.getChildren()) {
|
||||||
if (child == node1) {
|
if (child == node1) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -69,12 +69,12 @@ class Xpp3DomNodePointer extends NodePointer {
|
||||||
return getValue(node);
|
return getValue(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Object getValue(Dom node) {
|
private static Object getValue(XmlNode node) {
|
||||||
if (node.getValue() != null) {
|
if (node.getValue() != null) {
|
||||||
return node.getValue();
|
return node.getValue();
|
||||||
} else {
|
} else {
|
||||||
List<Object> children = new ArrayList<>();
|
List<Object> children = new ArrayList<>();
|
||||||
for (Dom child : node.getChildren()) {
|
for (XmlNode child : node.getChildren()) {
|
||||||
children.add(getValue(child));
|
children.add(getValue(child));
|
||||||
}
|
}
|
||||||
return children;
|
return children;
|
||||||
|
|
|
@ -23,7 +23,7 @@ import java.util.Locale;
|
||||||
import org.apache.commons.jxpath.ri.QName;
|
import org.apache.commons.jxpath.ri.QName;
|
||||||
import org.apache.commons.jxpath.ri.model.NodePointer;
|
import org.apache.commons.jxpath.ri.model.NodePointer;
|
||||||
import org.apache.commons.jxpath.ri.model.NodePointerFactory;
|
import org.apache.commons.jxpath.ri.model.NodePointerFactory;
|
||||||
import org.apache.maven.api.xml.Dom;
|
import org.apache.maven.api.xml.XmlNode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A node pointer factory for JXPath to support <code>Xpp3Dom</code>.
|
* A node pointer factory for JXPath to support <code>Xpp3Dom</code>.
|
||||||
|
@ -40,8 +40,8 @@ public class Xpp3DomPointerFactory implements NodePointerFactory {
|
||||||
if (object instanceof org.codehaus.plexus.util.xml.Xpp3Dom) {
|
if (object instanceof org.codehaus.plexus.util.xml.Xpp3Dom) {
|
||||||
object = ((org.codehaus.plexus.util.xml.Xpp3Dom) object).getDom();
|
object = ((org.codehaus.plexus.util.xml.Xpp3Dom) object).getDom();
|
||||||
}
|
}
|
||||||
if (object instanceof Dom) {
|
if (object instanceof XmlNode) {
|
||||||
return new Xpp3DomNodePointer((Dom) object);
|
return new Xpp3DomNodePointer((XmlNode) object);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -50,8 +50,8 @@ public class Xpp3DomPointerFactory implements NodePointerFactory {
|
||||||
if (object instanceof org.codehaus.plexus.util.xml.Xpp3Dom) {
|
if (object instanceof org.codehaus.plexus.util.xml.Xpp3Dom) {
|
||||||
object = ((org.codehaus.plexus.util.xml.Xpp3Dom) object).getDom();
|
object = ((org.codehaus.plexus.util.xml.Xpp3Dom) object).getDom();
|
||||||
}
|
}
|
||||||
if (object instanceof Dom) {
|
if (object instanceof XmlNode) {
|
||||||
return new Xpp3DomNodePointer(parent, (Dom) object);
|
return new Xpp3DomNodePointer(parent, (XmlNode) object);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,8 @@ import com.google.inject.Module;
|
||||||
import com.google.inject.TypeLiteral;
|
import com.google.inject.TypeLiteral;
|
||||||
import com.google.inject.spi.TypeConverter;
|
import com.google.inject.spi.TypeConverter;
|
||||||
import com.google.inject.spi.TypeConverterBinding;
|
import com.google.inject.spi.TypeConverterBinding;
|
||||||
import org.apache.maven.api.xml.Dom;
|
import org.apache.maven.api.xml.XmlNode;
|
||||||
|
import org.apache.maven.internal.xml.XmlNodeBuilder;
|
||||||
import org.codehaus.plexus.util.xml.Xpp3Dom;
|
import org.codehaus.plexus.util.xml.Xpp3Dom;
|
||||||
import org.codehaus.plexus.util.xml.Xpp3DomBuilder;
|
import org.codehaus.plexus.util.xml.Xpp3DomBuilder;
|
||||||
import org.codehaus.plexus.util.xml.pull.MXParser;
|
import org.codehaus.plexus.util.xml.pull.MXParser;
|
||||||
|
@ -111,8 +112,8 @@ public final class PlexusXmlBeanConverter implements PlexusBeanConverter {
|
||||||
parser.require(XmlPullParser.START_TAG, null, null);
|
parser.require(XmlPullParser.START_TAG, null, null);
|
||||||
|
|
||||||
final Class<?> rawType = toType.getRawType();
|
final Class<?> rawType = toType.getRawType();
|
||||||
if (Dom.class.isAssignableFrom(rawType)) {
|
if (XmlNode.class.isAssignableFrom(rawType)) {
|
||||||
return org.apache.maven.internal.xml.Xpp3DomBuilder.build(parser);
|
return XmlNodeBuilder.build(parser);
|
||||||
}
|
}
|
||||||
if (Xpp3Dom.class.isAssignableFrom(rawType)) {
|
if (Xpp3Dom.class.isAssignableFrom(rawType)) {
|
||||||
return parseXpp3Dom(parser);
|
return parseXpp3Dom(parser);
|
||||||
|
|
|
@ -45,7 +45,7 @@ import java.util.function.Function;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.apache.maven.api.annotations.Generated;
|
import org.apache.maven.api.annotations.Generated;
|
||||||
import org.apache.maven.api.xml.Dom;
|
import org.apache.maven.api.xml.XmlNode;
|
||||||
#foreach ( $class in $model.allClasses )
|
#foreach ( $class in $model.allClasses )
|
||||||
import ${packageModelV4}.${class.Name};
|
import ${packageModelV4}.${class.Name};
|
||||||
#end
|
#end
|
||||||
|
@ -172,10 +172,10 @@ public class ${className}
|
||||||
#elseif ( $field.to && $field.multiplicity == "*" )
|
#elseif ( $field.to && $field.multiplicity == "*" )
|
||||||
builder.${field.name}( merge( target.get${capField}(), source.get${capField}(), sourceDominant, get${field.to}Key() ) );
|
builder.${field.name}( merge( target.get${capField}(), source.get${capField}(), sourceDominant, get${field.to}Key() ) );
|
||||||
#elseif ( $field.type == "DOM" )
|
#elseif ( $field.type == "DOM" )
|
||||||
Dom src = source.getConfiguration();
|
XmlNode src = source.getConfiguration();
|
||||||
if ( src != null )
|
if ( src != null )
|
||||||
{
|
{
|
||||||
Dom tgt = target.getConfiguration();
|
XmlNode tgt = target.getConfiguration();
|
||||||
if ( tgt == null )
|
if ( tgt == null )
|
||||||
{
|
{
|
||||||
builder.configuration( src );
|
builder.configuration( src );
|
||||||
|
|
|
@ -294,7 +294,7 @@ public class ${class.name}
|
||||||
#elseif ( $field.type == "DOM" )
|
#elseif ( $field.type == "DOM" )
|
||||||
if ( getDelegate().get${cap}() == oldDelegate )
|
if ( getDelegate().get${cap}() == oldDelegate )
|
||||||
{
|
{
|
||||||
update( getDelegate().with${cap}( ( org.apache.maven.api.xml.Dom ) newDelegate ) );
|
update( getDelegate().with${cap}( ( org.apache.maven.api.xml.XmlNode ) newDelegate ) );
|
||||||
}
|
}
|
||||||
#end
|
#end
|
||||||
#end
|
#end
|
||||||
|
|
|
@ -46,7 +46,7 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import org.apache.maven.api.annotations.Generated;
|
import org.apache.maven.api.annotations.Generated;
|
||||||
import org.apache.maven.internal.xml.DomBuilder;
|
import org.apache.maven.internal.xml.XmlNodeBuilder;
|
||||||
import ${packageModelV4}.InputSource;
|
import ${packageModelV4}.InputSource;
|
||||||
import ${packageModelV4}.InputLocation;
|
import ${packageModelV4}.InputLocation;
|
||||||
#foreach ( $class in $model.allClasses )
|
#foreach ( $class in $model.allClasses )
|
||||||
|
@ -251,7 +251,7 @@ public class ${className}
|
||||||
${classLcapName}.${field.name}( getIntegerValue( interpolatedTrimmed( parser.nextText(), "${fieldTagName}" ), "${fieldTagName}", parser, strict, ${field.defaultValue} ) );
|
${classLcapName}.${field.name}( getIntegerValue( interpolatedTrimmed( parser.nextText(), "${fieldTagName}" ), "${fieldTagName}", parser, strict, ${field.defaultValue} ) );
|
||||||
break;
|
break;
|
||||||
#elseif ( $field.type == "DOM" )
|
#elseif ( $field.type == "DOM" )
|
||||||
${classLcapName}.${field.name}( DomBuilder.build( parser, true ) );
|
${classLcapName}.${field.name}( XmlNodeBuilder.build( parser, true ) );
|
||||||
break;
|
break;
|
||||||
#elseif ( $field.type == "java.util.List" && $field.to == "String" && $field.multiplicity == "*" )
|
#elseif ( $field.type == "java.util.List" && $field.to == "String" && $field.multiplicity == "*" )
|
||||||
List<String> ${field.name} = new ArrayList<>();
|
List<String> ${field.name} = new ArrayList<>();
|
||||||
|
|
|
@ -46,7 +46,7 @@ import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import org.apache.maven.api.annotations.Generated;
|
import org.apache.maven.api.annotations.Generated;
|
||||||
import org.apache.maven.internal.xml.DomBuilder;
|
import org.apache.maven.internal.xml.XmlNodeBuilder;
|
||||||
#foreach ( $class in $model.allClasses )
|
#foreach ( $class in $model.allClasses )
|
||||||
import ${packageModelV4}.${class.name};
|
import ${packageModelV4}.${class.name};
|
||||||
#end
|
#end
|
||||||
|
@ -277,7 +277,7 @@ public class ${className}
|
||||||
${classLcapName}.${field.name}( getIntegerValue( interpolatedTrimmed( parser.nextText(), "${fieldTagName}" ), "${fieldTagName}", parser, strict, ${field.defaultValue} ) );
|
${classLcapName}.${field.name}( getIntegerValue( interpolatedTrimmed( parser.nextText(), "${fieldTagName}" ), "${fieldTagName}", parser, strict, ${field.defaultValue} ) );
|
||||||
break;
|
break;
|
||||||
#elseif ( $field.type == "DOM" )
|
#elseif ( $field.type == "DOM" )
|
||||||
${classLcapName}.${field.name}( DomBuilder.build( parser, true ) );
|
${classLcapName}.${field.name}( XmlNodeBuilder.build( parser, true ) );
|
||||||
break;
|
break;
|
||||||
#elseif ( $field.type == "java.util.List" && $field.to == "String" && $field.multiplicity == "*" )
|
#elseif ( $field.type == "java.util.List" && $field.to == "String" && $field.multiplicity == "*" )
|
||||||
List<String> ${field.name} = new ArrayList<>();
|
List<String> ${field.name} = new ArrayList<>();
|
||||||
|
|
|
@ -43,7 +43,7 @@ import java.util.function.Function;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.apache.maven.api.annotations.Generated;
|
import org.apache.maven.api.annotations.Generated;
|
||||||
import org.apache.maven.api.xml.Dom;
|
import org.apache.maven.api.xml.XmlNode;
|
||||||
#foreach ( $class in $model.allClasses )
|
#foreach ( $class in $model.allClasses )
|
||||||
import ${packageModelV4}.${class.name};
|
import ${packageModelV4}.${class.name};
|
||||||
#end
|
#end
|
||||||
|
@ -126,7 +126,7 @@ public class ${className}
|
||||||
#elseif ( $field.to && $field.multiplicity == "*" )
|
#elseif ( $field.to && $field.multiplicity == "*" )
|
||||||
builder.${field.name}( transform( target.get${capField}(), this::transform${field.to} ) );
|
builder.${field.name}( transform( target.get${capField}(), this::transform${field.to} ) );
|
||||||
#elseif ( $field.type == "DOM" )
|
#elseif ( $field.type == "DOM" )
|
||||||
Dom newVal = transform( target.get${capField}() );
|
XmlNode newVal = transform( target.get${capField}() );
|
||||||
builder.${field.name}( newVal != target.get${capField}() ? newVal : null );
|
builder.${field.name}( newVal != target.get${capField}() ? newVal : null );
|
||||||
#elseif ( $field.type == "boolean" || $field.type == "int" || $field.type == "java.nio.file.Path" )
|
#elseif ( $field.type == "boolean" || $field.type == "int" || $field.type == "java.nio.file.Path" )
|
||||||
// nothing to do, the transformer only handles strings
|
// nothing to do, the transformer only handles strings
|
||||||
|
@ -156,7 +156,7 @@ public class ${className}
|
||||||
return newList;
|
return newList;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected Dom transform( Dom node )
|
protected XmlNode transform( XmlNode node )
|
||||||
{
|
{
|
||||||
if ( node != null )
|
if ( node != null )
|
||||||
{
|
{
|
||||||
|
|
|
@ -50,8 +50,8 @@ import java.util.Set;
|
||||||
import org.apache.maven.api.annotations.Generated;
|
import org.apache.maven.api.annotations.Generated;
|
||||||
import ${packageModelV4}.InputLocation;
|
import ${packageModelV4}.InputLocation;
|
||||||
import ${packageModelV4}.InputLocationTracker;
|
import ${packageModelV4}.InputLocationTracker;
|
||||||
import org.apache.maven.api.xml.Dom;
|
import org.apache.maven.api.xml.XmlNode;
|
||||||
import org.apache.maven.internal.xml.DomBuilder;
|
import org.apache.maven.internal.xml.XmlNodeBuilder;
|
||||||
#foreach ( $class in $model.allClasses )
|
#foreach ( $class in $model.allClasses )
|
||||||
#if ( $class.name != "InputLocation" )
|
#if ( $class.name != "InputLocation" )
|
||||||
import ${packageModelV4}.${class.name};
|
import ${packageModelV4}.${class.name};
|
||||||
|
@ -156,7 +156,7 @@ public class ${className}
|
||||||
* @param serializer a serializer object.
|
* @param serializer a serializer object.
|
||||||
* @throws java.io.IOException java.io.IOException if any.
|
* @throws java.io.IOException java.io.IOException if any.
|
||||||
*/
|
*/
|
||||||
protected void writeDomToSerializer( org.apache.maven.api.xml.Dom dom, XmlSerializer serializer )
|
protected void writeDomToSerializer( org.apache.maven.api.xml.XmlNode dom, XmlSerializer serializer )
|
||||||
throws java.io.IOException
|
throws java.io.IOException
|
||||||
{
|
{
|
||||||
serializer.startTag( NAMESPACE, dom.getName() );
|
serializer.startTag( NAMESPACE, dom.getName() );
|
||||||
|
@ -165,7 +165,7 @@ public class ${className}
|
||||||
{
|
{
|
||||||
serializer.attribute( NAMESPACE, attribute.getKey(), attribute.getValue() );
|
serializer.attribute( NAMESPACE, attribute.getKey(), attribute.getValue() );
|
||||||
}
|
}
|
||||||
for ( Dom aChild : dom.getChildren() )
|
for ( XmlNode aChild : dom.getChildren() )
|
||||||
{
|
{
|
||||||
writeDomToSerializer( aChild, serializer );
|
writeDomToSerializer( aChild, serializer );
|
||||||
}
|
}
|
||||||
|
@ -178,7 +178,7 @@ public class ${className}
|
||||||
|
|
||||||
serializer.endTag( NAMESPACE, dom.getName() );
|
serializer.endTag( NAMESPACE, dom.getName() );
|
||||||
|
|
||||||
} //-- void writeDomToSerializer( org.apache.maven.api.xml.Dom, XmlSerializer )
|
} //-- void writeDomToSerializer( org.apache.maven.api.xml.XmlNode, XmlSerializer )
|
||||||
|
|
||||||
|
|
||||||
#foreach ( $class in $model.allClasses )
|
#foreach ( $class in $model.allClasses )
|
||||||
|
@ -316,7 +316,7 @@ public class ${className}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeDom( Dom dom, XmlSerializer serializer )
|
private void writeDom( XmlNode dom, XmlSerializer serializer )
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
if ( dom != null )
|
if ( dom != null )
|
||||||
|
@ -326,7 +326,7 @@ public class ${className}
|
||||||
{
|
{
|
||||||
serializer.attribute( NAMESPACE, attr.getKey(), attr.getValue() );
|
serializer.attribute( NAMESPACE, attr.getKey(), attr.getValue() );
|
||||||
}
|
}
|
||||||
for ( Dom child : dom.getChildren() )
|
for ( XmlNode child : dom.getChildren() )
|
||||||
{
|
{
|
||||||
writeDom( child, serializer );
|
writeDom( child, serializer );
|
||||||
}
|
}
|
||||||
|
|
|
@ -48,8 +48,8 @@ import java.util.Objects;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import org.apache.maven.api.annotations.Generated;
|
import org.apache.maven.api.annotations.Generated;
|
||||||
import org.apache.maven.api.xml.Dom;
|
import org.apache.maven.api.xml.XmlNode;
|
||||||
import org.apache.maven.internal.xml.DomBuilder;
|
import org.apache.maven.internal.xml.XmlNodeBuilder;
|
||||||
#foreach ( $class in $model.allClasses )
|
#foreach ( $class in $model.allClasses )
|
||||||
import ${packageModelV4}.${class.name};
|
import ${packageModelV4}.${class.name};
|
||||||
#end
|
#end
|
||||||
|
@ -138,7 +138,7 @@ public class ${className}
|
||||||
* @param serializer a serializer object.
|
* @param serializer a serializer object.
|
||||||
* @throws java.io.IOException java.io.IOException if any.
|
* @throws java.io.IOException java.io.IOException if any.
|
||||||
*/
|
*/
|
||||||
protected void writeDomToSerializer( org.apache.maven.api.xml.Dom dom, XmlSerializer serializer )
|
protected void writeDomToSerializer( org.apache.maven.api.xml.XmlNode dom, XmlSerializer serializer )
|
||||||
throws java.io.IOException
|
throws java.io.IOException
|
||||||
{
|
{
|
||||||
serializer.startTag( NAMESPACE, dom.getName() );
|
serializer.startTag( NAMESPACE, dom.getName() );
|
||||||
|
@ -147,7 +147,7 @@ public class ${className}
|
||||||
{
|
{
|
||||||
serializer.attribute( NAMESPACE, attribute.getKey(), attribute.getValue() );
|
serializer.attribute( NAMESPACE, attribute.getKey(), attribute.getValue() );
|
||||||
}
|
}
|
||||||
for ( Dom aChild : dom.getChildren() )
|
for ( XmlNode aChild : dom.getChildren() )
|
||||||
{
|
{
|
||||||
writeDomToSerializer( aChild, serializer );
|
writeDomToSerializer( aChild, serializer );
|
||||||
}
|
}
|
||||||
|
@ -160,7 +160,7 @@ public class ${className}
|
||||||
|
|
||||||
serializer.endTag( NAMESPACE, dom.getName() );
|
serializer.endTag( NAMESPACE, dom.getName() );
|
||||||
|
|
||||||
} //-- void writeDomToSerializer( org.apache.maven.api.xml.Dom, XmlSerializer )
|
} //-- void writeDomToSerializer( org.apache.maven.api.xml.XmlNode, XmlSerializer )
|
||||||
|
|
||||||
|
|
||||||
#foreach ( $class in $model.allClasses )
|
#foreach ( $class in $model.allClasses )
|
||||||
|
@ -287,7 +287,7 @@ public class ${className}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeDom( Dom dom, XmlSerializer serializer )
|
private void writeDom( XmlNode dom, XmlSerializer serializer )
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
if ( dom != null )
|
if ( dom != null )
|
||||||
|
@ -297,7 +297,7 @@ public class ${className}
|
||||||
{
|
{
|
||||||
serializer.attribute( NAMESPACE, attr.getKey(), attr.getValue() );
|
serializer.attribute( NAMESPACE, attr.getKey(), attr.getValue() );
|
||||||
}
|
}
|
||||||
for ( Dom child : dom.getChildren() )
|
for ( XmlNode child : dom.getChildren() )
|
||||||
{
|
{
|
||||||
writeDom( child, serializer );
|
writeDom( child, serializer );
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,8 +24,8 @@ import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
|
import org.apache.maven.internal.xml.XmlNodeBuilder;
|
||||||
import org.apache.maven.internal.xml.XmlPlexusConfiguration;
|
import org.apache.maven.internal.xml.XmlPlexusConfiguration;
|
||||||
import org.apache.maven.internal.xml.Xpp3DomBuilder;
|
|
||||||
import org.codehaus.plexus.component.repository.ComponentDependency;
|
import org.codehaus.plexus.component.repository.ComponentDependency;
|
||||||
import org.codehaus.plexus.component.repository.ComponentRequirement;
|
import org.codehaus.plexus.component.repository.ComponentRequirement;
|
||||||
import org.codehaus.plexus.configuration.PlexusConfiguration;
|
import org.codehaus.plexus.configuration.PlexusConfiguration;
|
||||||
|
@ -369,7 +369,7 @@ public class PluginDescriptorBuilder {
|
||||||
|
|
||||||
public PlexusConfiguration buildConfiguration(Reader configuration) throws PlexusConfigurationException {
|
public PlexusConfiguration buildConfiguration(Reader configuration) throws PlexusConfigurationException {
|
||||||
try {
|
try {
|
||||||
return XmlPlexusConfiguration.toPlexusConfiguration(Xpp3DomBuilder.build(configuration));
|
return XmlPlexusConfiguration.toPlexusConfiguration(XmlNodeBuilder.build(configuration));
|
||||||
} catch (IOException | XmlPullParserException e) {
|
} catch (IOException | XmlPullParserException e) {
|
||||||
throw new PlexusConfigurationException(e.getMessage(), e);
|
throw new PlexusConfigurationException(e.getMessage(), e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -45,7 +45,7 @@ import java.util.function.Function;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.apache.maven.api.annotations.Generated;
|
import org.apache.maven.api.annotations.Generated;
|
||||||
import org.apache.maven.api.xml.Dom;
|
import org.apache.maven.api.xml.XmlNode;
|
||||||
#foreach ( $class in $model.allClasses )
|
#foreach ( $class in $model.allClasses )
|
||||||
import ${packageModelV4}.${class.Name};
|
import ${packageModelV4}.${class.Name};
|
||||||
#end
|
#end
|
||||||
|
@ -172,10 +172,10 @@ public class ${className}
|
||||||
#elseif ( $field.to && $field.multiplicity == "*" )
|
#elseif ( $field.to && $field.multiplicity == "*" )
|
||||||
builder.${field.name}( merge( target.get${capField}(), source.get${capField}(), sourceDominant, get${field.to}Key() ) );
|
builder.${field.name}( merge( target.get${capField}(), source.get${capField}(), sourceDominant, get${field.to}Key() ) );
|
||||||
#elseif ( $field.type == "DOM" )
|
#elseif ( $field.type == "DOM" )
|
||||||
Dom src = source.getConfiguration();
|
XmlNode src = source.getConfiguration();
|
||||||
if ( src != null )
|
if ( src != null )
|
||||||
{
|
{
|
||||||
Dom tgt = target.getConfiguration();
|
XmlNode tgt = target.getConfiguration();
|
||||||
if ( tgt == null )
|
if ( tgt == null )
|
||||||
{
|
{
|
||||||
builder.configuration( src );
|
builder.configuration( src );
|
||||||
|
|
|
@ -51,8 +51,8 @@
|
||||||
#set ( $dummy = $imports.add( "java.util.List" ) )
|
#set ( $dummy = $imports.add( "java.util.List" ) )
|
||||||
#set ( $dummy = $types.put( $field, "List<" + $field.to + ">" ) )
|
#set ( $dummy = $types.put( $field, "List<" + $field.to + ">" ) )
|
||||||
#elseif ( $field.type == "DOM" )
|
#elseif ( $field.type == "DOM" )
|
||||||
#set ( $dummy = $imports.add( "org.apache.maven.api.xml.Dom" ) )
|
#set ( $dummy = $imports.add( "org.apache.maven.api.xml.XmlNode" ) )
|
||||||
#set ( $dummy = $types.put( $field, "Dom" ) )
|
#set ( $dummy = $types.put( $field, "XmlNode" ) )
|
||||||
#else
|
#else
|
||||||
#set ( $fieldType = ${types.getOrDefault($field.type,$field.type)} )
|
#set ( $fieldType = ${types.getOrDefault($field.type,$field.type)} )
|
||||||
#set ( $idx = $fieldType.lastIndexOf('.') )
|
#set ( $idx = $fieldType.lastIndexOf('.') )
|
||||||
|
|
|
@ -44,7 +44,7 @@ import java.util.List;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import org.apache.maven.api.annotations.Generated;
|
import org.apache.maven.api.annotations.Generated;
|
||||||
import org.apache.maven.internal.xml.DomBuilder;
|
import org.apache.maven.internal.xml.XmlNodeBuilder;
|
||||||
#foreach ( $class in $model.allClasses )
|
#foreach ( $class in $model.allClasses )
|
||||||
import ${packageModelV4}.${class.name};
|
import ${packageModelV4}.${class.name};
|
||||||
#end
|
#end
|
||||||
|
@ -751,7 +751,7 @@ public class ${className}
|
||||||
${classLcapName}.${field.name}( getIntegerValue( interpolatedTrimmed( parser.nextText(), "${fieldTagName}" ), "${fieldTagName}", parser, strict, ${field.defaultValue} ) );
|
${classLcapName}.${field.name}( getIntegerValue( interpolatedTrimmed( parser.nextText(), "${fieldTagName}" ), "${fieldTagName}", parser, strict, ${field.defaultValue} ) );
|
||||||
break;
|
break;
|
||||||
#elseif ( $field.type == "DOM" )
|
#elseif ( $field.type == "DOM" )
|
||||||
${classLcapName}.${field.name}( DomBuilder.build( parser, true ) );
|
${classLcapName}.${field.name}( XmlNodeBuilder.build( parser, true ) );
|
||||||
break;
|
break;
|
||||||
#elseif ( $field.type == "java.util.List" && $field.to == "String" && $field.multiplicity == "*" )
|
#elseif ( $field.type == "java.util.List" && $field.to == "String" && $field.multiplicity == "*" )
|
||||||
List<String> ${field.name} = new ArrayList<>();
|
List<String> ${field.name} = new ArrayList<>();
|
||||||
|
|
|
@ -48,8 +48,8 @@ import java.util.Objects;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import org.apache.maven.api.annotations.Generated;
|
import org.apache.maven.api.annotations.Generated;
|
||||||
import org.apache.maven.api.xml.Dom;
|
import org.apache.maven.api.xml.XmlNode;
|
||||||
import org.apache.maven.internal.xml.DomBuilder;
|
import org.apache.maven.internal.xml.XmlNodeBuilder;
|
||||||
#foreach ( $class in $model.allClasses )
|
#foreach ( $class in $model.allClasses )
|
||||||
import ${packageModelV4}.${class.name};
|
import ${packageModelV4}.${class.name};
|
||||||
#end
|
#end
|
||||||
|
@ -138,7 +138,7 @@ public class ${className}
|
||||||
* @param serializer a serializer object.
|
* @param serializer a serializer object.
|
||||||
* @throws java.io.IOException java.io.IOException if any.
|
* @throws java.io.IOException java.io.IOException if any.
|
||||||
*/
|
*/
|
||||||
protected void writeDomToSerializer( org.apache.maven.api.xml.Dom dom, XmlSerializer serializer )
|
protected void writeDomToSerializer( org.apache.maven.api.xml.XmlNode dom, XmlSerializer serializer )
|
||||||
throws java.io.IOException
|
throws java.io.IOException
|
||||||
{
|
{
|
||||||
serializer.startTag( NAMESPACE, dom.getName() );
|
serializer.startTag( NAMESPACE, dom.getName() );
|
||||||
|
@ -147,7 +147,7 @@ public class ${className}
|
||||||
{
|
{
|
||||||
serializer.attribute( NAMESPACE, attribute.getKey(), attribute.getValue() );
|
serializer.attribute( NAMESPACE, attribute.getKey(), attribute.getValue() );
|
||||||
}
|
}
|
||||||
for ( Dom aChild : dom.getChildren() )
|
for ( XmlNode aChild : dom.getChildren() )
|
||||||
{
|
{
|
||||||
writeDomToSerializer( aChild, serializer );
|
writeDomToSerializer( aChild, serializer );
|
||||||
}
|
}
|
||||||
|
@ -160,7 +160,7 @@ public class ${className}
|
||||||
|
|
||||||
serializer.endTag( NAMESPACE, dom.getName() );
|
serializer.endTag( NAMESPACE, dom.getName() );
|
||||||
|
|
||||||
} //-- void writeDomToSerializer( org.apache.maven.api.xml.Dom, XmlSerializer )
|
} //-- void writeDomToSerializer( org.apache.maven.api.xml.XmlNode, XmlSerializer )
|
||||||
|
|
||||||
|
|
||||||
#foreach ( $class in $model.allClasses )
|
#foreach ( $class in $model.allClasses )
|
||||||
|
@ -287,7 +287,7 @@ public class ${className}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeDom( Dom dom, XmlSerializer serializer )
|
private void writeDom( XmlNode dom, XmlSerializer serializer )
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
if ( dom != null )
|
if ( dom != null )
|
||||||
|
@ -297,7 +297,7 @@ public class ${className}
|
||||||
{
|
{
|
||||||
serializer.attribute( NAMESPACE, attr.getKey(), attr.getValue() );
|
serializer.attribute( NAMESPACE, attr.getKey(), attr.getValue() );
|
||||||
}
|
}
|
||||||
for ( Dom child : dom.getChildren() )
|
for ( XmlNode child : dom.getChildren() )
|
||||||
{
|
{
|
||||||
writeDom( child, serializer );
|
writeDom( child, serializer );
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ import java.util.function.Function;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.apache.maven.api.annotations.Generated;
|
import org.apache.maven.api.annotations.Generated;
|
||||||
import org.apache.maven.api.xml.Dom;
|
import org.apache.maven.api.xml.XmlNode;
|
||||||
#foreach ( $class in $model.allClasses )
|
#foreach ( $class in $model.allClasses )
|
||||||
import ${packageModelV4}.${class.Name};
|
import ${packageModelV4}.${class.Name};
|
||||||
#end
|
#end
|
||||||
|
@ -171,10 +171,10 @@ public class ${className}
|
||||||
#elseif ( $field.to && $field.multiplicity == "*" )
|
#elseif ( $field.to && $field.multiplicity == "*" )
|
||||||
builder.${field.name}( merge( target.get${capField}(), source.get${capField}(), sourceDominant, get${field.to}Key() ) );
|
builder.${field.name}( merge( target.get${capField}(), source.get${capField}(), sourceDominant, get${field.to}Key() ) );
|
||||||
#elseif ( $field.type == "DOM" )
|
#elseif ( $field.type == "DOM" )
|
||||||
Dom src = source.getConfiguration();
|
XmlNode src = source.getConfiguration();
|
||||||
if ( src != null )
|
if ( src != null )
|
||||||
{
|
{
|
||||||
Dom tgt = target.getConfiguration();
|
XmlNode tgt = target.getConfiguration();
|
||||||
if ( tgt == null )
|
if ( tgt == null )
|
||||||
{
|
{
|
||||||
builder.configuration( src );
|
builder.configuration( src );
|
||||||
|
|
|
@ -47,7 +47,7 @@ import java.util.Map;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import org.apache.maven.api.annotations.Generated;
|
import org.apache.maven.api.annotations.Generated;
|
||||||
import org.apache.maven.internal.xml.DomBuilder;
|
import org.apache.maven.internal.xml.XmlNodeBuilder;
|
||||||
#foreach ( $class in $model.allClasses )
|
#foreach ( $class in $model.allClasses )
|
||||||
import ${packageModelV4}.${class.name};
|
import ${packageModelV4}.${class.name};
|
||||||
#end
|
#end
|
||||||
|
@ -754,7 +754,7 @@ public class ${className}
|
||||||
${classLcapName}.${field.name}( getIntegerValue( interpolatedTrimmed( parser.nextText(), "${fieldTagName}" ), "${fieldTagName}", parser, strict, ${field.defaultValue} ) );
|
${classLcapName}.${field.name}( getIntegerValue( interpolatedTrimmed( parser.nextText(), "${fieldTagName}" ), "${fieldTagName}", parser, strict, ${field.defaultValue} ) );
|
||||||
break;
|
break;
|
||||||
#elseif ( $field.type == "DOM" )
|
#elseif ( $field.type == "DOM" )
|
||||||
${classLcapName}.${field.name}( DomBuilder.build( parser, true ) );
|
${classLcapName}.${field.name}( XmlNodeBuilder.build( parser, true ) );
|
||||||
break;
|
break;
|
||||||
#elseif ( $field.type == "java.util.List" && $field.to == "String" && $field.multiplicity == "*" )
|
#elseif ( $field.type == "java.util.List" && $field.to == "String" && $field.multiplicity == "*" )
|
||||||
List<String> ${field.name} = new ArrayList<>();
|
List<String> ${field.name} = new ArrayList<>();
|
||||||
|
|
|
@ -48,8 +48,8 @@ import java.util.Objects;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import org.apache.maven.api.annotations.Generated;
|
import org.apache.maven.api.annotations.Generated;
|
||||||
import org.apache.maven.api.xml.Dom;
|
import org.apache.maven.api.xml.XmlNode;
|
||||||
import org.apache.maven.internal.xml.DomBuilder;
|
import org.apache.maven.internal.xml.XmlNodeBuilder;
|
||||||
#foreach ( $class in $model.allClasses )
|
#foreach ( $class in $model.allClasses )
|
||||||
import ${packageModelV4}.${class.name};
|
import ${packageModelV4}.${class.name};
|
||||||
#end
|
#end
|
||||||
|
@ -138,7 +138,7 @@ public class ${className}
|
||||||
* @param serializer a serializer object.
|
* @param serializer a serializer object.
|
||||||
* @throws java.io.IOException java.io.IOException if any.
|
* @throws java.io.IOException java.io.IOException if any.
|
||||||
*/
|
*/
|
||||||
protected void writeDomToSerializer( org.apache.maven.api.xml.Dom dom, XmlSerializer serializer )
|
protected void writeDomToSerializer( org.apache.maven.api.xml.XmlNode dom, XmlSerializer serializer )
|
||||||
throws java.io.IOException
|
throws java.io.IOException
|
||||||
{
|
{
|
||||||
serializer.startTag( NAMESPACE, dom.getName() );
|
serializer.startTag( NAMESPACE, dom.getName() );
|
||||||
|
@ -147,7 +147,7 @@ public class ${className}
|
||||||
{
|
{
|
||||||
serializer.attribute( NAMESPACE, attribute.getKey(), attribute.getValue() );
|
serializer.attribute( NAMESPACE, attribute.getKey(), attribute.getValue() );
|
||||||
}
|
}
|
||||||
for ( Dom aChild : dom.getChildren() )
|
for ( XmlNode aChild : dom.getChildren() )
|
||||||
{
|
{
|
||||||
writeDomToSerializer( aChild, serializer );
|
writeDomToSerializer( aChild, serializer );
|
||||||
}
|
}
|
||||||
|
@ -160,7 +160,7 @@ public class ${className}
|
||||||
|
|
||||||
serializer.endTag( NAMESPACE, dom.getName() );
|
serializer.endTag( NAMESPACE, dom.getName() );
|
||||||
|
|
||||||
} //-- void writeDomToSerializer( org.apache.maven.api.xml.Dom, XmlSerializer )
|
} //-- void writeDomToSerializer( org.apache.maven.api.xml.XmlNode, XmlSerializer )
|
||||||
|
|
||||||
|
|
||||||
#foreach ( $class in $model.allClasses )
|
#foreach ( $class in $model.allClasses )
|
||||||
|
@ -287,7 +287,7 @@ public class ${className}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeDom( Dom dom, XmlSerializer serializer )
|
private void writeDom( XmlNode dom, XmlSerializer serializer )
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
if ( dom != null )
|
if ( dom != null )
|
||||||
|
@ -297,7 +297,7 @@ public class ${className}
|
||||||
{
|
{
|
||||||
serializer.attribute( NAMESPACE, attr.getKey(), attr.getValue() );
|
serializer.attribute( NAMESPACE, attr.getKey(), attr.getValue() );
|
||||||
}
|
}
|
||||||
for ( Dom child : dom.getChildren() )
|
for ( XmlNode child : dom.getChildren() )
|
||||||
{
|
{
|
||||||
writeDom( child, serializer );
|
writeDom( child, serializer );
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,7 +25,7 @@ import java.util.Map;
|
||||||
|
|
||||||
import org.apache.maven.api.toolchain.PersistedToolchains;
|
import org.apache.maven.api.toolchain.PersistedToolchains;
|
||||||
import org.apache.maven.api.toolchain.ToolchainModel;
|
import org.apache.maven.api.toolchain.ToolchainModel;
|
||||||
import org.apache.maven.api.xml.Dom;
|
import org.apache.maven.api.xml.XmlNode;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -72,9 +72,9 @@ public class MavenToolchainMerger {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected ToolchainModel mergeToolchainModelConfiguration(ToolchainModel target, ToolchainModel source) {
|
protected ToolchainModel mergeToolchainModelConfiguration(ToolchainModel target, ToolchainModel source) {
|
||||||
Dom src = source.getConfiguration();
|
XmlNode src = source.getConfiguration();
|
||||||
Dom tgt = target.getConfiguration();
|
XmlNode tgt = target.getConfiguration();
|
||||||
Dom merged = Dom.merge(tgt, src);
|
XmlNode merged = XmlNode.merge(tgt, src);
|
||||||
return target.withConfiguration(merged);
|
return target.withConfiguration(merged);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,7 +27,7 @@ import java.util.Map;
|
||||||
import org.apache.maven.api.toolchain.PersistedToolchains;
|
import org.apache.maven.api.toolchain.PersistedToolchains;
|
||||||
import org.apache.maven.api.toolchain.ToolchainModel;
|
import org.apache.maven.api.toolchain.ToolchainModel;
|
||||||
import org.apache.maven.building.StringSource;
|
import org.apache.maven.building.StringSource;
|
||||||
import org.apache.maven.internal.xml.Xpp3Dom;
|
import org.apache.maven.internal.xml.XmlNodeImpl;
|
||||||
import org.apache.maven.toolchain.io.DefaultToolchainsReader;
|
import org.apache.maven.toolchain.io.DefaultToolchainsReader;
|
||||||
import org.apache.maven.toolchain.io.DefaultToolchainsWriter;
|
import org.apache.maven.toolchain.io.DefaultToolchainsWriter;
|
||||||
import org.apache.maven.toolchain.io.ToolchainsParseException;
|
import org.apache.maven.toolchain.io.ToolchainsParseException;
|
||||||
|
@ -236,9 +236,9 @@ public class DefaultToolchainsBuilderTest {
|
||||||
|
|
||||||
Map<String, String> props = new HashMap<>();
|
Map<String, String> props = new HashMap<>();
|
||||||
props.put("key", "${env.testKey}");
|
props.put("key", "${env.testKey}");
|
||||||
Xpp3Dom configurationChild = new Xpp3Dom("jdkHome", "${env.testKey}", null, null, null);
|
XmlNodeImpl configurationChild = new XmlNodeImpl("jdkHome", "${env.testKey}", null, null, null);
|
||||||
Xpp3Dom configuration =
|
XmlNodeImpl configuration =
|
||||||
new Xpp3Dom("configuration", null, null, Collections.singletonList(configurationChild), null);
|
new XmlNodeImpl("configuration", null, null, Collections.singletonList(configurationChild), null);
|
||||||
ToolchainModel toolchain = ToolchainModel.newBuilder()
|
ToolchainModel toolchain = ToolchainModel.newBuilder()
|
||||||
.type("TYPE")
|
.type("TYPE")
|
||||||
.provides(props)
|
.provides(props)
|
||||||
|
|
|
@ -22,7 +22,7 @@ import java.io.InputStream;
|
||||||
|
|
||||||
import org.apache.maven.api.toolchain.PersistedToolchains;
|
import org.apache.maven.api.toolchain.PersistedToolchains;
|
||||||
import org.apache.maven.api.toolchain.TrackableBase;
|
import org.apache.maven.api.toolchain.TrackableBase;
|
||||||
import org.apache.maven.api.xml.Dom;
|
import org.apache.maven.api.xml.XmlNode;
|
||||||
import org.apache.maven.toolchain.v4.MavenToolchainsXpp3Reader;
|
import org.apache.maven.toolchain.v4.MavenToolchainsXpp3Reader;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
@ -94,10 +94,10 @@ public class MavenToolchainMergerTest {
|
||||||
|
|
||||||
PersistedToolchains merged = merger.merge(jdks, jdksExtend, TrackableBase.USER_LEVEL);
|
PersistedToolchains merged = merger.merge(jdks, jdksExtend, TrackableBase.USER_LEVEL);
|
||||||
assertEquals(2, merged.getToolchains().size());
|
assertEquals(2, merged.getToolchains().size());
|
||||||
Dom config0 = merged.getToolchains().get(0).getConfiguration();
|
XmlNode config0 = merged.getToolchains().get(0).getConfiguration();
|
||||||
assertEquals("lib/tools.jar", config0.getChild("toolsJar").getValue());
|
assertEquals("lib/tools.jar", config0.getChild("toolsJar").getValue());
|
||||||
assertEquals(2, config0.getChildren().size());
|
assertEquals(2, config0.getChildren().size());
|
||||||
Dom config1 = merged.getToolchains().get(1).getConfiguration();
|
XmlNode config1 = merged.getToolchains().get(1).getConfiguration();
|
||||||
assertEquals(2, config1.getChildren().size());
|
assertEquals(2, config1.getChildren().size());
|
||||||
assertEquals("lib/classes.jar", config1.getChild("toolsJar").getValue());
|
assertEquals("lib/classes.jar", config1.getChild("toolsJar").getValue());
|
||||||
assertEquals(2, jdks.getToolchains().size());
|
assertEquals(2, jdks.getToolchains().size());
|
||||||
|
@ -112,10 +112,10 @@ public class MavenToolchainMergerTest {
|
||||||
// switch dominant with recessive
|
// switch dominant with recessive
|
||||||
PersistedToolchains merged = merger.merge(jdksExtend, jdks, TrackableBase.USER_LEVEL);
|
PersistedToolchains merged = merger.merge(jdksExtend, jdks, TrackableBase.USER_LEVEL);
|
||||||
assertEquals(2, merged.getToolchains().size());
|
assertEquals(2, merged.getToolchains().size());
|
||||||
Dom config0 = merged.getToolchains().get(0).getConfiguration();
|
XmlNode config0 = merged.getToolchains().get(0).getConfiguration();
|
||||||
assertEquals("lib/tools.jar", config0.getChild("toolsJar").getValue());
|
assertEquals("lib/tools.jar", config0.getChild("toolsJar").getValue());
|
||||||
assertEquals(2, config0.getChildren().size());
|
assertEquals(2, config0.getChildren().size());
|
||||||
Dom config1 = merged.getToolchains().get(1).getConfiguration();
|
XmlNode config1 = merged.getToolchains().get(1).getConfiguration();
|
||||||
assertEquals(2, config1.getChildren().size());
|
assertEquals(2, config1.getChildren().size());
|
||||||
assertEquals("lib/classes.jar", config1.getChild("toolsJar").getValue());
|
assertEquals("lib/classes.jar", config1.getChild("toolsJar").getValue());
|
||||||
assertEquals(2, jdks.getToolchains().size());
|
assertEquals(2, jdks.getToolchains().size());
|
||||||
|
|
|
@ -44,7 +44,7 @@ import java.util.function.Function;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.apache.maven.api.annotations.Generated;
|
import org.apache.maven.api.annotations.Generated;
|
||||||
import org.apache.maven.api.xml.Dom;
|
import org.apache.maven.api.xml.XmlNode;
|
||||||
#foreach ( $class in $model.allClasses )
|
#foreach ( $class in $model.allClasses )
|
||||||
import ${packageModelV4}.${class.Name};
|
import ${packageModelV4}.${class.Name};
|
||||||
#end
|
#end
|
||||||
|
@ -171,10 +171,10 @@ public class ${className}
|
||||||
#elseif ( $field.to && $field.multiplicity == "*" )
|
#elseif ( $field.to && $field.multiplicity == "*" )
|
||||||
builder.${field.name}( merge( target.get${capField}(), source.get${capField}(), sourceDominant, get${field.to}Key() ) );
|
builder.${field.name}( merge( target.get${capField}(), source.get${capField}(), sourceDominant, get${field.to}Key() ) );
|
||||||
#elseif ( $field.type == "DOM" )
|
#elseif ( $field.type == "DOM" )
|
||||||
Dom src = source.getConfiguration();
|
XmlNode src = source.getConfiguration();
|
||||||
if ( src != null )
|
if ( src != null )
|
||||||
{
|
{
|
||||||
Dom tgt = target.getConfiguration();
|
XmlNode tgt = target.getConfiguration();
|
||||||
if ( tgt == null )
|
if ( tgt == null )
|
||||||
{
|
{
|
||||||
builder.configuration( src );
|
builder.configuration( src );
|
||||||
|
|
|
@ -47,7 +47,7 @@ import java.util.Map;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import org.apache.maven.api.annotations.Generated;
|
import org.apache.maven.api.annotations.Generated;
|
||||||
import org.apache.maven.internal.xml.DomBuilder;
|
import org.apache.maven.internal.xml.XmlNodeBuilder;
|
||||||
#foreach ( $class in $model.allClasses )
|
#foreach ( $class in $model.allClasses )
|
||||||
import ${packageModelV4}.${class.name};
|
import ${packageModelV4}.${class.name};
|
||||||
#end
|
#end
|
||||||
|
@ -754,7 +754,7 @@ public class ${className}
|
||||||
${classLcapName}.${field.name}( getIntegerValue( interpolatedTrimmed( parser.nextText(), "${fieldTagName}" ), "${fieldTagName}", parser, strict, ${field.defaultValue} ) );
|
${classLcapName}.${field.name}( getIntegerValue( interpolatedTrimmed( parser.nextText(), "${fieldTagName}" ), "${fieldTagName}", parser, strict, ${field.defaultValue} ) );
|
||||||
break;
|
break;
|
||||||
#elseif ( $field.type == "DOM" )
|
#elseif ( $field.type == "DOM" )
|
||||||
${classLcapName}.${field.name}( DomBuilder.build( parser, true ) );
|
${classLcapName}.${field.name}( XmlNodeBuilder.build( parser, true ) );
|
||||||
break;
|
break;
|
||||||
#elseif ( $field.type == "java.util.List" && $field.to == "String" && $field.multiplicity == "*" )
|
#elseif ( $field.type == "java.util.List" && $field.to == "String" && $field.multiplicity == "*" )
|
||||||
List<String> ${field.name} = new ArrayList<>();
|
List<String> ${field.name} = new ArrayList<>();
|
||||||
|
|
|
@ -48,8 +48,8 @@ import java.util.Objects;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import org.apache.maven.api.annotations.Generated;
|
import org.apache.maven.api.annotations.Generated;
|
||||||
import org.apache.maven.api.xml.Dom;
|
import org.apache.maven.api.xml.XmlNode;
|
||||||
import org.apache.maven.internal.xml.DomBuilder;
|
import org.apache.maven.internal.xml.XmlNodeBuilder;
|
||||||
#foreach ( $class in $model.allClasses )
|
#foreach ( $class in $model.allClasses )
|
||||||
import ${packageModelV4}.${class.name};
|
import ${packageModelV4}.${class.name};
|
||||||
#end
|
#end
|
||||||
|
@ -138,7 +138,7 @@ public class ${className}
|
||||||
* @param serializer a serializer object.
|
* @param serializer a serializer object.
|
||||||
* @throws java.io.IOException java.io.IOException if any.
|
* @throws java.io.IOException java.io.IOException if any.
|
||||||
*/
|
*/
|
||||||
protected void writeDomToSerializer( org.apache.maven.api.xml.Dom dom, XmlSerializer serializer )
|
protected void writeDomToSerializer( org.apache.maven.api.xml.XmlNode dom, XmlSerializer serializer )
|
||||||
throws java.io.IOException
|
throws java.io.IOException
|
||||||
{
|
{
|
||||||
serializer.startTag( NAMESPACE, dom.getName() );
|
serializer.startTag( NAMESPACE, dom.getName() );
|
||||||
|
@ -147,7 +147,7 @@ public class ${className}
|
||||||
{
|
{
|
||||||
serializer.attribute( NAMESPACE, attribute.getKey(), attribute.getValue() );
|
serializer.attribute( NAMESPACE, attribute.getKey(), attribute.getValue() );
|
||||||
}
|
}
|
||||||
for ( Dom aChild : dom.getChildren() )
|
for ( XmlNode aChild : dom.getChildren() )
|
||||||
{
|
{
|
||||||
writeDomToSerializer( aChild, serializer );
|
writeDomToSerializer( aChild, serializer );
|
||||||
}
|
}
|
||||||
|
@ -160,7 +160,7 @@ public class ${className}
|
||||||
|
|
||||||
serializer.endTag( NAMESPACE, dom.getName() );
|
serializer.endTag( NAMESPACE, dom.getName() );
|
||||||
|
|
||||||
} //-- void writeDomToSerializer( org.apache.maven.api.xml.Dom, XmlSerializer )
|
} //-- void writeDomToSerializer( org.apache.maven.api.xml.XmlNode, XmlSerializer )
|
||||||
|
|
||||||
|
|
||||||
#foreach ( $class in $model.allClasses )
|
#foreach ( $class in $model.allClasses )
|
||||||
|
@ -287,7 +287,7 @@ public class ${className}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeDom( Dom dom, XmlSerializer serializer )
|
private void writeDom( XmlNode dom, XmlSerializer serializer )
|
||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
if ( dom != null )
|
if ( dom != null )
|
||||||
|
@ -297,7 +297,7 @@ public class ${className}
|
||||||
{
|
{
|
||||||
serializer.attribute( NAMESPACE, attr.getKey(), attr.getValue() );
|
serializer.attribute( NAMESPACE, attr.getKey(), attr.getValue() );
|
||||||
}
|
}
|
||||||
for ( Dom child : dom.getChildren() )
|
for ( XmlNode child : dom.getChildren() )
|
||||||
{
|
{
|
||||||
writeDom( child, serializer );
|
writeDom( child, serializer );
|
||||||
}
|
}
|
||||||
|
|
|
@ -17,6 +17,6 @@
|
||||||
Apache Maven XML Impl
|
Apache Maven XML Impl
|
||||||
=========================
|
=========================
|
||||||
|
|
||||||
This module contains the implementation of the `org.apache.maven.api.xml.Dom` interface used to convey XML snippets in the object model, and also the modified `org.codehaus.plexus.util.xml` package which wraps the immutable objects from `org.apache.maven.api.xml.Dom` in order to provide compatibility and interoperability between the API v3.x and v4.x.
|
This module contains the implementation of the `org.apache.maven.api.xml.XmlNode` interface used to convey XML snippets in the object model, and also the modified `org.codehaus.plexus.util.xml` package which wraps the immutable objects from `org.apache.maven.api.xml.XmlNode` in order to provide compatibility and interoperability between the API v3.x and v4.x.
|
||||||
|
|
||||||
See [plexus-utils](../plexus-utils/README.md) for more information.
|
See [plexus-utils](../plexus-utils/README.md) for more information.
|
||||||
|
|
|
@ -1,73 +0,0 @@
|
||||||
/*
|
|
||||||
* Licensed to the Apache Software Foundation (ASF) under one
|
|
||||||
* or more contributor license agreements. See the NOTICE file
|
|
||||||
* distributed with this work for additional information
|
|
||||||
* regarding copyright ownership. The ASF licenses this file
|
|
||||||
* to you under the Apache License, Version 2.0 (the
|
|
||||||
* "License"); you may not use this file except in compliance
|
|
||||||
* with the License. You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing,
|
|
||||||
* software distributed under the License is distributed on an
|
|
||||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
||||||
* KIND, either express or implied. See the License for the
|
|
||||||
* specific language governing permissions and limitations
|
|
||||||
* under the License.
|
|
||||||
*/
|
|
||||||
package org.apache.maven.internal.xml;
|
|
||||||
|
|
||||||
import java.io.Reader;
|
|
||||||
|
|
||||||
import org.codehaus.plexus.util.xml.pull.MXParser;
|
|
||||||
import org.codehaus.plexus.util.xml.pull.XmlPullParser;
|
|
||||||
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
|
|
||||||
|
|
||||||
public class DomBuilder {
|
|
||||||
|
|
||||||
public static Xpp3Dom build(Reader reader) throws MavenXmlException {
|
|
||||||
return build(reader, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Xpp3Dom build(Reader reader, boolean trim) throws MavenXmlException {
|
|
||||||
try {
|
|
||||||
MXParser parser = new MXParser();
|
|
||||||
parser.setInput(reader);
|
|
||||||
return build(parser, trim);
|
|
||||||
} catch (XmlPullParserException e) {
|
|
||||||
throw new MavenXmlException("Unable to build DOM", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Xpp3Dom build(XmlPullParser parser) {
|
|
||||||
return build(parser, true, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Xpp3Dom build(XmlPullParser parser, boolean trim) {
|
|
||||||
return build(parser, trim, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Xpp3Dom build(XmlPullParser parser, boolean trim, LocationBuilder locationBuilder) {
|
|
||||||
try {
|
|
||||||
Xpp3DomBuilder.InputLocationBuilder ilb =
|
|
||||||
locationBuilder != null ? (p -> locationBuilder.getLocation()) : null;
|
|
||||||
return Xpp3DomBuilder.build(parser, trim, ilb);
|
|
||||||
} catch (Exception e) {
|
|
||||||
throw new MavenXmlException("Unable to build DOM", e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class LocationBuilder {
|
|
||||||
|
|
||||||
private final Object location;
|
|
||||||
|
|
||||||
public LocationBuilder(Object location) {
|
|
||||||
this.location = location;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Object getLocation() {
|
|
||||||
return location;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -26,7 +26,7 @@ import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.maven.api.xml.Dom;
|
import org.apache.maven.api.xml.XmlNode;
|
||||||
import org.codehaus.plexus.util.IOUtil;
|
import org.codehaus.plexus.util.IOUtil;
|
||||||
import org.codehaus.plexus.util.xml.pull.MXParser;
|
import org.codehaus.plexus.util.xml.pull.MXParser;
|
||||||
import org.codehaus.plexus.util.xml.pull.XmlPullParser;
|
import org.codehaus.plexus.util.xml.pull.XmlPullParser;
|
||||||
|
@ -35,10 +35,10 @@ import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class Xpp3DomBuilder {
|
public class XmlNodeBuilder {
|
||||||
private static final boolean DEFAULT_TRIM = true;
|
private static final boolean DEFAULT_TRIM = true;
|
||||||
|
|
||||||
public static Xpp3Dom build(Reader reader) throws XmlPullParserException, IOException {
|
public static XmlNodeImpl build(Reader reader) throws XmlPullParserException, IOException {
|
||||||
return build(reader, null);
|
return build(reader, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,32 +50,32 @@ public class Xpp3DomBuilder {
|
||||||
* @throws XmlPullParserException xml exception
|
* @throws XmlPullParserException xml exception
|
||||||
* @throws IOException io
|
* @throws IOException io
|
||||||
*/
|
*/
|
||||||
public static Xpp3Dom build(Reader reader, InputLocationBuilder locationBuilder)
|
public static XmlNodeImpl build(Reader reader, InputLocationBuilder locationBuilder)
|
||||||
throws XmlPullParserException, IOException {
|
throws XmlPullParserException, IOException {
|
||||||
return build(reader, DEFAULT_TRIM, locationBuilder);
|
return build(reader, DEFAULT_TRIM, locationBuilder);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Xpp3Dom build(InputStream is, String encoding) throws XmlPullParserException, IOException {
|
public static XmlNodeImpl build(InputStream is, String encoding) throws XmlPullParserException, IOException {
|
||||||
return build(is, encoding, DEFAULT_TRIM);
|
return build(is, encoding, DEFAULT_TRIM);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Xpp3Dom build(InputStream is, String encoding, boolean trim)
|
public static XmlNodeImpl build(InputStream is, String encoding, boolean trim)
|
||||||
throws XmlPullParserException, IOException {
|
throws XmlPullParserException, IOException {
|
||||||
try {
|
try {
|
||||||
final XmlPullParser parser = new MXParser();
|
final XmlPullParser parser = new MXParser();
|
||||||
parser.setInput(is, encoding);
|
parser.setInput(is, encoding);
|
||||||
|
|
||||||
final Xpp3Dom xpp3Dom = build(parser, trim);
|
final XmlNodeImpl node = build(parser, trim);
|
||||||
is.close();
|
is.close();
|
||||||
is = null;
|
is = null;
|
||||||
|
|
||||||
return xpp3Dom;
|
return node;
|
||||||
} finally {
|
} finally {
|
||||||
IOUtil.close(is);
|
IOUtil.close(is);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Xpp3Dom build(Reader reader, boolean trim) throws XmlPullParserException, IOException {
|
public static XmlNodeImpl build(Reader reader, boolean trim) throws XmlPullParserException, IOException {
|
||||||
return build(reader, trim, null);
|
return build(reader, trim, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -88,27 +88,27 @@ public class Xpp3DomBuilder {
|
||||||
* @throws XmlPullParserException xml exception
|
* @throws XmlPullParserException xml exception
|
||||||
* @throws IOException io
|
* @throws IOException io
|
||||||
*/
|
*/
|
||||||
public static Xpp3Dom build(Reader reader, boolean trim, InputLocationBuilder locationBuilder)
|
public static XmlNodeImpl build(Reader reader, boolean trim, InputLocationBuilder locationBuilder)
|
||||||
throws XmlPullParserException, IOException {
|
throws XmlPullParserException, IOException {
|
||||||
try {
|
try {
|
||||||
final XmlPullParser parser = new MXParser();
|
final XmlPullParser parser = new MXParser();
|
||||||
parser.setInput(reader);
|
parser.setInput(reader);
|
||||||
|
|
||||||
final Xpp3Dom xpp3Dom = build(parser, trim, locationBuilder);
|
final XmlNodeImpl node = build(parser, trim, locationBuilder);
|
||||||
reader.close();
|
reader.close();
|
||||||
reader = null;
|
reader = null;
|
||||||
|
|
||||||
return xpp3Dom;
|
return node;
|
||||||
} finally {
|
} finally {
|
||||||
IOUtil.close(reader);
|
IOUtil.close(reader);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Xpp3Dom build(XmlPullParser parser) throws XmlPullParserException, IOException {
|
public static XmlNodeImpl build(XmlPullParser parser) throws XmlPullParserException, IOException {
|
||||||
return build(parser, DEFAULT_TRIM);
|
return build(parser, DEFAULT_TRIM);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Xpp3Dom build(XmlPullParser parser, boolean trim) throws XmlPullParserException, IOException {
|
public static XmlNodeImpl build(XmlPullParser parser, boolean trim) throws XmlPullParserException, IOException {
|
||||||
return build(parser, trim, null);
|
return build(parser, trim, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -121,14 +121,14 @@ public class Xpp3DomBuilder {
|
||||||
* @throws XmlPullParserException xml exception
|
* @throws XmlPullParserException xml exception
|
||||||
* @throws IOException io
|
* @throws IOException io
|
||||||
*/
|
*/
|
||||||
public static Xpp3Dom build(XmlPullParser parser, boolean trim, InputLocationBuilder locationBuilder)
|
public static XmlNodeImpl build(XmlPullParser parser, boolean trim, InputLocationBuilder locationBuilder)
|
||||||
throws XmlPullParserException, IOException {
|
throws XmlPullParserException, IOException {
|
||||||
boolean spacePreserve = false;
|
boolean spacePreserve = false;
|
||||||
String name = null;
|
String name = null;
|
||||||
String value = null;
|
String value = null;
|
||||||
Object location = null;
|
Object location = null;
|
||||||
Map<String, String> attrs = null;
|
Map<String, String> attrs = null;
|
||||||
List<Dom> children = null;
|
List<XmlNode> children = null;
|
||||||
int eventType = parser.getEventType();
|
int eventType = parser.getEventType();
|
||||||
boolean emptyTag = false;
|
boolean emptyTag = false;
|
||||||
while (eventType != XmlPullParser.END_DOCUMENT) {
|
while (eventType != XmlPullParser.END_DOCUMENT) {
|
||||||
|
@ -151,7 +151,7 @@ public class Xpp3DomBuilder {
|
||||||
if (children == null) {
|
if (children == null) {
|
||||||
children = new ArrayList<>();
|
children = new ArrayList<>();
|
||||||
}
|
}
|
||||||
Dom child = build(parser, trim, locationBuilder);
|
XmlNode child = build(parser, trim, locationBuilder);
|
||||||
children.add(child);
|
children.add(child);
|
||||||
}
|
}
|
||||||
} else if (eventType == XmlPullParser.TEXT) {
|
} else if (eventType == XmlPullParser.TEXT) {
|
||||||
|
@ -161,7 +161,7 @@ public class Xpp3DomBuilder {
|
||||||
}
|
}
|
||||||
value = value != null ? value + text : text;
|
value = value != null ? value + text : text;
|
||||||
} else if (eventType == XmlPullParser.END_TAG) {
|
} else if (eventType == XmlPullParser.END_TAG) {
|
||||||
return new Xpp3Dom(
|
return new XmlNodeImpl(
|
||||||
name,
|
name,
|
||||||
children == null ? (value != null ? value : emptyTag ? null : "") : null,
|
children == null ? (value != null ? value : emptyTag ? null : "") : null,
|
||||||
attrs,
|
attrs,
|
|
@ -34,7 +34,7 @@ import java.util.Set;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
import org.apache.maven.api.xml.Dom;
|
import org.apache.maven.api.xml.XmlNode;
|
||||||
import org.codehaus.plexus.util.xml.PrettyPrintXMLWriter;
|
import org.codehaus.plexus.util.xml.PrettyPrintXMLWriter;
|
||||||
import org.codehaus.plexus.util.xml.SerializerXMLWriter;
|
import org.codehaus.plexus.util.xml.SerializerXMLWriter;
|
||||||
import org.codehaus.plexus.util.xml.XMLWriter;
|
import org.codehaus.plexus.util.xml.XMLWriter;
|
||||||
|
@ -43,7 +43,7 @@ import org.codehaus.plexus.util.xml.pull.XmlSerializer;
|
||||||
/**
|
/**
|
||||||
* NOTE: remove all the util code in here when separated, this class should be pure data.
|
* NOTE: remove all the util code in here when separated, this class should be pure data.
|
||||||
*/
|
*/
|
||||||
public class Xpp3Dom implements Serializable, Dom {
|
public class XmlNodeImpl implements Serializable, XmlNode {
|
||||||
private static final long serialVersionUID = 2567894443061173996L;
|
private static final long serialVersionUID = 2567894443061173996L;
|
||||||
|
|
||||||
protected final String name;
|
protected final String name;
|
||||||
|
@ -52,23 +52,24 @@ public class Xpp3Dom implements Serializable, Dom {
|
||||||
|
|
||||||
protected final Map<String, String> attributes;
|
protected final Map<String, String> attributes;
|
||||||
|
|
||||||
protected final List<Dom> children;
|
protected final List<XmlNode> children;
|
||||||
|
|
||||||
protected final Object location;
|
protected final Object location;
|
||||||
|
|
||||||
public Xpp3Dom(String name) {
|
public XmlNodeImpl(String name) {
|
||||||
this(name, null, null, null, null);
|
this(name, null, null, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Xpp3Dom(String name, String value) {
|
public XmlNodeImpl(String name, String value) {
|
||||||
this(name, value, null, null, null);
|
this(name, value, null, null, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Xpp3Dom(Dom from, String name) {
|
public XmlNodeImpl(XmlNode from, String name) {
|
||||||
this(name, from.getValue(), from.getAttributes(), from.getChildren(), from.getInputLocation());
|
this(name, from.getValue(), from.getAttributes(), from.getChildren(), from.getInputLocation());
|
||||||
}
|
}
|
||||||
|
|
||||||
public Xpp3Dom(String name, String value, Map<String, String> attributes, List<Dom> children, Object location) {
|
public XmlNodeImpl(
|
||||||
|
String name, String value, Map<String, String> attributes, List<XmlNode> children, Object location) {
|
||||||
this.name = Objects.requireNonNull(name);
|
this.name = Objects.requireNonNull(name);
|
||||||
this.value = value;
|
this.value = value;
|
||||||
this.attributes =
|
this.attributes =
|
||||||
|
@ -79,11 +80,11 @@ public class Xpp3Dom implements Serializable, Dom {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Dom merge(Dom source, Boolean childMergeOverride) {
|
public XmlNode merge(XmlNode source, Boolean childMergeOverride) {
|
||||||
return merge(this, source, childMergeOverride);
|
return merge(this, source, childMergeOverride);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Dom clone() {
|
public XmlNode clone() {
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,11 +121,11 @@ public class Xpp3Dom implements Serializable, Dom {
|
||||||
// Child handling
|
// Child handling
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
|
||||||
public Dom getChild(String name) {
|
public XmlNode getChild(String name) {
|
||||||
if (name != null) {
|
if (name != null) {
|
||||||
ListIterator<Dom> it = children.listIterator(children.size());
|
ListIterator<XmlNode> it = children.listIterator(children.size());
|
||||||
while (it.hasPrevious()) {
|
while (it.hasPrevious()) {
|
||||||
Dom child = it.previous();
|
XmlNode child = it.previous();
|
||||||
if (name.equals(child.getName())) {
|
if (name.equals(child.getName())) {
|
||||||
return child;
|
return child;
|
||||||
}
|
}
|
||||||
|
@ -133,7 +134,7 @@ public class Xpp3Dom implements Serializable, Dom {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Dom> getChildren() {
|
public List<XmlNode> getChildren() {
|
||||||
return children;
|
return children;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -161,7 +162,7 @@ public class Xpp3Dom implements Serializable, Dom {
|
||||||
// TODO: WARNING! Later versions of plexus-utils psit out an <?xml ?> header due to thinking this is a new
|
// TODO: WARNING! Later versions of plexus-utils psit out an <?xml ?> header due to thinking this is a new
|
||||||
// document - not the desired behaviour!
|
// document - not the desired behaviour!
|
||||||
SerializerXMLWriter xmlWriter = new SerializerXMLWriter(namespace, serializer);
|
SerializerXMLWriter xmlWriter = new SerializerXMLWriter(namespace, serializer);
|
||||||
Xpp3DomWriter.write(xmlWriter, this);
|
XmlNodeWriter.write(xmlWriter, this);
|
||||||
if (xmlWriter.getExceptions().size() > 0) {
|
if (xmlWriter.getExceptions().size() > 0) {
|
||||||
throw (IOException) xmlWriter.getExceptions().get(0);
|
throw (IOException) xmlWriter.getExceptions().get(0);
|
||||||
}
|
}
|
||||||
|
@ -203,7 +204,7 @@ public class Xpp3Dom implements Serializable, Dom {
|
||||||
* </ol>
|
* </ol>
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("checkstyle:MethodLength")
|
@SuppressWarnings("checkstyle:MethodLength")
|
||||||
public static Dom merge(Dom dominant, Dom recessive, Boolean childMergeOverride) {
|
public static XmlNode merge(XmlNode dominant, XmlNode recessive, Boolean childMergeOverride) {
|
||||||
// TODO: share this as some sort of assembler, implement a walk interface?
|
// TODO: share this as some sort of assembler, implement a walk interface?
|
||||||
if (recessive == null) {
|
if (recessive == null) {
|
||||||
return dominant;
|
return dominant;
|
||||||
|
@ -225,7 +226,7 @@ public class Xpp3Dom implements Serializable, Dom {
|
||||||
String value = dominant.getValue();
|
String value = dominant.getValue();
|
||||||
Object location = dominant.getInputLocation();
|
Object location = dominant.getInputLocation();
|
||||||
Map<String, String> attrs = null;
|
Map<String, String> attrs = null;
|
||||||
List<Dom> children = null;
|
List<XmlNode> children = null;
|
||||||
|
|
||||||
for (Map.Entry<String, String> attr : recessive.getAttributes().entrySet()) {
|
for (Map.Entry<String, String> attr : recessive.getAttributes().entrySet()) {
|
||||||
String key = attr.getKey();
|
String key = attr.getKey();
|
||||||
|
@ -250,12 +251,12 @@ public class Xpp3Dom implements Serializable, Dom {
|
||||||
|
|
||||||
String keysValue = recessive.getAttribute(KEYS_COMBINATION_MODE_ATTRIBUTE);
|
String keysValue = recessive.getAttribute(KEYS_COMBINATION_MODE_ATTRIBUTE);
|
||||||
|
|
||||||
for (Dom recessiveChild : recessive.getChildren()) {
|
for (XmlNode recessiveChild : recessive.getChildren()) {
|
||||||
String idValue = recessiveChild.getAttribute(ID_COMBINATION_MODE_ATTRIBUTE);
|
String idValue = recessiveChild.getAttribute(ID_COMBINATION_MODE_ATTRIBUTE);
|
||||||
|
|
||||||
Dom childDom = null;
|
XmlNode childDom = null;
|
||||||
if (isNotEmpty(idValue)) {
|
if (isNotEmpty(idValue)) {
|
||||||
for (Dom dominantChild : dominant.getChildren()) {
|
for (XmlNode dominantChild : dominant.getChildren()) {
|
||||||
if (idValue.equals(dominantChild.getAttribute(ID_COMBINATION_MODE_ATTRIBUTE))) {
|
if (idValue.equals(dominantChild.getAttribute(ID_COMBINATION_MODE_ATTRIBUTE))) {
|
||||||
childDom = dominantChild;
|
childDom = dominantChild;
|
||||||
// we have a match, so don't append but merge
|
// we have a match, so don't append but merge
|
||||||
|
@ -268,7 +269,7 @@ public class Xpp3Dom implements Serializable, Dom {
|
||||||
.collect(Collectors.toMap(
|
.collect(Collectors.toMap(
|
||||||
k -> k, k -> Optional.ofNullable(recessiveChild.getAttribute(k))));
|
k -> k, k -> Optional.ofNullable(recessiveChild.getAttribute(k))));
|
||||||
|
|
||||||
for (Dom dominantChild : dominant.getChildren()) {
|
for (XmlNode dominantChild : dominant.getChildren()) {
|
||||||
Map<String, Optional<String>> dominantKeyValues = Stream.of(keys)
|
Map<String, Optional<String>> dominantKeyValues = Stream.of(keys)
|
||||||
.collect(Collectors.toMap(
|
.collect(Collectors.toMap(
|
||||||
k -> k, k -> Optional.ofNullable(dominantChild.getAttribute(k))));
|
k -> k, k -> Optional.ofNullable(dominantChild.getAttribute(k))));
|
||||||
|
@ -284,12 +285,12 @@ public class Xpp3Dom implements Serializable, Dom {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mergeChildren && childDom != null) {
|
if (mergeChildren && childDom != null) {
|
||||||
Map<String, Iterator<Dom>> commonChildren = new HashMap<>();
|
Map<String, Iterator<XmlNode>> commonChildren = new HashMap<>();
|
||||||
Set<String> names = recessive.getChildren().stream()
|
Set<String> names = recessive.getChildren().stream()
|
||||||
.map(Dom::getName)
|
.map(XmlNode::getName)
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
for (String name : names) {
|
for (String name : names) {
|
||||||
List<Dom> dominantChildren = dominant.getChildren().stream()
|
List<XmlNode> dominantChildren = dominant.getChildren().stream()
|
||||||
.filter(n -> n.getName().equals(name))
|
.filter(n -> n.getName().equals(name))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
if (dominantChildren.size() > 0) {
|
if (dominantChildren.size() > 0) {
|
||||||
|
@ -298,7 +299,7 @@ public class Xpp3Dom implements Serializable, Dom {
|
||||||
}
|
}
|
||||||
|
|
||||||
String name = recessiveChild.getName();
|
String name = recessiveChild.getName();
|
||||||
Iterator<Dom> it =
|
Iterator<XmlNode> it =
|
||||||
commonChildren.computeIfAbsent(name, n1 -> Stream.of(dominant.getChildren().stream()
|
commonChildren.computeIfAbsent(name, n1 -> Stream.of(dominant.getChildren().stream()
|
||||||
.filter(n2 -> n2.getName().equals(n1))
|
.filter(n2 -> n2.getName().equals(n1))
|
||||||
.collect(Collectors.toList()))
|
.collect(Collectors.toList()))
|
||||||
|
@ -312,7 +313,7 @@ public class Xpp3Dom implements Serializable, Dom {
|
||||||
}
|
}
|
||||||
children.add(recessiveChild);
|
children.add(recessiveChild);
|
||||||
} else if (it.hasNext()) {
|
} else if (it.hasNext()) {
|
||||||
Dom dominantChild = it.next();
|
XmlNode dominantChild = it.next();
|
||||||
|
|
||||||
String dominantChildCombinationMode =
|
String dominantChildCombinationMode =
|
||||||
dominantChild.getAttribute(SELF_COMBINATION_MODE_ATTRIBUTE);
|
dominantChild.getAttribute(SELF_COMBINATION_MODE_ATTRIBUTE);
|
||||||
|
@ -323,7 +324,7 @@ public class Xpp3Dom implements Serializable, Dom {
|
||||||
children.remove(dominantChild);
|
children.remove(dominantChild);
|
||||||
} else {
|
} else {
|
||||||
int idx = dominant.getChildren().indexOf(dominantChild);
|
int idx = dominant.getChildren().indexOf(dominantChild);
|
||||||
Dom merged = merge(dominantChild, recessiveChild, childMergeOverride);
|
XmlNode merged = merge(dominantChild, recessiveChild, childMergeOverride);
|
||||||
if (merged != dominantChild) {
|
if (merged != dominantChild) {
|
||||||
if (children == null) {
|
if (children == null) {
|
||||||
children = new ArrayList<>(dominant.getChildren());
|
children = new ArrayList<>(dominant.getChildren());
|
||||||
|
@ -355,7 +356,7 @@ public class Xpp3Dom implements Serializable, Dom {
|
||||||
if (children == null) {
|
if (children == null) {
|
||||||
children = dominant.getChildren();
|
children = dominant.getChildren();
|
||||||
}
|
}
|
||||||
return new Xpp3Dom(
|
return new XmlNodeImpl(
|
||||||
dominant.getName(), value != null ? value : dominant.getValue(), attrs, children, location);
|
dominant.getName(), value != null ? value : dominant.getValue(), attrs, children, location);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -372,7 +373,7 @@ public class Xpp3Dom implements Serializable, Dom {
|
||||||
* @param recessive The recessive DOM, which will be merged into the dominant DOM
|
* @param recessive The recessive DOM, which will be merged into the dominant DOM
|
||||||
* @return merged DOM
|
* @return merged DOM
|
||||||
*/
|
*/
|
||||||
public static Dom merge(Dom dominant, Dom recessive) {
|
public static XmlNode merge(XmlNode dominant, XmlNode recessive) {
|
||||||
return merge(dominant, recessive, null);
|
return merge(dominant, recessive, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -388,11 +389,11 @@ public class Xpp3Dom implements Serializable, Dom {
|
||||||
if (o == null || getClass() != o.getClass()) {
|
if (o == null || getClass() != o.getClass()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
Xpp3Dom xpp3Dom = (Xpp3Dom) o;
|
XmlNodeImpl that = (XmlNodeImpl) o;
|
||||||
return name.equals(xpp3Dom.name)
|
return Objects.equals(this.name, that.name)
|
||||||
&& Objects.equals(value, xpp3Dom.value)
|
&& Objects.equals(this.value, that.value)
|
||||||
&& attributes.equals(xpp3Dom.attributes)
|
&& Objects.equals(this.attributes, that.attributes)
|
||||||
&& children.equals(xpp3Dom.children);
|
&& Objects.equals(this.children, that.children);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -403,14 +404,14 @@ public class Xpp3Dom implements Serializable, Dom {
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
StringWriter writer = new StringWriter();
|
StringWriter writer = new StringWriter();
|
||||||
Xpp3DomWriter.write(writer, this);
|
XmlNodeWriter.write(writer, this);
|
||||||
return writer.toString();
|
return writer.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toUnescapedString() {
|
public String toUnescapedString() {
|
||||||
StringWriter writer = new StringWriter();
|
StringWriter writer = new StringWriter();
|
||||||
XMLWriter xmlWriter = new PrettyPrintXMLWriter(writer);
|
XMLWriter xmlWriter = new PrettyPrintXMLWriter(writer);
|
||||||
Xpp3DomWriter.write(xmlWriter, this, false);
|
XmlNodeWriter.write(xmlWriter, this, false);
|
||||||
return writer.toString();
|
return writer.toString();
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,33 +22,33 @@ import java.io.PrintWriter;
|
||||||
import java.io.Writer;
|
import java.io.Writer;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.maven.api.xml.Dom;
|
import org.apache.maven.api.xml.XmlNode;
|
||||||
import org.codehaus.plexus.util.xml.PrettyPrintXMLWriter;
|
import org.codehaus.plexus.util.xml.PrettyPrintXMLWriter;
|
||||||
import org.codehaus.plexus.util.xml.XMLWriter;
|
import org.codehaus.plexus.util.xml.XMLWriter;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class Xpp3DomWriter {
|
public class XmlNodeWriter {
|
||||||
public static void write(Writer writer, Dom dom) {
|
public static void write(Writer writer, XmlNode dom) {
|
||||||
write(new PrettyPrintXMLWriter(writer), dom);
|
write(new PrettyPrintXMLWriter(writer), dom);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void write(PrintWriter writer, Dom dom) {
|
public static void write(PrintWriter writer, XmlNode dom) {
|
||||||
write(new PrettyPrintXMLWriter(writer), dom);
|
write(new PrettyPrintXMLWriter(writer), dom);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void write(XMLWriter xmlWriter, Dom dom) {
|
public static void write(XMLWriter xmlWriter, XmlNode dom) {
|
||||||
write(xmlWriter, dom, true);
|
write(xmlWriter, dom, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void write(XMLWriter xmlWriter, Dom dom, boolean escape) {
|
public static void write(XMLWriter xmlWriter, XmlNode dom, boolean escape) {
|
||||||
// TODO: move to XMLWriter?
|
// TODO: move to XMLWriter?
|
||||||
xmlWriter.startElement(dom.getName());
|
xmlWriter.startElement(dom.getName());
|
||||||
for (Map.Entry<String, String> attr : dom.getAttributes().entrySet()) {
|
for (Map.Entry<String, String> attr : dom.getAttributes().entrySet()) {
|
||||||
xmlWriter.addAttribute(attr.getKey(), attr.getValue());
|
xmlWriter.addAttribute(attr.getKey(), attr.getValue());
|
||||||
}
|
}
|
||||||
for (Dom aChildren : dom.getChildren()) {
|
for (XmlNode aChildren : dom.getChildren()) {
|
||||||
write(xmlWriter, aChildren, escape);
|
write(xmlWriter, aChildren, escape);
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,16 +18,16 @@
|
||||||
*/
|
*/
|
||||||
package org.apache.maven.internal.xml;
|
package org.apache.maven.internal.xml;
|
||||||
|
|
||||||
import org.apache.maven.api.xml.Dom;
|
import org.apache.maven.api.xml.XmlNode;
|
||||||
import org.codehaus.plexus.configuration.DefaultPlexusConfiguration;
|
import org.codehaus.plexus.configuration.DefaultPlexusConfiguration;
|
||||||
import org.codehaus.plexus.configuration.PlexusConfiguration;
|
import org.codehaus.plexus.configuration.PlexusConfiguration;
|
||||||
|
|
||||||
public class XmlPlexusConfiguration extends DefaultPlexusConfiguration {
|
public class XmlPlexusConfiguration extends DefaultPlexusConfiguration {
|
||||||
public static PlexusConfiguration toPlexusConfiguration(Dom node) {
|
public static PlexusConfiguration toPlexusConfiguration(XmlNode node) {
|
||||||
return new XmlPlexusConfiguration(node);
|
return new XmlPlexusConfiguration(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
public XmlPlexusConfiguration(Dom node) {
|
public XmlPlexusConfiguration(XmlNode node) {
|
||||||
super(node.getName(), node.getValue());
|
super(node.getName(), node.getValue());
|
||||||
node.getAttributes().forEach(this::setAttribute);
|
node.getAttributes().forEach(this::setAttribute);
|
||||||
node.getChildren().forEach(c -> this.addChild(new XmlPlexusConfiguration(c)));
|
node.getChildren().forEach(c -> this.addChild(new XmlPlexusConfiguration(c)));
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
// CHECKSTYLE_OFF: RegexpHeader
|
// CHECKSTYLE_OFF: RegexpHeader
|
||||||
/**
|
/**
|
||||||
* Contains implementation of the {@link org.apache.maven.api.xml.Dom} interface and related classes.
|
* Contains implementation of the {@link org.apache.maven.api.xml.XmlNode} interface and related classes.
|
||||||
*/
|
*/
|
||||||
package org.apache.maven.internal.xml;
|
package org.apache.maven.internal.xml;
|
||||||
|
|
|
@ -25,7 +25,8 @@ import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import org.apache.maven.api.xml.Dom;
|
import org.apache.maven.api.xml.XmlNode;
|
||||||
|
import org.apache.maven.internal.xml.XmlNodeImpl;
|
||||||
import org.codehaus.plexus.util.StringUtils;
|
import org.codehaus.plexus.util.StringUtils;
|
||||||
import org.codehaus.plexus.util.xml.pull.XmlSerializer;
|
import org.codehaus.plexus.util.xml.pull.XmlSerializer;
|
||||||
|
|
||||||
|
@ -67,10 +68,10 @@ public class Xpp3Dom implements Serializable {
|
||||||
public static final String DEFAULT_SELF_COMBINATION_MODE = SELF_COMBINATION_MERGE;
|
public static final String DEFAULT_SELF_COMBINATION_MODE = SELF_COMBINATION_MERGE;
|
||||||
|
|
||||||
private ChildrenTracking childrenTracking;
|
private ChildrenTracking childrenTracking;
|
||||||
private Dom dom;
|
private XmlNode dom;
|
||||||
|
|
||||||
public Xpp3Dom(String name) {
|
public Xpp3Dom(String name) {
|
||||||
this.dom = new org.apache.maven.internal.xml.Xpp3Dom(name);
|
this.dom = new XmlNodeImpl(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -79,7 +80,7 @@ public class Xpp3Dom implements Serializable {
|
||||||
* @param name The name of the Dom.
|
* @param name The name of the Dom.
|
||||||
*/
|
*/
|
||||||
public Xpp3Dom(String name, Object inputLocation) {
|
public Xpp3Dom(String name, Object inputLocation) {
|
||||||
this.dom = new org.apache.maven.internal.xml.Xpp3Dom(name, null, null, null, inputLocation);
|
this.dom = new XmlNodeImpl(name, null, null, null, inputLocation);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -96,24 +97,24 @@ public class Xpp3Dom implements Serializable {
|
||||||
* @param name The name of the Dom.
|
* @param name The name of the Dom.
|
||||||
*/
|
*/
|
||||||
public Xpp3Dom(Xpp3Dom src, String name) {
|
public Xpp3Dom(Xpp3Dom src, String name) {
|
||||||
this.dom = new org.apache.maven.internal.xml.Xpp3Dom(src.dom, name);
|
this.dom = new XmlNodeImpl(src.dom, name);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Xpp3Dom(Dom dom) {
|
public Xpp3Dom(XmlNode dom) {
|
||||||
this.dom = dom;
|
this.dom = dom;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Xpp3Dom(Dom dom, Xpp3Dom parent) {
|
public Xpp3Dom(XmlNode dom, Xpp3Dom parent) {
|
||||||
this.dom = dom;
|
this.dom = dom;
|
||||||
this.childrenTracking = parent::replace;
|
this.childrenTracking = parent::replace;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Xpp3Dom(Dom dom, ChildrenTracking childrenTracking) {
|
public Xpp3Dom(XmlNode dom, ChildrenTracking childrenTracking) {
|
||||||
this.dom = dom;
|
this.dom = dom;
|
||||||
this.childrenTracking = childrenTracking;
|
this.childrenTracking = childrenTracking;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Dom getDom() {
|
public XmlNode getDom() {
|
||||||
return dom;
|
return dom;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,8 +135,7 @@ public class Xpp3Dom implements Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setValue(String value) {
|
public void setValue(String value) {
|
||||||
update(new org.apache.maven.internal.xml.Xpp3Dom(
|
update(new XmlNodeImpl(dom.getName(), value, dom.getAttributes(), dom.getChildren(), dom.getInputLocation()));
|
||||||
dom.getName(), value, dom.getAttributes(), dom.getChildren(), dom.getInputLocation()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
@ -161,7 +161,7 @@ public class Xpp3Dom implements Serializable {
|
||||||
Map<String, String> attrs = new HashMap<>(dom.getAttributes());
|
Map<String, String> attrs = new HashMap<>(dom.getAttributes());
|
||||||
boolean ret = attrs.remove(name) != null;
|
boolean ret = attrs.remove(name) != null;
|
||||||
if (ret) {
|
if (ret) {
|
||||||
update(new org.apache.maven.internal.xml.Xpp3Dom(
|
update(new XmlNodeImpl(
|
||||||
dom.getName(), dom.getValue(), attrs, dom.getChildren(), dom.getInputLocation()));
|
dom.getName(), dom.getValue(), attrs, dom.getChildren(), dom.getInputLocation()));
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -184,8 +184,7 @@ public class Xpp3Dom implements Serializable {
|
||||||
}
|
}
|
||||||
Map<String, String> attrs = new HashMap<>(dom.getAttributes());
|
Map<String, String> attrs = new HashMap<>(dom.getAttributes());
|
||||||
attrs.put(name, value);
|
attrs.put(name, value);
|
||||||
update(new org.apache.maven.internal.xml.Xpp3Dom(
|
update(new XmlNodeImpl(dom.getName(), dom.getValue(), attrs, dom.getChildren(), dom.getInputLocation()));
|
||||||
dom.getName(), dom.getValue(), attrs, dom.getChildren(), dom.getInputLocation()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
@ -197,16 +196,15 @@ public class Xpp3Dom implements Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Xpp3Dom getChild(String name) {
|
public Xpp3Dom getChild(String name) {
|
||||||
Dom child = dom.getChild(name);
|
XmlNode child = dom.getChild(name);
|
||||||
return child != null ? new Xpp3Dom(child, this) : null;
|
return child != null ? new Xpp3Dom(child, this) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addChild(Xpp3Dom xpp3Dom) {
|
public void addChild(Xpp3Dom xpp3Dom) {
|
||||||
List<Dom> children = new ArrayList<>(dom.getChildren());
|
List<XmlNode> children = new ArrayList<>(dom.getChildren());
|
||||||
children.add(xpp3Dom.dom);
|
children.add(xpp3Dom.dom);
|
||||||
xpp3Dom.childrenTracking = this::replace;
|
xpp3Dom.childrenTracking = this::replace;
|
||||||
update(new org.apache.maven.internal.xml.Xpp3Dom(
|
update(new XmlNodeImpl(dom.getName(), dom.getValue(), dom.getAttributes(), children, dom.getInputLocation()));
|
||||||
dom.getName(), dom.getValue(), dom.getAttributes(), children, dom.getInputLocation()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Xpp3Dom[] getChildren() {
|
public Xpp3Dom[] getChildren() {
|
||||||
|
@ -225,17 +223,15 @@ public class Xpp3Dom implements Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeChild(int i) {
|
public void removeChild(int i) {
|
||||||
List<Dom> children = new ArrayList<>(dom.getChildren());
|
List<XmlNode> children = new ArrayList<>(dom.getChildren());
|
||||||
children.remove(i);
|
children.remove(i);
|
||||||
update(new org.apache.maven.internal.xml.Xpp3Dom(
|
update(new XmlNodeImpl(dom.getName(), dom.getValue(), dom.getAttributes(), children, dom.getInputLocation()));
|
||||||
dom.getName(), dom.getValue(), dom.getAttributes(), children, dom.getInputLocation()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeChild(Xpp3Dom child) {
|
public void removeChild(Xpp3Dom child) {
|
||||||
List<Dom> children = new ArrayList<>(dom.getChildren());
|
List<XmlNode> children = new ArrayList<>(dom.getChildren());
|
||||||
children.remove(child.dom);
|
children.remove(child.dom);
|
||||||
update(new org.apache.maven.internal.xml.Xpp3Dom(
|
update(new XmlNodeImpl(dom.getName(), dom.getValue(), dom.getAttributes(), children, dom.getInputLocation()));
|
||||||
dom.getName(), dom.getValue(), dom.getAttributes(), children, dom.getInputLocation()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
@ -265,8 +261,7 @@ public class Xpp3Dom implements Serializable {
|
||||||
* @param inputLocation input location to set
|
* @param inputLocation input location to set
|
||||||
*/
|
*/
|
||||||
public void setInputLocation(Object inputLocation) {
|
public void setInputLocation(Object inputLocation) {
|
||||||
update(new org.apache.maven.internal.xml.Xpp3Dom(
|
update(new XmlNodeImpl(dom.getName(), dom.getValue(), dom.getAttributes(), dom.getChildren(), inputLocation));
|
||||||
dom.getName(), dom.getValue(), dom.getAttributes(), dom.getChildren(), inputLocation));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------
|
// ----------------------------------------------------------------------
|
||||||
|
@ -405,7 +400,7 @@ public class Xpp3Dom implements Serializable {
|
||||||
return ((str == null) || (str.trim().length() == 0));
|
return ((str == null) || (str.trim().length() == 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void update(Dom dom) {
|
private void update(XmlNode dom) {
|
||||||
if (childrenTracking != null) {
|
if (childrenTracking != null) {
|
||||||
childrenTracking.replace(this.dom, dom);
|
childrenTracking.replace(this.dom, dom);
|
||||||
}
|
}
|
||||||
|
@ -413,10 +408,9 @@ public class Xpp3Dom implements Serializable {
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean replace(Object prevChild, Object newChild) {
|
private boolean replace(Object prevChild, Object newChild) {
|
||||||
List<Dom> children = new ArrayList<>(dom.getChildren());
|
List<XmlNode> children = new ArrayList<>(dom.getChildren());
|
||||||
children.replaceAll(d -> d == prevChild ? (Dom) newChild : d);
|
children.replaceAll(d -> d == prevChild ? (XmlNode) newChild : d);
|
||||||
update(new org.apache.maven.internal.xml.Xpp3Dom(
|
update(new XmlNodeImpl(dom.getName(), dom.getValue(), dom.getAttributes(), children, dom.getInputLocation()));
|
||||||
dom.getName(), dom.getValue(), dom.getAttributes(), children, dom.getInputLocation()));
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@ import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.io.Reader;
|
import java.io.Reader;
|
||||||
|
|
||||||
|
import org.apache.maven.internal.xml.XmlNodeBuilder;
|
||||||
import org.codehaus.plexus.util.xml.pull.XmlPullParser;
|
import org.codehaus.plexus.util.xml.pull.XmlPullParser;
|
||||||
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
|
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
|
||||||
|
|
||||||
|
@ -49,7 +50,7 @@ public class Xpp3DomBuilder {
|
||||||
|
|
||||||
public static Xpp3Dom build(InputStream is, String encoding, boolean trim)
|
public static Xpp3Dom build(InputStream is, String encoding, boolean trim)
|
||||||
throws XmlPullParserException, IOException {
|
throws XmlPullParserException, IOException {
|
||||||
return new Xpp3Dom(org.apache.maven.internal.xml.Xpp3DomBuilder.build(is, encoding, trim));
|
return new Xpp3Dom(XmlNodeBuilder.build(is, encoding, trim));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Xpp3Dom build(Reader reader, boolean trim) throws XmlPullParserException, IOException {
|
public static Xpp3Dom build(Reader reader, boolean trim) throws XmlPullParserException, IOException {
|
||||||
|
@ -61,8 +62,8 @@ public class Xpp3DomBuilder {
|
||||||
*/
|
*/
|
||||||
public static Xpp3Dom build(Reader reader, boolean trim, InputLocationBuilder locationBuilder)
|
public static Xpp3Dom build(Reader reader, boolean trim, InputLocationBuilder locationBuilder)
|
||||||
throws XmlPullParserException, IOException {
|
throws XmlPullParserException, IOException {
|
||||||
return new Xpp3Dom(org.apache.maven.internal.xml.Xpp3DomBuilder.build(
|
return new Xpp3Dom(
|
||||||
reader, trim, locationBuilder != null ? locationBuilder::toInputLocation : null));
|
XmlNodeBuilder.build(reader, trim, locationBuilder != null ? locationBuilder::toInputLocation : null));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Xpp3Dom build(XmlPullParser parser) throws XmlPullParserException, IOException {
|
public static Xpp3Dom build(XmlPullParser parser) throws XmlPullParserException, IOException {
|
||||||
|
@ -78,8 +79,8 @@ public class Xpp3DomBuilder {
|
||||||
*/
|
*/
|
||||||
public static Xpp3Dom build(XmlPullParser parser, boolean trim, InputLocationBuilder locationBuilder)
|
public static Xpp3Dom build(XmlPullParser parser, boolean trim, InputLocationBuilder locationBuilder)
|
||||||
throws XmlPullParserException, IOException {
|
throws XmlPullParserException, IOException {
|
||||||
return new Xpp3Dom(org.apache.maven.internal.xml.Xpp3DomBuilder.build(
|
return new Xpp3Dom(
|
||||||
parser, trim, locationBuilder != null ? locationBuilder::toInputLocation : null));
|
XmlNodeBuilder.build(parser, trim, locationBuilder != null ? locationBuilder::toInputLocation : null));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -5,6 +5,6 @@
|
||||||
* {@link org.codehaus.plexus.util.xml.Xpp3DomBuilder}
|
* {@link org.codehaus.plexus.util.xml.Xpp3DomBuilder}
|
||||||
* classes.
|
* classes.
|
||||||
* The modified {@link org.codehaus.plexus.util.xml.Xpp3Dom} wraps
|
* The modified {@link org.codehaus.plexus.util.xml.Xpp3Dom} wraps
|
||||||
* an immutable {@link org.apache.maven.api.xml.Dom} instance.
|
* an immutable {@link org.apache.maven.api.xml.XmlNode} instance.
|
||||||
*/
|
*/
|
||||||
package org.codehaus.plexus.util.xml;
|
package org.codehaus.plexus.util.xml;
|
||||||
|
|
|
@ -23,14 +23,14 @@ import java.io.StringReader;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import org.apache.maven.api.xml.Dom;
|
import org.apache.maven.api.xml.XmlNode;
|
||||||
import org.codehaus.plexus.util.xml.pull.XmlPullParser;
|
import org.codehaus.plexus.util.xml.pull.XmlPullParser;
|
||||||
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
|
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||||
|
|
||||||
public class Xpp3DomTest {
|
public class XmlNodeImplTest {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>testCombineId.</p>
|
* <p>testCombineId.</p>
|
||||||
|
@ -47,19 +47,19 @@ public class Xpp3DomTest {
|
||||||
+ "<property combine.id='TOOVERWRITE'><name>TOOVERWRITE</name><value>RHS</value></property>"
|
+ "<property combine.id='TOOVERWRITE'><name>TOOVERWRITE</name><value>RHS</value></property>"
|
||||||
+ "</props>";
|
+ "</props>";
|
||||||
|
|
||||||
Xpp3Dom leftDom = Xpp3DomBuilder.build(new StringReader(lhs), new FixedInputLocationBuilder("left"));
|
XmlNodeImpl leftDom = XmlNodeBuilder.build(new StringReader(lhs), new FixedInputLocationBuilder("left"));
|
||||||
Xpp3Dom rightDom = Xpp3DomBuilder.build(new StringReader(rhs), new FixedInputLocationBuilder("right"));
|
XmlNodeImpl rightDom = XmlNodeBuilder.build(new StringReader(rhs), new FixedInputLocationBuilder("right"));
|
||||||
|
|
||||||
Dom mergeResult = Xpp3Dom.merge(leftDom, rightDom, true);
|
XmlNode mergeResult = XmlNodeImpl.merge(leftDom, rightDom, true);
|
||||||
assertEquals(3, getChildren(mergeResult, "property").size());
|
assertEquals(3, getChildren(mergeResult, "property").size());
|
||||||
|
|
||||||
Dom p0 = getNthChild(mergeResult, "property", 0);
|
XmlNode p0 = getNthChild(mergeResult, "property", 0);
|
||||||
assertEquals("LHS-ONLY", p0.getChild("name").getValue());
|
assertEquals("LHS-ONLY", p0.getChild("name").getValue());
|
||||||
assertEquals("left", p0.getChild("name").getInputLocation());
|
assertEquals("left", p0.getChild("name").getInputLocation());
|
||||||
assertEquals("LHS", p0.getChild("value").getValue());
|
assertEquals("LHS", p0.getChild("value").getValue());
|
||||||
assertEquals("left", p0.getChild("value").getInputLocation());
|
assertEquals("left", p0.getChild("value").getInputLocation());
|
||||||
|
|
||||||
Dom p1 = getNthChild(mergeResult, "property", 1);
|
XmlNode p1 = getNthChild(mergeResult, "property", 1);
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"TOOVERWRITE",
|
"TOOVERWRITE",
|
||||||
getNthChild(mergeResult, "property", 1).getChild("name").getValue());
|
getNthChild(mergeResult, "property", 1).getChild("name").getValue());
|
||||||
|
@ -68,7 +68,7 @@ public class Xpp3DomTest {
|
||||||
"LHS", getNthChild(mergeResult, "property", 1).getChild("value").getValue());
|
"LHS", getNthChild(mergeResult, "property", 1).getChild("value").getValue());
|
||||||
assertEquals("left", p1.getChild("value").getInputLocation());
|
assertEquals("left", p1.getChild("value").getInputLocation());
|
||||||
|
|
||||||
Dom p2 = getNthChild(mergeResult, "property", 2);
|
XmlNode p2 = getNthChild(mergeResult, "property", 2);
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"RHS-ONLY",
|
"RHS-ONLY",
|
||||||
getNthChild(mergeResult, "property", 2).getChild("name").getValue());
|
getNthChild(mergeResult, "property", 2).getChild("name").getValue());
|
||||||
|
@ -93,19 +93,19 @@ public class Xpp3DomTest {
|
||||||
+ "<property key=\"RHS-ONLY\"><name>RHS-ONLY</name><value>RHS</value></property>"
|
+ "<property key=\"RHS-ONLY\"><name>RHS-ONLY</name><value>RHS</value></property>"
|
||||||
+ "<property combine.keys='name'><name>TOOVERWRITE</name><value>RHS</value></property>" + "</props>";
|
+ "<property combine.keys='name'><name>TOOVERWRITE</name><value>RHS</value></property>" + "</props>";
|
||||||
|
|
||||||
Xpp3Dom leftDom = Xpp3DomBuilder.build(new StringReader(lhs), new FixedInputLocationBuilder("left"));
|
XmlNodeImpl leftDom = XmlNodeBuilder.build(new StringReader(lhs), new FixedInputLocationBuilder("left"));
|
||||||
Xpp3Dom rightDom = Xpp3DomBuilder.build(new StringReader(rhs), new FixedInputLocationBuilder("right"));
|
XmlNodeImpl rightDom = XmlNodeBuilder.build(new StringReader(rhs), new FixedInputLocationBuilder("right"));
|
||||||
|
|
||||||
Dom mergeResult = Xpp3Dom.merge(leftDom, rightDom, true);
|
XmlNode mergeResult = XmlNodeImpl.merge(leftDom, rightDom, true);
|
||||||
assertEquals(3, getChildren(mergeResult, "property").size());
|
assertEquals(3, getChildren(mergeResult, "property").size());
|
||||||
|
|
||||||
Dom p0 = getNthChild(mergeResult, "property", 0);
|
XmlNode p0 = getNthChild(mergeResult, "property", 0);
|
||||||
assertEquals("LHS-ONLY", p0.getChild("name").getValue());
|
assertEquals("LHS-ONLY", p0.getChild("name").getValue());
|
||||||
assertEquals("left", p0.getChild("name").getInputLocation());
|
assertEquals("left", p0.getChild("name").getInputLocation());
|
||||||
assertEquals("LHS", p0.getChild("value").getValue());
|
assertEquals("LHS", p0.getChild("value").getValue());
|
||||||
assertEquals("left", p0.getChild("value").getInputLocation());
|
assertEquals("left", p0.getChild("value").getInputLocation());
|
||||||
|
|
||||||
Dom p1 = getNthChild(mergeResult, "property", 1);
|
XmlNode p1 = getNthChild(mergeResult, "property", 1);
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"TOOVERWRITE",
|
"TOOVERWRITE",
|
||||||
getNthChild(mergeResult, "property", 1).getChild("name").getValue());
|
getNthChild(mergeResult, "property", 1).getChild("name").getValue());
|
||||||
|
@ -114,7 +114,7 @@ public class Xpp3DomTest {
|
||||||
"LHS", getNthChild(mergeResult, "property", 1).getChild("value").getValue());
|
"LHS", getNthChild(mergeResult, "property", 1).getChild("value").getValue());
|
||||||
assertEquals("left", p1.getChild("value").getInputLocation());
|
assertEquals("left", p1.getChild("value").getInputLocation());
|
||||||
|
|
||||||
Dom p2 = getNthChild(mergeResult, "property", 2);
|
XmlNode p2 = getNthChild(mergeResult, "property", 2);
|
||||||
assertEquals(
|
assertEquals(
|
||||||
"RHS-ONLY",
|
"RHS-ONLY",
|
||||||
getNthChild(mergeResult, "property", 2).getChild("name").getValue());
|
getNthChild(mergeResult, "property", 2).getChild("name").getValue());
|
||||||
|
@ -130,10 +130,10 @@ public class Xpp3DomTest {
|
||||||
|
|
||||||
String rhs = "<parameter>recessive</parameter>";
|
String rhs = "<parameter>recessive</parameter>";
|
||||||
|
|
||||||
Xpp3Dom leftDom = Xpp3DomBuilder.build(new StringReader(lhs), new FixedInputLocationBuilder("left"));
|
XmlNodeImpl leftDom = XmlNodeBuilder.build(new StringReader(lhs), new FixedInputLocationBuilder("left"));
|
||||||
Xpp3Dom rightDom = Xpp3DomBuilder.build(new StringReader(rhs), new FixedInputLocationBuilder("right"));
|
XmlNodeImpl rightDom = XmlNodeBuilder.build(new StringReader(rhs), new FixedInputLocationBuilder("right"));
|
||||||
|
|
||||||
Dom mergeResult = Xpp3Dom.merge(leftDom, rightDom, true);
|
XmlNode mergeResult = XmlNodeImpl.merge(leftDom, rightDom, true);
|
||||||
assertEquals(" ", mergeResult.getValue());
|
assertEquals(" ", mergeResult.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -143,10 +143,10 @@ public class Xpp3DomTest {
|
||||||
|
|
||||||
String rhs = "<parameter>recessive</parameter>";
|
String rhs = "<parameter>recessive</parameter>";
|
||||||
|
|
||||||
Xpp3Dom leftDom = Xpp3DomBuilder.build(new StringReader(lhs), new FixedInputLocationBuilder("left"));
|
XmlNodeImpl leftDom = XmlNodeBuilder.build(new StringReader(lhs), new FixedInputLocationBuilder("left"));
|
||||||
Xpp3Dom rightDom = Xpp3DomBuilder.build(new StringReader(rhs), new FixedInputLocationBuilder("right"));
|
XmlNodeImpl rightDom = XmlNodeBuilder.build(new StringReader(rhs), new FixedInputLocationBuilder("right"));
|
||||||
|
|
||||||
Dom mergeResult = Xpp3Dom.merge(leftDom, rightDom, true);
|
XmlNode mergeResult = XmlNodeImpl.merge(leftDom, rightDom, true);
|
||||||
assertEquals("", mergeResult.getValue());
|
assertEquals("", mergeResult.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -156,18 +156,18 @@ public class Xpp3DomTest {
|
||||||
|
|
||||||
String rhs = "<parameter>recessive</parameter>";
|
String rhs = "<parameter>recessive</parameter>";
|
||||||
|
|
||||||
Xpp3Dom leftDom = Xpp3DomBuilder.build(new StringReader(lhs), new FixedInputLocationBuilder("left"));
|
XmlNodeImpl leftDom = XmlNodeBuilder.build(new StringReader(lhs), new FixedInputLocationBuilder("left"));
|
||||||
Xpp3Dom rightDom = Xpp3DomBuilder.build(new StringReader(rhs), new FixedInputLocationBuilder("right"));
|
XmlNodeImpl rightDom = XmlNodeBuilder.build(new StringReader(rhs), new FixedInputLocationBuilder("right"));
|
||||||
|
|
||||||
Dom mergeResult = Xpp3Dom.merge(leftDom, rightDom, true);
|
XmlNode mergeResult = XmlNodeImpl.merge(leftDom, rightDom, true);
|
||||||
assertEquals(null, mergeResult.getValue());
|
assertEquals(null, mergeResult.getValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<Dom> getChildren(Dom node, String name) {
|
private static List<XmlNode> getChildren(XmlNode node, String name) {
|
||||||
return node.getChildren().stream().filter(n -> n.getName().equals(name)).collect(Collectors.toList());
|
return node.getChildren().stream().filter(n -> n.getName().equals(name)).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Dom getNthChild(Dom node, String name, int nth) {
|
private static XmlNode getNthChild(XmlNode node, String name, int nth) {
|
||||||
return node.getChildren().stream()
|
return node.getChildren().stream()
|
||||||
.filter(n -> n.getName().equals(name))
|
.filter(n -> n.getName().equals(name))
|
||||||
.skip(nth)
|
.skip(nth)
|
||||||
|
@ -175,7 +175,7 @@ public class Xpp3DomTest {
|
||||||
.orElse(null);
|
.orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class FixedInputLocationBuilder implements Xpp3DomBuilder.InputLocationBuilder {
|
private static class FixedInputLocationBuilder implements XmlNodeBuilder.InputLocationBuilder {
|
||||||
private final Object location;
|
private final Object location;
|
||||||
|
|
||||||
public FixedInputLocationBuilder(Object location) {
|
public FixedInputLocationBuilder(Object location) {
|
Loading…
Reference in New Issue