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.Nonnull;
|
||||
import org.apache.maven.api.model.Plugin;
|
||||
import org.apache.maven.api.xml.Dom;
|
||||
import org.apache.maven.api.xml.XmlNode;
|
||||
|
||||
/**
|
||||
* A {@code MojoExecution}
|
||||
|
@ -40,5 +40,5 @@ public interface MojoExecution {
|
|||
String getGoal();
|
||||
|
||||
@Nonnull
|
||||
Optional<Dom> getConfiguration();
|
||||
Optional<XmlNode> getConfiguration();
|
||||
}
|
||||
|
|
|
@ -55,8 +55,8 @@
|
|||
#set ( $dummy = $imports.add( "java.util.Map" ) )
|
||||
#set ( $dummy = $types.put( $field, "Map<String, String>" ) )
|
||||
#elseif ( $field.type == "DOM" )
|
||||
#set ( $dummy = $imports.add( "org.apache.maven.api.xml.Dom" ) )
|
||||
#set ( $dummy = $types.put( $field, "Dom" ) )
|
||||
#set ( $dummy = $imports.add( "org.apache.maven.api.xml.XmlNode" ) )
|
||||
#set ( $dummy = $types.put( $field, "XmlNode" ) )
|
||||
#else
|
||||
#set ( $fieldType = ${types.getOrDefault($field.type,$field.type)} )
|
||||
#set ( $idx = $fieldType.lastIndexOf('.') )
|
||||
|
|
|
@ -55,8 +55,8 @@
|
|||
#set ( $dummy = $imports.add( "java.util.Map" ) )
|
||||
#set ( $dummy = $types.put( $field, "Map<String, String>" ) )
|
||||
#elseif ( $field.type == "DOM" )
|
||||
#set ( $dummy = $imports.add( "org.apache.maven.api.xml.Dom" ) )
|
||||
#set ( $dummy = $types.put( $field, "Dom" ) )
|
||||
#set ( $dummy = $imports.add( "org.apache.maven.api.xml.XmlNode" ) )
|
||||
#set ( $dummy = $types.put( $field, "XmlNode" ) )
|
||||
#else
|
||||
#set ( $fieldType = ${types.getOrDefault($field.type,$field.type)} )
|
||||
#set ( $idx = $fieldType.lastIndexOf('.') )
|
||||
|
|
|
@ -55,8 +55,8 @@
|
|||
#set ( $dummy = $imports.add( "java.util.Map" ) )
|
||||
#set ( $dummy = $types.put( $field, "Map<String, String>" ) )
|
||||
#elseif ( $field.type == "DOM" )
|
||||
#set ( $dummy = $imports.add( "org.apache.maven.api.xml.Dom" ) )
|
||||
#set ( $dummy = $types.put( $field, "Dom" ) )
|
||||
#set ( $dummy = $imports.add( "org.apache.maven.api.xml.XmlNode" ) )
|
||||
#set ( $dummy = $types.put( $field, "XmlNode" ) )
|
||||
#else
|
||||
#set ( $fieldType = ${types.getOrDefault($field.type,$field.type)} )
|
||||
#set ( $idx = $fieldType.lastIndexOf('.') )
|
||||
|
|
|
@ -35,7 +35,7 @@ import org.apache.maven.api.annotations.ThreadSafe;
|
|||
@Experimental
|
||||
@ThreadSafe
|
||||
@Immutable
|
||||
public interface Dom {
|
||||
public interface XmlNode {
|
||||
|
||||
String CHILDREN_COMBINATION_MODE_ATTRIBUTE = "combine.children";
|
||||
|
||||
|
@ -90,21 +90,21 @@ public interface Dom {
|
|||
String getAttribute(@Nonnull String name);
|
||||
|
||||
@Nonnull
|
||||
List<Dom> getChildren();
|
||||
List<XmlNode> getChildren();
|
||||
|
||||
@Nullable
|
||||
Dom getChild(String name);
|
||||
XmlNode getChild(String name);
|
||||
|
||||
@Nullable
|
||||
Object getInputLocation();
|
||||
|
||||
default Dom merge(@Nullable Dom source) {
|
||||
default XmlNode merge(@Nullable XmlNode source) {
|
||||
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}
|
||||
|
@ -116,12 +116,13 @@ public interface Dom {
|
|||
* @return the merged node
|
||||
*/
|
||||
@Nullable
|
||||
static Dom merge(@Nullable Dom dominant, @Nullable Dom recessive) {
|
||||
static XmlNode merge(@Nullable XmlNode dominant, @Nullable XmlNode recessive) {
|
||||
return merge(dominant, recessive, null);
|
||||
}
|
||||
|
||||
@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) {
|
||||
return dominant;
|
||||
}
|
|
@ -36,14 +36,14 @@ import java.util.Map;
|
|||
import java.util.stream.Collectors;
|
||||
|
||||
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.bridge.MavenRepositorySystem;
|
||||
import org.apache.maven.eventspy.internal.EventSpyDispatcher;
|
||||
import org.apache.maven.execution.MavenExecutionRequest;
|
||||
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.Xpp3Dom;
|
||||
import org.apache.maven.model.ModelBase;
|
||||
import org.apache.maven.model.building.TransformerContext;
|
||||
import org.apache.maven.repository.internal.MavenRepositorySystemUtils;
|
||||
|
@ -254,11 +254,11 @@ public class DefaultRepositorySystemSessionFactory {
|
|||
authSelector.add(server.getId(), authBuilder.build());
|
||||
|
||||
if (server.getConfiguration() != null) {
|
||||
Dom dom = ((org.codehaus.plexus.util.xml.Xpp3Dom) server.getConfiguration()).getDom();
|
||||
List<Dom> children = dom.getChildren().stream()
|
||||
XmlNode dom = ((org.codehaus.plexus.util.xml.Xpp3Dom) server.getConfiguration()).getDom();
|
||||
List<XmlNode> children = dom.getChildren().stream()
|
||||
.filter(c -> !"wagonProvider".equals(c.getName()))
|
||||
.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);
|
||||
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.model.Plugin;
|
||||
import org.apache.maven.api.xml.Dom;
|
||||
import org.apache.maven.api.xml.XmlNode;
|
||||
import org.codehaus.plexus.util.xml.Xpp3Dom;
|
||||
|
||||
public class DefaultMojoExecution implements MojoExecution {
|
||||
|
@ -52,7 +52,7 @@ public class DefaultMojoExecution implements MojoExecution {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Optional<Dom> getConfiguration() {
|
||||
public Optional<XmlNode> getConfiguration() {
|
||||
return Optional.of(delegate.getConfiguration()).map(Xpp3Dom::getDom);
|
||||
}
|
||||
|
||||
|
|
|
@ -33,9 +33,9 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
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.internal.xml.Xpp3Dom;
|
||||
import org.apache.maven.internal.xml.XmlNodeImpl;
|
||||
import org.apache.maven.lifecycle.DefaultLifecycles;
|
||||
import org.apache.maven.lifecycle.Lifecycle;
|
||||
import org.apache.maven.lifecycle.LifecycleMappingDelegate;
|
||||
|
@ -291,23 +291,23 @@ public class DefaultLifecycleExecutionPlanCalculator implements LifecycleExecuti
|
|||
MojoDescriptor mojoDescriptor = mojoExecution.getMojoDescriptor();
|
||||
|
||||
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) {
|
||||
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) {
|
||||
for (Parameter parameter : mojoDescriptor.getParameters()) {
|
||||
Dom parameterConfiguration = executionConfiguration.getChild(parameter.getName());
|
||||
XmlNode parameterConfiguration = executionConfiguration.getChild(parameter.getName());
|
||||
|
||||
if (parameterConfiguration == null) {
|
||||
parameterConfiguration = executionConfiguration.getChild(parameter.getAlias());
|
||||
}
|
||||
|
||||
Dom parameterDefaults = defaultConfiguration.getChild(parameter.getName());
|
||||
XmlNode parameterDefaults = defaultConfiguration.getChild(parameter.getName());
|
||||
|
||||
if (parameterConfiguration != null) {
|
||||
parameterConfiguration = parameterConfiguration.merge(parameterDefaults, Boolean.TRUE);
|
||||
|
@ -323,7 +323,7 @@ public class DefaultLifecycleExecutionPlanCalculator implements LifecycleExecuti
|
|||
attributes.put("implementation", parameter.getImplementation());
|
||||
}
|
||||
|
||||
parameterConfiguration = new Xpp3Dom(
|
||||
parameterConfiguration = new XmlNodeImpl(
|
||||
parameter.getName(),
|
||||
parameterConfiguration.getValue(),
|
||||
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);
|
||||
}
|
||||
|
||||
private Dom getMojoConfiguration(MojoDescriptor mojoDescriptor) {
|
||||
private XmlNode getMojoConfiguration(MojoDescriptor mojoDescriptor) {
|
||||
return MojoDescriptorCreator.convert(mojoDescriptor).getDom();
|
||||
}
|
||||
|
||||
|
@ -490,7 +490,7 @@ public class DefaultLifecycleExecutionPlanCalculator implements LifecycleExecuti
|
|||
MojoExecution forkedExecution =
|
||||
new MojoExecution(forkedMojoDescriptor, mojoExecution.getExecutionId());
|
||||
|
||||
Xpp3Dom forkedConfiguration = (Xpp3Dom) execution.getConfiguration();
|
||||
XmlNodeImpl forkedConfiguration = (XmlNodeImpl) execution.getConfiguration();
|
||||
|
||||
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) {
|
||||
for (MojoExecution forkedExecution : forkedExecutions) {
|
||||
org.codehaus.plexus.util.xml.Xpp3Dom config = forkedExecution.getConfiguration();
|
||||
|
||||
if (config != null) {
|
||||
Dom forkedConfiguration = config.getDom();
|
||||
XmlNode forkedConfiguration = config.getDom();
|
||||
|
||||
forkedConfiguration = phaseConfiguration.merge(forkedConfiguration);
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@ import java.util.Map;
|
|||
import java.util.NoSuchElementException;
|
||||
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.LifeCyclePluginAnalyzer;
|
||||
import org.apache.maven.lifecycle.Lifecycle;
|
||||
|
@ -196,7 +196,7 @@ public class DefaultLifecyclePluginAnalyzer implements LifeCyclePluginAnalyzer {
|
|||
execution.setLocation("phase", location);
|
||||
execution.setLocation("goals", location);
|
||||
|
||||
Dom lifecycleConfiguration = mojo.getConfiguration();
|
||||
XmlNode lifecycleConfiguration = mojo.getConfiguration();
|
||||
if (lifecycleConfiguration != null) {
|
||||
execution.setConfiguration(new Xpp3Dom(lifecycleConfiguration));
|
||||
}
|
||||
|
|
|
@ -26,8 +26,8 @@ import java.util.Set;
|
|||
import java.util.stream.Collectors;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import org.apache.maven.api.xml.Dom;
|
||||
import org.apache.maven.internal.xml.Xpp3Dom;
|
||||
import org.apache.maven.api.xml.XmlNode;
|
||||
import org.apache.maven.internal.xml.XmlNodeImpl;
|
||||
import org.apache.maven.lifecycle.MojoExecutionConfigurator;
|
||||
import org.apache.maven.model.Plugin;
|
||||
import org.apache.maven.model.PluginExecution;
|
||||
|
@ -67,7 +67,7 @@ public class DefaultMojoExecutionConfigurator implements MojoExecutionConfigurat
|
|||
PluginExecution pluginExecution =
|
||||
findPluginExecution(mojoExecution.getExecutionId(), plugin.getExecutions());
|
||||
|
||||
Dom pomConfiguration = null;
|
||||
XmlNode pomConfiguration = null;
|
||||
|
||||
if (pluginExecution != null) {
|
||||
pomConfiguration = pluginExecution.getDelegate().getConfiguration();
|
||||
|
@ -75,11 +75,11 @@ public class DefaultMojoExecutionConfigurator implements MojoExecutionConfigurat
|
|||
pomConfiguration = plugin.getDelegate().getConfiguration();
|
||||
}
|
||||
|
||||
Dom mojoConfiguration = mojoExecution.getConfiguration() != null
|
||||
XmlNode mojoConfiguration = mojoExecution.getConfiguration() != null
|
||||
? mojoExecution.getConfiguration().getDom()
|
||||
: null;
|
||||
|
||||
Dom mergedConfiguration = Xpp3Dom.merge(mojoConfiguration, pomConfiguration);
|
||||
XmlNode mergedConfiguration = XmlNodeImpl.merge(mojoConfiguration, pomConfiguration);
|
||||
|
||||
mojoExecution.setConfiguration(mergedConfiguration);
|
||||
|
||||
|
|
|
@ -28,9 +28,9 @@ import java.util.Collections;
|
|||
import java.util.List;
|
||||
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.internal.xml.Xpp3Dom;
|
||||
import org.apache.maven.internal.xml.XmlNodeImpl;
|
||||
import org.apache.maven.model.Plugin;
|
||||
import org.apache.maven.plugin.BuildPluginManager;
|
||||
import org.apache.maven.plugin.InvalidPluginDescriptorException;
|
||||
|
@ -99,14 +99,14 @@ public class MojoDescriptorCreator {
|
|||
public static org.codehaus.plexus.util.xml.Xpp3Dom convert(MojoDescriptor mojoDescriptor) {
|
||||
PlexusConfiguration c = mojoDescriptor.getMojoConfiguration();
|
||||
|
||||
List<Dom> children = new ArrayList<>();
|
||||
List<XmlNode> children = new ArrayList<>();
|
||||
PlexusConfiguration[] ces = c.getChildren();
|
||||
if (ces != null) {
|
||||
for (PlexusConfiguration ce : ces) {
|
||||
String value = ce.getValue(null);
|
||||
String defaultValue = ce.getAttribute("default-value", null);
|
||||
if (value != null || defaultValue != null) {
|
||||
Xpp3Dom e = new Xpp3Dom(
|
||||
XmlNodeImpl e = new XmlNodeImpl(
|
||||
ce.getName(),
|
||||
value,
|
||||
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);
|
||||
}
|
||||
|
||||
|
|
|
@ -20,7 +20,7 @@ package org.apache.maven.lifecycle.mapping;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.maven.api.xml.Dom;
|
||||
import org.apache.maven.api.xml.XmlNode;
|
||||
import org.apache.maven.model.Dependency;
|
||||
|
||||
/**
|
||||
|
@ -31,14 +31,14 @@ import org.apache.maven.model.Dependency;
|
|||
public class LifecycleMojo {
|
||||
|
||||
private String goal;
|
||||
private Dom configuration;
|
||||
private XmlNode configuration;
|
||||
private List<Dependency> dependencies;
|
||||
|
||||
public String getGoal() {
|
||||
return goal;
|
||||
}
|
||||
|
||||
public Dom getConfiguration() {
|
||||
public XmlNode getConfiguration() {
|
||||
return configuration;
|
||||
}
|
||||
|
||||
|
@ -50,7 +50,7 @@ public class LifecycleMojo {
|
|||
this.goal = goal;
|
||||
}
|
||||
|
||||
public void setConfiguration(Dom configuration) {
|
||||
public void setConfiguration(XmlNode configuration) {
|
||||
this.configuration = configuration;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,7 @@ import java.util.LinkedHashMap;
|
|||
import java.util.List;
|
||||
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.plugin.descriptor.MojoDescriptor;
|
||||
|
||||
|
@ -102,7 +102,7 @@ public class MojoExecution {
|
|||
this.executionId = null;
|
||||
}
|
||||
|
||||
public MojoExecution(MojoDescriptor mojoDescriptor, Dom configuration) {
|
||||
public MojoExecution(MojoDescriptor mojoDescriptor, XmlNode configuration) {
|
||||
this.mojoDescriptor = mojoDescriptor;
|
||||
this.configuration = new org.codehaus.plexus.util.xml.Xpp3Dom(configuration);
|
||||
this.executionId = null;
|
||||
|
@ -141,7 +141,7 @@ public class MojoExecution {
|
|||
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;
|
||||
}
|
||||
|
||||
|
|
|
@ -42,7 +42,7 @@ import java.util.stream.Collectors;
|
|||
import java.util.zip.ZipEntry;
|
||||
|
||||
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.classrealm.ClassRealmManager;
|
||||
import org.apache.maven.execution.MavenSession;
|
||||
|
@ -559,7 +559,7 @@ public class DefaultMavenPluginManager implements MavenPluginManager {
|
|||
((Mojo) mojo).setLog(new MojoLogWrapper(mojoLogger));
|
||||
}
|
||||
|
||||
Dom dom = mojoExecution.getConfiguration() != null
|
||||
XmlNode dom = mojoExecution.getConfiguration() != null
|
||||
? mojoExecution.getConfiguration().getDom()
|
||||
: null;
|
||||
|
||||
|
|
|
@ -28,8 +28,8 @@ import java.util.List;
|
|||
import java.util.jar.JarFile;
|
||||
import java.util.zip.ZipEntry;
|
||||
|
||||
import org.apache.maven.api.xml.Dom;
|
||||
import org.apache.maven.internal.xml.Xpp3DomBuilder;
|
||||
import org.apache.maven.api.xml.XmlNode;
|
||||
import org.apache.maven.internal.xml.XmlNodeBuilder;
|
||||
import org.codehaus.plexus.util.ReaderFactory;
|
||||
import org.codehaus.plexus.util.xml.pull.XmlPullParserException;
|
||||
|
||||
|
@ -86,9 +86,9 @@ public class ExtensionDescriptorBuilder {
|
|||
public ExtensionDescriptor build(InputStream is) throws IOException {
|
||||
ExtensionDescriptor extensionDescriptor = new ExtensionDescriptor();
|
||||
|
||||
Dom dom;
|
||||
XmlNode dom;
|
||||
try {
|
||||
dom = Xpp3DomBuilder.build(ReaderFactory.newXmlReader(is));
|
||||
dom = XmlNodeBuilder.build(ReaderFactory.newXmlReader(is));
|
||||
} catch (XmlPullParserException e) {
|
||||
throw new IOException(e.getMessage(), e);
|
||||
}
|
||||
|
@ -104,13 +104,13 @@ public class ExtensionDescriptorBuilder {
|
|||
return extensionDescriptor;
|
||||
}
|
||||
|
||||
private List<String> parseStrings(Dom dom) {
|
||||
private List<String> parseStrings(XmlNode dom) {
|
||||
List<String> strings = null;
|
||||
|
||||
if (dom != null) {
|
||||
strings = new ArrayList<>();
|
||||
|
||||
for (Dom child : dom.getChildren()) {
|
||||
for (XmlNode child : dom.getChildren()) {
|
||||
String string = child.getValue();
|
||||
if (string != null) {
|
||||
string = string.trim();
|
||||
|
|
|
@ -28,7 +28,7 @@ import java.util.HashSet;
|
|||
import java.util.List;
|
||||
|
||||
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.MojoExecutionEvent;
|
||||
import org.apache.maven.execution.MojoExecutionListener;
|
||||
|
@ -309,7 +309,7 @@ public class LifecycleExecutorTest extends AbstractCoreMavenComponentTestCase {
|
|||
MavenSession session = createMavenSession(pom);
|
||||
MojoDescriptor mojoDescriptor = mojoDescriptorCreator.getMojoDescriptor(
|
||||
"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);
|
||||
}
|
||||
|
||||
|
|
|
@ -25,7 +25,7 @@ import java.util.List;
|
|||
import java.util.Set;
|
||||
|
||||
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.LifecycleNotFoundException;
|
||||
import org.apache.maven.lifecycle.LifecyclePhaseNotFoundException;
|
||||
|
@ -219,7 +219,7 @@ public class LifecycleExecutionPlanCalculatorStub implements LifecycleExecutionP
|
|||
final Plugin plugin = mojoDescriptor.getPluginDescriptor().getPlugin();
|
||||
plugin.setLocation("version", new InputLocation(12, 34, defaultBindings));
|
||||
MojoExecution result = new MojoExecution(plugin, goal, executionId);
|
||||
result.setConfiguration(new Xpp3Dom(executionId + "-" + goal));
|
||||
result.setConfiguration(new XmlNodeImpl(executionId + "-" + goal));
|
||||
result.setMojoDescriptor(mojoDescriptor);
|
||||
result.setLifecyclePhase(mojoDescriptor.getPhase());
|
||||
|
||||
|
|
|
@ -21,7 +21,7 @@ package org.apache.maven.project.canonical;
|
|||
import java.io.File;
|
||||
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.PluginExecution;
|
||||
import org.apache.maven.project.AbstractMavenProjectTestCase;
|
||||
|
@ -69,7 +69,7 @@ public class CanonicalProjectBuilderTest extends AbstractMavenProjectTestCase {
|
|||
|
||||
assertEquals("1.0", plugin.getVersion());
|
||||
|
||||
Dom configuration = plugin.getDelegate().getConfiguration();
|
||||
XmlNode configuration = plugin.getDelegate().getConfiguration();
|
||||
|
||||
assertEquals(
|
||||
"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.model.NodeIterator;
|
||||
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>.
|
||||
|
@ -36,7 +36,7 @@ class Xpp3DomAttributeIterator implements NodeIterator {
|
|||
|
||||
private NodePointer parent;
|
||||
|
||||
private Xpp3Dom node;
|
||||
private XmlNodeImpl node;
|
||||
|
||||
private List<Map.Entry<String, String>> attributes;
|
||||
|
||||
|
@ -46,7 +46,7 @@ class Xpp3DomAttributeIterator implements NodeIterator {
|
|||
|
||||
public Xpp3DomAttributeIterator(NodePointer parent, QName qname) {
|
||||
this.parent = parent;
|
||||
this.node = (Xpp3Dom) parent.getNode();
|
||||
this.node = (XmlNodeImpl) parent.getNode();
|
||||
|
||||
this.attributes = this.node.getAttributes().entrySet().stream()
|
||||
.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.model.NodeIterator;
|
||||
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.xml.Xpp3Dom;
|
||||
|
||||
|
@ -42,21 +42,21 @@ class Xpp3DomNodeIterator implements NodeIterator {
|
|||
|
||||
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 Dom child;
|
||||
private XmlNode child;
|
||||
|
||||
private int position;
|
||||
|
||||
public Xpp3DomNodeIterator(NodePointer parent, NodeTest test, boolean reverse, NodePointer startWith) {
|
||||
this.parent = parent;
|
||||
this.node = (Dom) parent.getNode();
|
||||
this.node = (XmlNode) parent.getNode();
|
||||
this.children = this.node.getChildren();
|
||||
if (startWith != null) {
|
||||
Xpp3Dom startWithNode = (Xpp3Dom) startWith.getNode();
|
||||
|
@ -93,14 +93,14 @@ class Xpp3DomNodeIterator implements NodeIterator {
|
|||
|
||||
private void filterChildren(int position) {
|
||||
for (; position > filteredChildren.size() && filteredIndex < children.size(); filteredIndex++) {
|
||||
Dom child = children.get(filteredIndex);
|
||||
XmlNode child = children.get(filteredIndex);
|
||||
if (testNode(child)) {
|
||||
filteredChildren.add(child);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean testNode(Dom node) {
|
||||
private boolean testNode(XmlNode node) {
|
||||
if (test == null) {
|
||||
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.model.NodeIterator;
|
||||
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>.
|
||||
|
@ -34,26 +34,26 @@ import org.apache.maven.api.xml.Dom;
|
|||
*/
|
||||
class Xpp3DomNodePointer extends NodePointer {
|
||||
|
||||
private Dom node;
|
||||
private XmlNode node;
|
||||
|
||||
public Xpp3DomNodePointer(Dom node) {
|
||||
public Xpp3DomNodePointer(XmlNode node) {
|
||||
super(null);
|
||||
this.node = node;
|
||||
}
|
||||
|
||||
public Xpp3DomNodePointer(NodePointer parent, Dom node) {
|
||||
public Xpp3DomNodePointer(NodePointer parent, XmlNode node) {
|
||||
super(parent);
|
||||
this.node = node;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareChildNodePointers(NodePointer pointer1, NodePointer pointer2) {
|
||||
Dom node1 = (Dom) pointer1.getBaseValue();
|
||||
Dom node2 = (Dom) pointer2.getBaseValue();
|
||||
XmlNode node1 = (XmlNode) pointer1.getBaseValue();
|
||||
XmlNode node2 = (XmlNode) pointer2.getBaseValue();
|
||||
if (node1 == node2) {
|
||||
return 0;
|
||||
}
|
||||
for (Dom child : node.getChildren()) {
|
||||
for (XmlNode child : node.getChildren()) {
|
||||
if (child == node1) {
|
||||
return -1;
|
||||
}
|
||||
|
@ -69,12 +69,12 @@ class Xpp3DomNodePointer extends NodePointer {
|
|||
return getValue(node);
|
||||
}
|
||||
|
||||
private static Object getValue(Dom node) {
|
||||
private static Object getValue(XmlNode node) {
|
||||
if (node.getValue() != null) {
|
||||
return node.getValue();
|
||||
} else {
|
||||
List<Object> children = new ArrayList<>();
|
||||
for (Dom child : node.getChildren()) {
|
||||
for (XmlNode child : node.getChildren()) {
|
||||
children.add(getValue(child));
|
||||
}
|
||||
return children;
|
||||
|
|
|
@ -23,7 +23,7 @@ import java.util.Locale;
|
|||
import org.apache.commons.jxpath.ri.QName;
|
||||
import org.apache.commons.jxpath.ri.model.NodePointer;
|
||||
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>.
|
||||
|
@ -40,8 +40,8 @@ public class Xpp3DomPointerFactory implements NodePointerFactory {
|
|||
if (object instanceof org.codehaus.plexus.util.xml.Xpp3Dom) {
|
||||
object = ((org.codehaus.plexus.util.xml.Xpp3Dom) object).getDom();
|
||||
}
|
||||
if (object instanceof Dom) {
|
||||
return new Xpp3DomNodePointer((Dom) object);
|
||||
if (object instanceof XmlNode) {
|
||||
return new Xpp3DomNodePointer((XmlNode) object);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -50,8 +50,8 @@ public class Xpp3DomPointerFactory implements NodePointerFactory {
|
|||
if (object instanceof org.codehaus.plexus.util.xml.Xpp3Dom) {
|
||||
object = ((org.codehaus.plexus.util.xml.Xpp3Dom) object).getDom();
|
||||
}
|
||||
if (object instanceof Dom) {
|
||||
return new Xpp3DomNodePointer(parent, (Dom) object);
|
||||
if (object instanceof XmlNode) {
|
||||
return new Xpp3DomNodePointer(parent, (XmlNode) object);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
|
|
@ -37,7 +37,8 @@ import com.google.inject.Module;
|
|||
import com.google.inject.TypeLiteral;
|
||||
import com.google.inject.spi.TypeConverter;
|
||||
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.Xpp3DomBuilder;
|
||||
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);
|
||||
|
||||
final Class<?> rawType = toType.getRawType();
|
||||
if (Dom.class.isAssignableFrom(rawType)) {
|
||||
return org.apache.maven.internal.xml.Xpp3DomBuilder.build(parser);
|
||||
if (XmlNode.class.isAssignableFrom(rawType)) {
|
||||
return XmlNodeBuilder.build(parser);
|
||||
}
|
||||
if (Xpp3Dom.class.isAssignableFrom(rawType)) {
|
||||
return parseXpp3Dom(parser);
|
||||
|
|
|
@ -45,7 +45,7 @@ import java.util.function.Function;
|
|||
import java.util.stream.Collectors;
|
||||
|
||||
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 )
|
||||
import ${packageModelV4}.${class.Name};
|
||||
#end
|
||||
|
@ -172,10 +172,10 @@ public class ${className}
|
|||
#elseif ( $field.to && $field.multiplicity == "*" )
|
||||
builder.${field.name}( merge( target.get${capField}(), source.get${capField}(), sourceDominant, get${field.to}Key() ) );
|
||||
#elseif ( $field.type == "DOM" )
|
||||
Dom src = source.getConfiguration();
|
||||
XmlNode src = source.getConfiguration();
|
||||
if ( src != null )
|
||||
{
|
||||
Dom tgt = target.getConfiguration();
|
||||
XmlNode tgt = target.getConfiguration();
|
||||
if ( tgt == null )
|
||||
{
|
||||
builder.configuration( src );
|
||||
|
|
|
@ -294,7 +294,7 @@ public class ${class.name}
|
|||
#elseif ( $field.type == "DOM" )
|
||||
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
|
||||
|
|
|
@ -46,7 +46,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
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}.InputLocation;
|
||||
#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} ) );
|
||||
break;
|
||||
#elseif ( $field.type == "DOM" )
|
||||
${classLcapName}.${field.name}( DomBuilder.build( parser, true ) );
|
||||
${classLcapName}.${field.name}( XmlNodeBuilder.build( parser, true ) );
|
||||
break;
|
||||
#elseif ( $field.type == "java.util.List" && $field.to == "String" && $field.multiplicity == "*" )
|
||||
List<String> ${field.name} = new ArrayList<>();
|
||||
|
|
|
@ -46,7 +46,7 @@ import java.util.List;
|
|||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
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 )
|
||||
import ${packageModelV4}.${class.name};
|
||||
#end
|
||||
|
@ -277,7 +277,7 @@ public class ${className}
|
|||
${classLcapName}.${field.name}( getIntegerValue( interpolatedTrimmed( parser.nextText(), "${fieldTagName}" ), "${fieldTagName}", parser, strict, ${field.defaultValue} ) );
|
||||
break;
|
||||
#elseif ( $field.type == "DOM" )
|
||||
${classLcapName}.${field.name}( DomBuilder.build( parser, true ) );
|
||||
${classLcapName}.${field.name}( XmlNodeBuilder.build( parser, true ) );
|
||||
break;
|
||||
#elseif ( $field.type == "java.util.List" && $field.to == "String" && $field.multiplicity == "*" )
|
||||
List<String> ${field.name} = new ArrayList<>();
|
||||
|
|
|
@ -43,7 +43,7 @@ import java.util.function.Function;
|
|||
import java.util.stream.Collectors;
|
||||
|
||||
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 )
|
||||
import ${packageModelV4}.${class.name};
|
||||
#end
|
||||
|
@ -126,7 +126,7 @@ public class ${className}
|
|||
#elseif ( $field.to && $field.multiplicity == "*" )
|
||||
builder.${field.name}( transform( target.get${capField}(), this::transform${field.to} ) );
|
||||
#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 );
|
||||
#elseif ( $field.type == "boolean" || $field.type == "int" || $field.type == "java.nio.file.Path" )
|
||||
// nothing to do, the transformer only handles strings
|
||||
|
@ -156,7 +156,7 @@ public class ${className}
|
|||
return newList;
|
||||
}
|
||||
|
||||
protected Dom transform( Dom node )
|
||||
protected XmlNode transform( XmlNode node )
|
||||
{
|
||||
if ( node != null )
|
||||
{
|
||||
|
|
|
@ -50,8 +50,8 @@ import java.util.Set;
|
|||
import org.apache.maven.api.annotations.Generated;
|
||||
import ${packageModelV4}.InputLocation;
|
||||
import ${packageModelV4}.InputLocationTracker;
|
||||
import org.apache.maven.api.xml.Dom;
|
||||
import org.apache.maven.internal.xml.DomBuilder;
|
||||
import org.apache.maven.api.xml.XmlNode;
|
||||
import org.apache.maven.internal.xml.XmlNodeBuilder;
|
||||
#foreach ( $class in $model.allClasses )
|
||||
#if ( $class.name != "InputLocation" )
|
||||
import ${packageModelV4}.${class.name};
|
||||
|
@ -156,7 +156,7 @@ public class ${className}
|
|||
* @param serializer a serializer object.
|
||||
* @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
|
||||
{
|
||||
serializer.startTag( NAMESPACE, dom.getName() );
|
||||
|
@ -165,7 +165,7 @@ public class ${className}
|
|||
{
|
||||
serializer.attribute( NAMESPACE, attribute.getKey(), attribute.getValue() );
|
||||
}
|
||||
for ( Dom aChild : dom.getChildren() )
|
||||
for ( XmlNode aChild : dom.getChildren() )
|
||||
{
|
||||
writeDomToSerializer( aChild, serializer );
|
||||
}
|
||||
|
@ -178,7 +178,7 @@ public class ${className}
|
|||
|
||||
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 )
|
||||
|
@ -316,7 +316,7 @@ public class ${className}
|
|||
}
|
||||
}
|
||||
|
||||
private void writeDom( Dom dom, XmlSerializer serializer )
|
||||
private void writeDom( XmlNode dom, XmlSerializer serializer )
|
||||
throws IOException
|
||||
{
|
||||
if ( dom != null )
|
||||
|
@ -326,7 +326,7 @@ public class ${className}
|
|||
{
|
||||
serializer.attribute( NAMESPACE, attr.getKey(), attr.getValue() );
|
||||
}
|
||||
for ( Dom child : dom.getChildren() )
|
||||
for ( XmlNode child : dom.getChildren() )
|
||||
{
|
||||
writeDom( child, serializer );
|
||||
}
|
||||
|
|
|
@ -48,8 +48,8 @@ import java.util.Objects;
|
|||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
import org.apache.maven.api.annotations.Generated;
|
||||
import org.apache.maven.api.xml.Dom;
|
||||
import org.apache.maven.internal.xml.DomBuilder;
|
||||
import org.apache.maven.api.xml.XmlNode;
|
||||
import org.apache.maven.internal.xml.XmlNodeBuilder;
|
||||
#foreach ( $class in $model.allClasses )
|
||||
import ${packageModelV4}.${class.name};
|
||||
#end
|
||||
|
@ -138,7 +138,7 @@ public class ${className}
|
|||
* @param serializer a serializer object.
|
||||
* @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
|
||||
{
|
||||
serializer.startTag( NAMESPACE, dom.getName() );
|
||||
|
@ -147,7 +147,7 @@ public class ${className}
|
|||
{
|
||||
serializer.attribute( NAMESPACE, attribute.getKey(), attribute.getValue() );
|
||||
}
|
||||
for ( Dom aChild : dom.getChildren() )
|
||||
for ( XmlNode aChild : dom.getChildren() )
|
||||
{
|
||||
writeDomToSerializer( aChild, serializer );
|
||||
}
|
||||
|
@ -160,7 +160,7 @@ public class ${className}
|
|||
|
||||
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 )
|
||||
|
@ -287,7 +287,7 @@ public class ${className}
|
|||
}
|
||||
}
|
||||
|
||||
private void writeDom( Dom dom, XmlSerializer serializer )
|
||||
private void writeDom( XmlNode dom, XmlSerializer serializer )
|
||||
throws IOException
|
||||
{
|
||||
if ( dom != null )
|
||||
|
@ -297,7 +297,7 @@ public class ${className}
|
|||
{
|
||||
serializer.attribute( NAMESPACE, attr.getKey(), attr.getValue() );
|
||||
}
|
||||
for ( Dom child : dom.getChildren() )
|
||||
for ( XmlNode child : dom.getChildren() )
|
||||
{
|
||||
writeDom( child, serializer );
|
||||
}
|
||||
|
|
|
@ -24,8 +24,8 @@ import java.util.ArrayList;
|
|||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import org.apache.maven.internal.xml.XmlNodeBuilder;
|
||||
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.ComponentRequirement;
|
||||
import org.codehaus.plexus.configuration.PlexusConfiguration;
|
||||
|
@ -369,7 +369,7 @@ public class PluginDescriptorBuilder {
|
|||
|
||||
public PlexusConfiguration buildConfiguration(Reader configuration) throws PlexusConfigurationException {
|
||||
try {
|
||||
return XmlPlexusConfiguration.toPlexusConfiguration(Xpp3DomBuilder.build(configuration));
|
||||
return XmlPlexusConfiguration.toPlexusConfiguration(XmlNodeBuilder.build(configuration));
|
||||
} catch (IOException | XmlPullParserException e) {
|
||||
throw new PlexusConfigurationException(e.getMessage(), e);
|
||||
}
|
||||
|
|
|
@ -45,7 +45,7 @@ import java.util.function.Function;
|
|||
import java.util.stream.Collectors;
|
||||
|
||||
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 )
|
||||
import ${packageModelV4}.${class.Name};
|
||||
#end
|
||||
|
@ -172,10 +172,10 @@ public class ${className}
|
|||
#elseif ( $field.to && $field.multiplicity == "*" )
|
||||
builder.${field.name}( merge( target.get${capField}(), source.get${capField}(), sourceDominant, get${field.to}Key() ) );
|
||||
#elseif ( $field.type == "DOM" )
|
||||
Dom src = source.getConfiguration();
|
||||
XmlNode src = source.getConfiguration();
|
||||
if ( src != null )
|
||||
{
|
||||
Dom tgt = target.getConfiguration();
|
||||
XmlNode tgt = target.getConfiguration();
|
||||
if ( tgt == null )
|
||||
{
|
||||
builder.configuration( src );
|
||||
|
|
|
@ -51,8 +51,8 @@
|
|||
#set ( $dummy = $imports.add( "java.util.List" ) )
|
||||
#set ( $dummy = $types.put( $field, "List<" + $field.to + ">" ) )
|
||||
#elseif ( $field.type == "DOM" )
|
||||
#set ( $dummy = $imports.add( "org.apache.maven.api.xml.Dom" ) )
|
||||
#set ( $dummy = $types.put( $field, "Dom" ) )
|
||||
#set ( $dummy = $imports.add( "org.apache.maven.api.xml.XmlNode" ) )
|
||||
#set ( $dummy = $types.put( $field, "XmlNode" ) )
|
||||
#else
|
||||
#set ( $fieldType = ${types.getOrDefault($field.type,$field.type)} )
|
||||
#set ( $idx = $fieldType.lastIndexOf('.') )
|
||||
|
|
|
@ -44,7 +44,7 @@ import java.util.List;
|
|||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
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 )
|
||||
import ${packageModelV4}.${class.name};
|
||||
#end
|
||||
|
@ -751,7 +751,7 @@ public class ${className}
|
|||
${classLcapName}.${field.name}( getIntegerValue( interpolatedTrimmed( parser.nextText(), "${fieldTagName}" ), "${fieldTagName}", parser, strict, ${field.defaultValue} ) );
|
||||
break;
|
||||
#elseif ( $field.type == "DOM" )
|
||||
${classLcapName}.${field.name}( DomBuilder.build( parser, true ) );
|
||||
${classLcapName}.${field.name}( XmlNodeBuilder.build( parser, true ) );
|
||||
break;
|
||||
#elseif ( $field.type == "java.util.List" && $field.to == "String" && $field.multiplicity == "*" )
|
||||
List<String> ${field.name} = new ArrayList<>();
|
||||
|
|
|
@ -48,8 +48,8 @@ import java.util.Objects;
|
|||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
import org.apache.maven.api.annotations.Generated;
|
||||
import org.apache.maven.api.xml.Dom;
|
||||
import org.apache.maven.internal.xml.DomBuilder;
|
||||
import org.apache.maven.api.xml.XmlNode;
|
||||
import org.apache.maven.internal.xml.XmlNodeBuilder;
|
||||
#foreach ( $class in $model.allClasses )
|
||||
import ${packageModelV4}.${class.name};
|
||||
#end
|
||||
|
@ -138,7 +138,7 @@ public class ${className}
|
|||
* @param serializer a serializer object.
|
||||
* @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
|
||||
{
|
||||
serializer.startTag( NAMESPACE, dom.getName() );
|
||||
|
@ -147,7 +147,7 @@ public class ${className}
|
|||
{
|
||||
serializer.attribute( NAMESPACE, attribute.getKey(), attribute.getValue() );
|
||||
}
|
||||
for ( Dom aChild : dom.getChildren() )
|
||||
for ( XmlNode aChild : dom.getChildren() )
|
||||
{
|
||||
writeDomToSerializer( aChild, serializer );
|
||||
}
|
||||
|
@ -160,7 +160,7 @@ public class ${className}
|
|||
|
||||
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 )
|
||||
|
@ -287,7 +287,7 @@ public class ${className}
|
|||
}
|
||||
}
|
||||
|
||||
private void writeDom( Dom dom, XmlSerializer serializer )
|
||||
private void writeDom( XmlNode dom, XmlSerializer serializer )
|
||||
throws IOException
|
||||
{
|
||||
if ( dom != null )
|
||||
|
@ -297,7 +297,7 @@ public class ${className}
|
|||
{
|
||||
serializer.attribute( NAMESPACE, attr.getKey(), attr.getValue() );
|
||||
}
|
||||
for ( Dom child : dom.getChildren() )
|
||||
for ( XmlNode child : dom.getChildren() )
|
||||
{
|
||||
writeDom( child, serializer );
|
||||
}
|
||||
|
|
|
@ -44,7 +44,7 @@ import java.util.function.Function;
|
|||
import java.util.stream.Collectors;
|
||||
|
||||
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 )
|
||||
import ${packageModelV4}.${class.Name};
|
||||
#end
|
||||
|
@ -171,10 +171,10 @@ public class ${className}
|
|||
#elseif ( $field.to && $field.multiplicity == "*" )
|
||||
builder.${field.name}( merge( target.get${capField}(), source.get${capField}(), sourceDominant, get${field.to}Key() ) );
|
||||
#elseif ( $field.type == "DOM" )
|
||||
Dom src = source.getConfiguration();
|
||||
XmlNode src = source.getConfiguration();
|
||||
if ( src != null )
|
||||
{
|
||||
Dom tgt = target.getConfiguration();
|
||||
XmlNode tgt = target.getConfiguration();
|
||||
if ( tgt == null )
|
||||
{
|
||||
builder.configuration( src );
|
||||
|
|
|
@ -47,7 +47,7 @@ import java.util.Map;
|
|||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
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 )
|
||||
import ${packageModelV4}.${class.name};
|
||||
#end
|
||||
|
@ -754,7 +754,7 @@ public class ${className}
|
|||
${classLcapName}.${field.name}( getIntegerValue( interpolatedTrimmed( parser.nextText(), "${fieldTagName}" ), "${fieldTagName}", parser, strict, ${field.defaultValue} ) );
|
||||
break;
|
||||
#elseif ( $field.type == "DOM" )
|
||||
${classLcapName}.${field.name}( DomBuilder.build( parser, true ) );
|
||||
${classLcapName}.${field.name}( XmlNodeBuilder.build( parser, true ) );
|
||||
break;
|
||||
#elseif ( $field.type == "java.util.List" && $field.to == "String" && $field.multiplicity == "*" )
|
||||
List<String> ${field.name} = new ArrayList<>();
|
||||
|
|
|
@ -48,8 +48,8 @@ import java.util.Objects;
|
|||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
import org.apache.maven.api.annotations.Generated;
|
||||
import org.apache.maven.api.xml.Dom;
|
||||
import org.apache.maven.internal.xml.DomBuilder;
|
||||
import org.apache.maven.api.xml.XmlNode;
|
||||
import org.apache.maven.internal.xml.XmlNodeBuilder;
|
||||
#foreach ( $class in $model.allClasses )
|
||||
import ${packageModelV4}.${class.name};
|
||||
#end
|
||||
|
@ -138,7 +138,7 @@ public class ${className}
|
|||
* @param serializer a serializer object.
|
||||
* @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
|
||||
{
|
||||
serializer.startTag( NAMESPACE, dom.getName() );
|
||||
|
@ -147,7 +147,7 @@ public class ${className}
|
|||
{
|
||||
serializer.attribute( NAMESPACE, attribute.getKey(), attribute.getValue() );
|
||||
}
|
||||
for ( Dom aChild : dom.getChildren() )
|
||||
for ( XmlNode aChild : dom.getChildren() )
|
||||
{
|
||||
writeDomToSerializer( aChild, serializer );
|
||||
}
|
||||
|
@ -160,7 +160,7 @@ public class ${className}
|
|||
|
||||
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 )
|
||||
|
@ -287,7 +287,7 @@ public class ${className}
|
|||
}
|
||||
}
|
||||
|
||||
private void writeDom( Dom dom, XmlSerializer serializer )
|
||||
private void writeDom( XmlNode dom, XmlSerializer serializer )
|
||||
throws IOException
|
||||
{
|
||||
if ( dom != null )
|
||||
|
@ -297,7 +297,7 @@ public class ${className}
|
|||
{
|
||||
serializer.attribute( NAMESPACE, attr.getKey(), attr.getValue() );
|
||||
}
|
||||
for ( Dom child : dom.getChildren() )
|
||||
for ( XmlNode child : dom.getChildren() )
|
||||
{
|
||||
writeDom( child, serializer );
|
||||
}
|
||||
|
|
|
@ -25,7 +25,7 @@ import java.util.Map;
|
|||
|
||||
import org.apache.maven.api.toolchain.PersistedToolchains;
|
||||
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) {
|
||||
Dom src = source.getConfiguration();
|
||||
Dom tgt = target.getConfiguration();
|
||||
Dom merged = Dom.merge(tgt, src);
|
||||
XmlNode src = source.getConfiguration();
|
||||
XmlNode tgt = target.getConfiguration();
|
||||
XmlNode merged = XmlNode.merge(tgt, src);
|
||||
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.ToolchainModel;
|
||||
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.DefaultToolchainsWriter;
|
||||
import org.apache.maven.toolchain.io.ToolchainsParseException;
|
||||
|
@ -236,9 +236,9 @@ public class DefaultToolchainsBuilderTest {
|
|||
|
||||
Map<String, String> props = new HashMap<>();
|
||||
props.put("key", "${env.testKey}");
|
||||
Xpp3Dom configurationChild = new Xpp3Dom("jdkHome", "${env.testKey}", null, null, null);
|
||||
Xpp3Dom configuration =
|
||||
new Xpp3Dom("configuration", null, null, Collections.singletonList(configurationChild), null);
|
||||
XmlNodeImpl configurationChild = new XmlNodeImpl("jdkHome", "${env.testKey}", null, null, null);
|
||||
XmlNodeImpl configuration =
|
||||
new XmlNodeImpl("configuration", null, null, Collections.singletonList(configurationChild), null);
|
||||
ToolchainModel toolchain = ToolchainModel.newBuilder()
|
||||
.type("TYPE")
|
||||
.provides(props)
|
||||
|
|
|
@ -22,7 +22,7 @@ import java.io.InputStream;
|
|||
|
||||
import org.apache.maven.api.toolchain.PersistedToolchains;
|
||||
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.junit.jupiter.api.Test;
|
||||
|
||||
|
@ -94,10 +94,10 @@ public class MavenToolchainMergerTest {
|
|||
|
||||
PersistedToolchains merged = merger.merge(jdks, jdksExtend, TrackableBase.USER_LEVEL);
|
||||
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(2, config0.getChildren().size());
|
||||
Dom config1 = merged.getToolchains().get(1).getConfiguration();
|
||||
XmlNode config1 = merged.getToolchains().get(1).getConfiguration();
|
||||
assertEquals(2, config1.getChildren().size());
|
||||
assertEquals("lib/classes.jar", config1.getChild("toolsJar").getValue());
|
||||
assertEquals(2, jdks.getToolchains().size());
|
||||
|
@ -112,10 +112,10 @@ public class MavenToolchainMergerTest {
|
|||
// switch dominant with recessive
|
||||
PersistedToolchains merged = merger.merge(jdksExtend, jdks, TrackableBase.USER_LEVEL);
|
||||
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(2, config0.getChildren().size());
|
||||
Dom config1 = merged.getToolchains().get(1).getConfiguration();
|
||||
XmlNode config1 = merged.getToolchains().get(1).getConfiguration();
|
||||
assertEquals(2, config1.getChildren().size());
|
||||
assertEquals("lib/classes.jar", config1.getChild("toolsJar").getValue());
|
||||
assertEquals(2, jdks.getToolchains().size());
|
||||
|
|
|
@ -44,7 +44,7 @@ import java.util.function.Function;
|
|||
import java.util.stream.Collectors;
|
||||
|
||||
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 )
|
||||
import ${packageModelV4}.${class.Name};
|
||||
#end
|
||||
|
@ -171,10 +171,10 @@ public class ${className}
|
|||
#elseif ( $field.to && $field.multiplicity == "*" )
|
||||
builder.${field.name}( merge( target.get${capField}(), source.get${capField}(), sourceDominant, get${field.to}Key() ) );
|
||||
#elseif ( $field.type == "DOM" )
|
||||
Dom src = source.getConfiguration();
|
||||
XmlNode src = source.getConfiguration();
|
||||
if ( src != null )
|
||||
{
|
||||
Dom tgt = target.getConfiguration();
|
||||
XmlNode tgt = target.getConfiguration();
|
||||
if ( tgt == null )
|
||||
{
|
||||
builder.configuration( src );
|
||||
|
|
|
@ -47,7 +47,7 @@ import java.util.Map;
|
|||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
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 )
|
||||
import ${packageModelV4}.${class.name};
|
||||
#end
|
||||
|
@ -754,7 +754,7 @@ public class ${className}
|
|||
${classLcapName}.${field.name}( getIntegerValue( interpolatedTrimmed( parser.nextText(), "${fieldTagName}" ), "${fieldTagName}", parser, strict, ${field.defaultValue} ) );
|
||||
break;
|
||||
#elseif ( $field.type == "DOM" )
|
||||
${classLcapName}.${field.name}( DomBuilder.build( parser, true ) );
|
||||
${classLcapName}.${field.name}( XmlNodeBuilder.build( parser, true ) );
|
||||
break;
|
||||
#elseif ( $field.type == "java.util.List" && $field.to == "String" && $field.multiplicity == "*" )
|
||||
List<String> ${field.name} = new ArrayList<>();
|
||||
|
|
|
@ -48,8 +48,8 @@ import java.util.Objects;
|
|||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
import org.apache.maven.api.annotations.Generated;
|
||||
import org.apache.maven.api.xml.Dom;
|
||||
import org.apache.maven.internal.xml.DomBuilder;
|
||||
import org.apache.maven.api.xml.XmlNode;
|
||||
import org.apache.maven.internal.xml.XmlNodeBuilder;
|
||||
#foreach ( $class in $model.allClasses )
|
||||
import ${packageModelV4}.${class.name};
|
||||
#end
|
||||
|
@ -138,7 +138,7 @@ public class ${className}
|
|||
* @param serializer a serializer object.
|
||||
* @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
|
||||
{
|
||||
serializer.startTag( NAMESPACE, dom.getName() );
|
||||
|
@ -147,7 +147,7 @@ public class ${className}
|
|||
{
|
||||
serializer.attribute( NAMESPACE, attribute.getKey(), attribute.getValue() );
|
||||
}
|
||||
for ( Dom aChild : dom.getChildren() )
|
||||
for ( XmlNode aChild : dom.getChildren() )
|
||||
{
|
||||
writeDomToSerializer( aChild, serializer );
|
||||
}
|
||||
|
@ -160,7 +160,7 @@ public class ${className}
|
|||
|
||||
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 )
|
||||
|
@ -287,7 +287,7 @@ public class ${className}
|
|||
}
|
||||
}
|
||||
|
||||
private void writeDom( Dom dom, XmlSerializer serializer )
|
||||
private void writeDom( XmlNode dom, XmlSerializer serializer )
|
||||
throws IOException
|
||||
{
|
||||
if ( dom != null )
|
||||
|
@ -297,7 +297,7 @@ public class ${className}
|
|||
{
|
||||
serializer.attribute( NAMESPACE, attr.getKey(), attr.getValue() );
|
||||
}
|
||||
for ( Dom child : dom.getChildren() )
|
||||
for ( XmlNode child : dom.getChildren() )
|
||||
{
|
||||
writeDom( child, serializer );
|
||||
}
|
||||
|
|
|
@ -17,6 +17,6 @@
|
|||
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.
|
||||
|
|
|
@ -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.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.xml.pull.MXParser;
|
||||
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;
|
||||
|
||||
public static Xpp3Dom build(Reader reader) throws XmlPullParserException, IOException {
|
||||
public static XmlNodeImpl build(Reader reader) throws XmlPullParserException, IOException {
|
||||
return build(reader, null);
|
||||
}
|
||||
|
||||
|
@ -50,32 +50,32 @@ public class Xpp3DomBuilder {
|
|||
* @throws XmlPullParserException xml exception
|
||||
* @throws IOException io
|
||||
*/
|
||||
public static Xpp3Dom build(Reader reader, InputLocationBuilder locationBuilder)
|
||||
public static XmlNodeImpl build(Reader reader, InputLocationBuilder locationBuilder)
|
||||
throws XmlPullParserException, IOException {
|
||||
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);
|
||||
}
|
||||
|
||||
public static Xpp3Dom build(InputStream is, String encoding, boolean trim)
|
||||
public static XmlNodeImpl build(InputStream is, String encoding, boolean trim)
|
||||
throws XmlPullParserException, IOException {
|
||||
try {
|
||||
final XmlPullParser parser = new MXParser();
|
||||
parser.setInput(is, encoding);
|
||||
|
||||
final Xpp3Dom xpp3Dom = build(parser, trim);
|
||||
final XmlNodeImpl node = build(parser, trim);
|
||||
is.close();
|
||||
is = null;
|
||||
|
||||
return xpp3Dom;
|
||||
return node;
|
||||
} finally {
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -88,27 +88,27 @@ public class Xpp3DomBuilder {
|
|||
* @throws XmlPullParserException xml exception
|
||||
* @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 {
|
||||
try {
|
||||
final XmlPullParser parser = new MXParser();
|
||||
parser.setInput(reader);
|
||||
|
||||
final Xpp3Dom xpp3Dom = build(parser, trim, locationBuilder);
|
||||
final XmlNodeImpl node = build(parser, trim, locationBuilder);
|
||||
reader.close();
|
||||
reader = null;
|
||||
|
||||
return xpp3Dom;
|
||||
return node;
|
||||
} finally {
|
||||
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);
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
|
@ -121,14 +121,14 @@ public class Xpp3DomBuilder {
|
|||
* @throws XmlPullParserException xml exception
|
||||
* @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 {
|
||||
boolean spacePreserve = false;
|
||||
String name = null;
|
||||
String value = null;
|
||||
Object location = null;
|
||||
Map<String, String> attrs = null;
|
||||
List<Dom> children = null;
|
||||
List<XmlNode> children = null;
|
||||
int eventType = parser.getEventType();
|
||||
boolean emptyTag = false;
|
||||
while (eventType != XmlPullParser.END_DOCUMENT) {
|
||||
|
@ -151,7 +151,7 @@ public class Xpp3DomBuilder {
|
|||
if (children == null) {
|
||||
children = new ArrayList<>();
|
||||
}
|
||||
Dom child = build(parser, trim, locationBuilder);
|
||||
XmlNode child = build(parser, trim, locationBuilder);
|
||||
children.add(child);
|
||||
}
|
||||
} else if (eventType == XmlPullParser.TEXT) {
|
||||
|
@ -161,7 +161,7 @@ public class Xpp3DomBuilder {
|
|||
}
|
||||
value = value != null ? value + text : text;
|
||||
} else if (eventType == XmlPullParser.END_TAG) {
|
||||
return new Xpp3Dom(
|
||||
return new XmlNodeImpl(
|
||||
name,
|
||||
children == null ? (value != null ? value : emptyTag ? null : "") : null,
|
||||
attrs,
|
|
@ -34,7 +34,7 @@ import java.util.Set;
|
|||
import java.util.stream.Collectors;
|
||||
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.SerializerXMLWriter;
|
||||
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.
|
||||
*/
|
||||
public class Xpp3Dom implements Serializable, Dom {
|
||||
public class XmlNodeImpl implements Serializable, XmlNode {
|
||||
private static final long serialVersionUID = 2567894443061173996L;
|
||||
|
||||
protected final String name;
|
||||
|
@ -52,23 +52,24 @@ public class Xpp3Dom implements Serializable, Dom {
|
|||
|
||||
protected final Map<String, String> attributes;
|
||||
|
||||
protected final List<Dom> children;
|
||||
protected final List<XmlNode> children;
|
||||
|
||||
protected final Object location;
|
||||
|
||||
public Xpp3Dom(String name) {
|
||||
public XmlNodeImpl(String name) {
|
||||
this(name, null, null, null, null);
|
||||
}
|
||||
|
||||
public Xpp3Dom(String name, String value) {
|
||||
public XmlNodeImpl(String name, String value) {
|
||||
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());
|
||||
}
|
||||
|
||||
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.value = value;
|
||||
this.attributes =
|
||||
|
@ -79,11 +80,11 @@ public class Xpp3Dom implements Serializable, Dom {
|
|||
}
|
||||
|
||||
@Override
|
||||
public Dom merge(Dom source, Boolean childMergeOverride) {
|
||||
public XmlNode merge(XmlNode source, Boolean childMergeOverride) {
|
||||
return merge(this, source, childMergeOverride);
|
||||
}
|
||||
|
||||
public Dom clone() {
|
||||
public XmlNode clone() {
|
||||
return this;
|
||||
}
|
||||
|
||||
|
@ -120,11 +121,11 @@ public class Xpp3Dom implements Serializable, Dom {
|
|||
// Child handling
|
||||
// ----------------------------------------------------------------------
|
||||
|
||||
public Dom getChild(String name) {
|
||||
public XmlNode getChild(String name) {
|
||||
if (name != null) {
|
||||
ListIterator<Dom> it = children.listIterator(children.size());
|
||||
ListIterator<XmlNode> it = children.listIterator(children.size());
|
||||
while (it.hasPrevious()) {
|
||||
Dom child = it.previous();
|
||||
XmlNode child = it.previous();
|
||||
if (name.equals(child.getName())) {
|
||||
return child;
|
||||
}
|
||||
|
@ -133,7 +134,7 @@ public class Xpp3Dom implements Serializable, Dom {
|
|||
return null;
|
||||
}
|
||||
|
||||
public List<Dom> getChildren() {
|
||||
public List<XmlNode> getChildren() {
|
||||
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
|
||||
// document - not the desired behaviour!
|
||||
SerializerXMLWriter xmlWriter = new SerializerXMLWriter(namespace, serializer);
|
||||
Xpp3DomWriter.write(xmlWriter, this);
|
||||
XmlNodeWriter.write(xmlWriter, this);
|
||||
if (xmlWriter.getExceptions().size() > 0) {
|
||||
throw (IOException) xmlWriter.getExceptions().get(0);
|
||||
}
|
||||
|
@ -203,7 +204,7 @@ public class Xpp3Dom implements Serializable, Dom {
|
|||
* </ol>
|
||||
*/
|
||||
@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?
|
||||
if (recessive == null) {
|
||||
return dominant;
|
||||
|
@ -225,7 +226,7 @@ public class Xpp3Dom implements Serializable, Dom {
|
|||
String value = dominant.getValue();
|
||||
Object location = dominant.getInputLocation();
|
||||
Map<String, String> attrs = null;
|
||||
List<Dom> children = null;
|
||||
List<XmlNode> children = null;
|
||||
|
||||
for (Map.Entry<String, String> attr : recessive.getAttributes().entrySet()) {
|
||||
String key = attr.getKey();
|
||||
|
@ -250,12 +251,12 @@ public class Xpp3Dom implements Serializable, Dom {
|
|||
|
||||
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);
|
||||
|
||||
Dom childDom = null;
|
||||
XmlNode childDom = null;
|
||||
if (isNotEmpty(idValue)) {
|
||||
for (Dom dominantChild : dominant.getChildren()) {
|
||||
for (XmlNode dominantChild : dominant.getChildren()) {
|
||||
if (idValue.equals(dominantChild.getAttribute(ID_COMBINATION_MODE_ATTRIBUTE))) {
|
||||
childDom = dominantChild;
|
||||
// we have a match, so don't append but merge
|
||||
|
@ -268,7 +269,7 @@ public class Xpp3Dom implements Serializable, Dom {
|
|||
.collect(Collectors.toMap(
|
||||
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)
|
||||
.collect(Collectors.toMap(
|
||||
k -> k, k -> Optional.ofNullable(dominantChild.getAttribute(k))));
|
||||
|
@ -284,12 +285,12 @@ public class Xpp3Dom implements Serializable, Dom {
|
|||
}
|
||||
|
||||
if (mergeChildren && childDom != null) {
|
||||
Map<String, Iterator<Dom>> commonChildren = new HashMap<>();
|
||||
Map<String, Iterator<XmlNode>> commonChildren = new HashMap<>();
|
||||
Set<String> names = recessive.getChildren().stream()
|
||||
.map(Dom::getName)
|
||||
.map(XmlNode::getName)
|
||||
.collect(Collectors.toSet());
|
||||
for (String name : names) {
|
||||
List<Dom> dominantChildren = dominant.getChildren().stream()
|
||||
List<XmlNode> dominantChildren = dominant.getChildren().stream()
|
||||
.filter(n -> n.getName().equals(name))
|
||||
.collect(Collectors.toList());
|
||||
if (dominantChildren.size() > 0) {
|
||||
|
@ -298,7 +299,7 @@ public class Xpp3Dom implements Serializable, Dom {
|
|||
}
|
||||
|
||||
String name = recessiveChild.getName();
|
||||
Iterator<Dom> it =
|
||||
Iterator<XmlNode> it =
|
||||
commonChildren.computeIfAbsent(name, n1 -> Stream.of(dominant.getChildren().stream()
|
||||
.filter(n2 -> n2.getName().equals(n1))
|
||||
.collect(Collectors.toList()))
|
||||
|
@ -312,7 +313,7 @@ public class Xpp3Dom implements Serializable, Dom {
|
|||
}
|
||||
children.add(recessiveChild);
|
||||
} else if (it.hasNext()) {
|
||||
Dom dominantChild = it.next();
|
||||
XmlNode dominantChild = it.next();
|
||||
|
||||
String dominantChildCombinationMode =
|
||||
dominantChild.getAttribute(SELF_COMBINATION_MODE_ATTRIBUTE);
|
||||
|
@ -323,7 +324,7 @@ public class Xpp3Dom implements Serializable, Dom {
|
|||
children.remove(dominantChild);
|
||||
} else {
|
||||
int idx = dominant.getChildren().indexOf(dominantChild);
|
||||
Dom merged = merge(dominantChild, recessiveChild, childMergeOverride);
|
||||
XmlNode merged = merge(dominantChild, recessiveChild, childMergeOverride);
|
||||
if (merged != dominantChild) {
|
||||
if (children == null) {
|
||||
children = new ArrayList<>(dominant.getChildren());
|
||||
|
@ -355,7 +356,7 @@ public class Xpp3Dom implements Serializable, Dom {
|
|||
if (children == null) {
|
||||
children = dominant.getChildren();
|
||||
}
|
||||
return new Xpp3Dom(
|
||||
return new XmlNodeImpl(
|
||||
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
|
||||
* @return merged DOM
|
||||
*/
|
||||
public static Dom merge(Dom dominant, Dom recessive) {
|
||||
public static XmlNode merge(XmlNode dominant, XmlNode recessive) {
|
||||
return merge(dominant, recessive, null);
|
||||
}
|
||||
|
||||
|
@ -388,11 +389,11 @@ public class Xpp3Dom implements Serializable, Dom {
|
|||
if (o == null || getClass() != o.getClass()) {
|
||||
return false;
|
||||
}
|
||||
Xpp3Dom xpp3Dom = (Xpp3Dom) o;
|
||||
return name.equals(xpp3Dom.name)
|
||||
&& Objects.equals(value, xpp3Dom.value)
|
||||
&& attributes.equals(xpp3Dom.attributes)
|
||||
&& children.equals(xpp3Dom.children);
|
||||
XmlNodeImpl that = (XmlNodeImpl) o;
|
||||
return Objects.equals(this.name, that.name)
|
||||
&& Objects.equals(this.value, that.value)
|
||||
&& Objects.equals(this.attributes, that.attributes)
|
||||
&& Objects.equals(this.children, that.children);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -403,14 +404,14 @@ public class Xpp3Dom implements Serializable, Dom {
|
|||
@Override
|
||||
public String toString() {
|
||||
StringWriter writer = new StringWriter();
|
||||
Xpp3DomWriter.write(writer, this);
|
||||
XmlNodeWriter.write(writer, this);
|
||||
return writer.toString();
|
||||
}
|
||||
|
||||
public String toUnescapedString() {
|
||||
StringWriter writer = new StringWriter();
|
||||
XMLWriter xmlWriter = new PrettyPrintXMLWriter(writer);
|
||||
Xpp3DomWriter.write(xmlWriter, this, false);
|
||||
XmlNodeWriter.write(xmlWriter, this, false);
|
||||
return writer.toString();
|
||||
}
|
||||
|
|
@ -22,33 +22,33 @@ import java.io.PrintWriter;
|
|||
import java.io.Writer;
|
||||
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.XMLWriter;
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
public class Xpp3DomWriter {
|
||||
public static void write(Writer writer, Dom dom) {
|
||||
public class XmlNodeWriter {
|
||||
public static void write(Writer writer, XmlNode 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);
|
||||
}
|
||||
|
||||
public static void write(XMLWriter xmlWriter, Dom dom) {
|
||||
public static void write(XMLWriter xmlWriter, XmlNode dom) {
|
||||
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?
|
||||
xmlWriter.startElement(dom.getName());
|
||||
for (Map.Entry<String, String> attr : dom.getAttributes().entrySet()) {
|
||||
xmlWriter.addAttribute(attr.getKey(), attr.getValue());
|
||||
}
|
||||
for (Dom aChildren : dom.getChildren()) {
|
||||
for (XmlNode aChildren : dom.getChildren()) {
|
||||
write(xmlWriter, aChildren, escape);
|
||||
}
|
||||
|
|
@ -18,16 +18,16 @@
|
|||
*/
|
||||
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.PlexusConfiguration;
|
||||
|
||||
public class XmlPlexusConfiguration extends DefaultPlexusConfiguration {
|
||||
public static PlexusConfiguration toPlexusConfiguration(Dom node) {
|
||||
public static PlexusConfiguration toPlexusConfiguration(XmlNode node) {
|
||||
return new XmlPlexusConfiguration(node);
|
||||
}
|
||||
|
||||
public XmlPlexusConfiguration(Dom node) {
|
||||
public XmlPlexusConfiguration(XmlNode node) {
|
||||
super(node.getName(), node.getValue());
|
||||
node.getAttributes().forEach(this::setAttribute);
|
||||
node.getChildren().forEach(c -> this.addChild(new XmlPlexusConfiguration(c)));
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
// 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;
|
||||
|
|
|
@ -25,7 +25,8 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
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.xml.pull.XmlSerializer;
|
||||
|
||||
|
@ -67,10 +68,10 @@ public class Xpp3Dom implements Serializable {
|
|||
public static final String DEFAULT_SELF_COMBINATION_MODE = SELF_COMBINATION_MERGE;
|
||||
|
||||
private ChildrenTracking childrenTracking;
|
||||
private Dom dom;
|
||||
private XmlNode dom;
|
||||
|
||||
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.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
public Xpp3Dom(Dom dom, Xpp3Dom parent) {
|
||||
public Xpp3Dom(XmlNode dom, Xpp3Dom parent) {
|
||||
this.dom = dom;
|
||||
this.childrenTracking = parent::replace;
|
||||
}
|
||||
|
||||
public Xpp3Dom(Dom dom, ChildrenTracking childrenTracking) {
|
||||
public Xpp3Dom(XmlNode dom, ChildrenTracking childrenTracking) {
|
||||
this.dom = dom;
|
||||
this.childrenTracking = childrenTracking;
|
||||
}
|
||||
|
||||
public Dom getDom() {
|
||||
public XmlNode getDom() {
|
||||
return dom;
|
||||
}
|
||||
|
||||
|
@ -134,8 +135,7 @@ public class Xpp3Dom implements Serializable {
|
|||
}
|
||||
|
||||
public void setValue(String value) {
|
||||
update(new org.apache.maven.internal.xml.Xpp3Dom(
|
||||
dom.getName(), value, dom.getAttributes(), dom.getChildren(), dom.getInputLocation()));
|
||||
update(new XmlNodeImpl(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());
|
||||
boolean ret = attrs.remove(name) != null;
|
||||
if (ret) {
|
||||
update(new org.apache.maven.internal.xml.Xpp3Dom(
|
||||
update(new XmlNodeImpl(
|
||||
dom.getName(), dom.getValue(), attrs, dom.getChildren(), dom.getInputLocation()));
|
||||
}
|
||||
return ret;
|
||||
|
@ -184,8 +184,7 @@ public class Xpp3Dom implements Serializable {
|
|||
}
|
||||
Map<String, String> attrs = new HashMap<>(dom.getAttributes());
|
||||
attrs.put(name, value);
|
||||
update(new org.apache.maven.internal.xml.Xpp3Dom(
|
||||
dom.getName(), dom.getValue(), attrs, dom.getChildren(), dom.getInputLocation()));
|
||||
update(new XmlNodeImpl(dom.getName(), dom.getValue(), attrs, dom.getChildren(), dom.getInputLocation()));
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
@ -197,16 +196,15 @@ public class Xpp3Dom implements Serializable {
|
|||
}
|
||||
|
||||
public Xpp3Dom getChild(String name) {
|
||||
Dom child = dom.getChild(name);
|
||||
XmlNode child = dom.getChild(name);
|
||||
return child != null ? new Xpp3Dom(child, this) : null;
|
||||
}
|
||||
|
||||
public void addChild(Xpp3Dom xpp3Dom) {
|
||||
List<Dom> children = new ArrayList<>(dom.getChildren());
|
||||
List<XmlNode> children = new ArrayList<>(dom.getChildren());
|
||||
children.add(xpp3Dom.dom);
|
||||
xpp3Dom.childrenTracking = this::replace;
|
||||
update(new org.apache.maven.internal.xml.Xpp3Dom(
|
||||
dom.getName(), dom.getValue(), dom.getAttributes(), children, dom.getInputLocation()));
|
||||
update(new XmlNodeImpl(dom.getName(), dom.getValue(), dom.getAttributes(), children, dom.getInputLocation()));
|
||||
}
|
||||
|
||||
public Xpp3Dom[] getChildren() {
|
||||
|
@ -225,17 +223,15 @@ public class Xpp3Dom implements Serializable {
|
|||
}
|
||||
|
||||
public void removeChild(int i) {
|
||||
List<Dom> children = new ArrayList<>(dom.getChildren());
|
||||
List<XmlNode> children = new ArrayList<>(dom.getChildren());
|
||||
children.remove(i);
|
||||
update(new org.apache.maven.internal.xml.Xpp3Dom(
|
||||
dom.getName(), dom.getValue(), dom.getAttributes(), children, dom.getInputLocation()));
|
||||
update(new XmlNodeImpl(dom.getName(), dom.getValue(), dom.getAttributes(), children, dom.getInputLocation()));
|
||||
}
|
||||
|
||||
public void removeChild(Xpp3Dom child) {
|
||||
List<Dom> children = new ArrayList<>(dom.getChildren());
|
||||
List<XmlNode> children = new ArrayList<>(dom.getChildren());
|
||||
children.remove(child.dom);
|
||||
update(new org.apache.maven.internal.xml.Xpp3Dom(
|
||||
dom.getName(), dom.getValue(), dom.getAttributes(), children, dom.getInputLocation()));
|
||||
update(new XmlNodeImpl(dom.getName(), dom.getValue(), dom.getAttributes(), children, dom.getInputLocation()));
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------
|
||||
|
@ -265,8 +261,7 @@ public class Xpp3Dom implements Serializable {
|
|||
* @param inputLocation input location to set
|
||||
*/
|
||||
public void setInputLocation(Object inputLocation) {
|
||||
update(new org.apache.maven.internal.xml.Xpp3Dom(
|
||||
dom.getName(), dom.getValue(), dom.getAttributes(), dom.getChildren(), inputLocation));
|
||||
update(new XmlNodeImpl(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));
|
||||
}
|
||||
|
||||
private void update(Dom dom) {
|
||||
private void update(XmlNode dom) {
|
||||
if (childrenTracking != null) {
|
||||
childrenTracking.replace(this.dom, dom);
|
||||
}
|
||||
|
@ -413,10 +408,9 @@ public class Xpp3Dom implements Serializable {
|
|||
}
|
||||
|
||||
private boolean replace(Object prevChild, Object newChild) {
|
||||
List<Dom> children = new ArrayList<>(dom.getChildren());
|
||||
children.replaceAll(d -> d == prevChild ? (Dom) newChild : d);
|
||||
update(new org.apache.maven.internal.xml.Xpp3Dom(
|
||||
dom.getName(), dom.getValue(), dom.getAttributes(), children, dom.getInputLocation()));
|
||||
List<XmlNode> children = new ArrayList<>(dom.getChildren());
|
||||
children.replaceAll(d -> d == prevChild ? (XmlNode) newChild : d);
|
||||
update(new XmlNodeImpl(dom.getName(), dom.getValue(), dom.getAttributes(), children, dom.getInputLocation()));
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@ import java.io.IOException;
|
|||
import java.io.InputStream;
|
||||
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.XmlPullParserException;
|
||||
|
||||
|
@ -49,7 +50,7 @@ public class Xpp3DomBuilder {
|
|||
|
||||
public static Xpp3Dom build(InputStream is, String encoding, boolean trim)
|
||||
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 {
|
||||
|
@ -61,8 +62,8 @@ public class Xpp3DomBuilder {
|
|||
*/
|
||||
public static Xpp3Dom build(Reader reader, boolean trim, InputLocationBuilder locationBuilder)
|
||||
throws XmlPullParserException, IOException {
|
||||
return new Xpp3Dom(org.apache.maven.internal.xml.Xpp3DomBuilder.build(
|
||||
reader, trim, locationBuilder != null ? locationBuilder::toInputLocation : null));
|
||||
return new Xpp3Dom(
|
||||
XmlNodeBuilder.build(reader, trim, locationBuilder != null ? locationBuilder::toInputLocation : null));
|
||||
}
|
||||
|
||||
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)
|
||||
throws XmlPullParserException, IOException {
|
||||
return new Xpp3Dom(org.apache.maven.internal.xml.Xpp3DomBuilder.build(
|
||||
parser, trim, locationBuilder != null ? locationBuilder::toInputLocation : null));
|
||||
return new Xpp3Dom(
|
||||
XmlNodeBuilder.build(parser, trim, locationBuilder != null ? locationBuilder::toInputLocation : null));
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -5,6 +5,6 @@
|
|||
* {@link org.codehaus.plexus.util.xml.Xpp3DomBuilder}
|
||||
* classes.
|
||||
* 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;
|
||||
|
|
|
@ -23,14 +23,14 @@ import java.io.StringReader;
|
|||
import java.util.List;
|
||||
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.XmlPullParserException;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
public class Xpp3DomTest {
|
||||
public class XmlNodeImplTest {
|
||||
|
||||
/**
|
||||
* <p>testCombineId.</p>
|
||||
|
@ -47,19 +47,19 @@ public class Xpp3DomTest {
|
|||
+ "<property combine.id='TOOVERWRITE'><name>TOOVERWRITE</name><value>RHS</value></property>"
|
||||
+ "</props>";
|
||||
|
||||
Xpp3Dom leftDom = Xpp3DomBuilder.build(new StringReader(lhs), new FixedInputLocationBuilder("left"));
|
||||
Xpp3Dom rightDom = Xpp3DomBuilder.build(new StringReader(rhs), new FixedInputLocationBuilder("right"));
|
||||
XmlNodeImpl leftDom = XmlNodeBuilder.build(new StringReader(lhs), new FixedInputLocationBuilder("left"));
|
||||
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());
|
||||
|
||||
Dom p0 = getNthChild(mergeResult, "property", 0);
|
||||
XmlNode p0 = getNthChild(mergeResult, "property", 0);
|
||||
assertEquals("LHS-ONLY", p0.getChild("name").getValue());
|
||||
assertEquals("left", p0.getChild("name").getInputLocation());
|
||||
assertEquals("LHS", p0.getChild("value").getValue());
|
||||
assertEquals("left", p0.getChild("value").getInputLocation());
|
||||
|
||||
Dom p1 = getNthChild(mergeResult, "property", 1);
|
||||
XmlNode p1 = getNthChild(mergeResult, "property", 1);
|
||||
assertEquals(
|
||||
"TOOVERWRITE",
|
||||
getNthChild(mergeResult, "property", 1).getChild("name").getValue());
|
||||
|
@ -68,7 +68,7 @@ public class Xpp3DomTest {
|
|||
"LHS", getNthChild(mergeResult, "property", 1).getChild("value").getValue());
|
||||
assertEquals("left", p1.getChild("value").getInputLocation());
|
||||
|
||||
Dom p2 = getNthChild(mergeResult, "property", 2);
|
||||
XmlNode p2 = getNthChild(mergeResult, "property", 2);
|
||||
assertEquals(
|
||||
"RHS-ONLY",
|
||||
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 combine.keys='name'><name>TOOVERWRITE</name><value>RHS</value></property>" + "</props>";
|
||||
|
||||
Xpp3Dom leftDom = Xpp3DomBuilder.build(new StringReader(lhs), new FixedInputLocationBuilder("left"));
|
||||
Xpp3Dom rightDom = Xpp3DomBuilder.build(new StringReader(rhs), new FixedInputLocationBuilder("right"));
|
||||
XmlNodeImpl leftDom = XmlNodeBuilder.build(new StringReader(lhs), new FixedInputLocationBuilder("left"));
|
||||
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());
|
||||
|
||||
Dom p0 = getNthChild(mergeResult, "property", 0);
|
||||
XmlNode p0 = getNthChild(mergeResult, "property", 0);
|
||||
assertEquals("LHS-ONLY", p0.getChild("name").getValue());
|
||||
assertEquals("left", p0.getChild("name").getInputLocation());
|
||||
assertEquals("LHS", p0.getChild("value").getValue());
|
||||
assertEquals("left", p0.getChild("value").getInputLocation());
|
||||
|
||||
Dom p1 = getNthChild(mergeResult, "property", 1);
|
||||
XmlNode p1 = getNthChild(mergeResult, "property", 1);
|
||||
assertEquals(
|
||||
"TOOVERWRITE",
|
||||
getNthChild(mergeResult, "property", 1).getChild("name").getValue());
|
||||
|
@ -114,7 +114,7 @@ public class Xpp3DomTest {
|
|||
"LHS", getNthChild(mergeResult, "property", 1).getChild("value").getValue());
|
||||
assertEquals("left", p1.getChild("value").getInputLocation());
|
||||
|
||||
Dom p2 = getNthChild(mergeResult, "property", 2);
|
||||
XmlNode p2 = getNthChild(mergeResult, "property", 2);
|
||||
assertEquals(
|
||||
"RHS-ONLY",
|
||||
getNthChild(mergeResult, "property", 2).getChild("name").getValue());
|
||||
|
@ -130,10 +130,10 @@ public class Xpp3DomTest {
|
|||
|
||||
String rhs = "<parameter>recessive</parameter>";
|
||||
|
||||
Xpp3Dom leftDom = Xpp3DomBuilder.build(new StringReader(lhs), new FixedInputLocationBuilder("left"));
|
||||
Xpp3Dom rightDom = Xpp3DomBuilder.build(new StringReader(rhs), new FixedInputLocationBuilder("right"));
|
||||
XmlNodeImpl leftDom = XmlNodeBuilder.build(new StringReader(lhs), new FixedInputLocationBuilder("left"));
|
||||
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());
|
||||
}
|
||||
|
||||
|
@ -143,10 +143,10 @@ public class Xpp3DomTest {
|
|||
|
||||
String rhs = "<parameter>recessive</parameter>";
|
||||
|
||||
Xpp3Dom leftDom = Xpp3DomBuilder.build(new StringReader(lhs), new FixedInputLocationBuilder("left"));
|
||||
Xpp3Dom rightDom = Xpp3DomBuilder.build(new StringReader(rhs), new FixedInputLocationBuilder("right"));
|
||||
XmlNodeImpl leftDom = XmlNodeBuilder.build(new StringReader(lhs), new FixedInputLocationBuilder("left"));
|
||||
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());
|
||||
}
|
||||
|
||||
|
@ -156,18 +156,18 @@ public class Xpp3DomTest {
|
|||
|
||||
String rhs = "<parameter>recessive</parameter>";
|
||||
|
||||
Xpp3Dom leftDom = Xpp3DomBuilder.build(new StringReader(lhs), new FixedInputLocationBuilder("left"));
|
||||
Xpp3Dom rightDom = Xpp3DomBuilder.build(new StringReader(rhs), new FixedInputLocationBuilder("right"));
|
||||
XmlNodeImpl leftDom = XmlNodeBuilder.build(new StringReader(lhs), new FixedInputLocationBuilder("left"));
|
||||
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());
|
||||
}
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
private static Dom getNthChild(Dom node, String name, int nth) {
|
||||
private static XmlNode getNthChild(XmlNode node, String name, int nth) {
|
||||
return node.getChildren().stream()
|
||||
.filter(n -> n.getName().equals(name))
|
||||
.skip(nth)
|
||||
|
@ -175,7 +175,7 @@ public class Xpp3DomTest {
|
|||
.orElse(null);
|
||||
}
|
||||
|
||||
private static class FixedInputLocationBuilder implements Xpp3DomBuilder.InputLocationBuilder {
|
||||
private static class FixedInputLocationBuilder implements XmlNodeBuilder.InputLocationBuilder {
|
||||
private final Object location;
|
||||
|
||||
public FixedInputLocationBuilder(Object location) {
|
Loading…
Reference in New Issue