This is an automated email from the ASF dual-hosted git repository. slachiewicz pushed a commit to branch cleanup-api-deprecations-4.0 in repository https://gitbox.apache.org/repos/asf/maven.git
commit a0ca2db9814eab72652afde17e62a4f4ac4f5d4b Author: Sylwester Lachiewicz <[email protected]> AuthorDate: Wed Nov 18 10:28:41 2026 +0100 Remove @Deprecated API members before Maven 4.0 GA - Remove @Deprecated(since = "4.0.0", forRemoval = true) methods and constants from XmlNode and XmlNodeImpl - Make @Deprecated(since = "4.0.0-rc-6") InputLocation constructors private (and remove the copy constructor) in maven-api-model and Modello templates, updating remaining callers to InputLocation.of(...) --- .../org/apache/maven/api/model/InputLocation.java | 70 +------ .../java/org/apache/maven/api/xml/XmlNode.java | 205 --------------------- .../internal/impl/DefaultLifecycleRegistry.java | 2 +- .../org/apache/maven/impl/SettingsUtilsV4.java | 2 +- .../model/DefaultDependencyManagementImporter.java | 2 +- .../DefaultDependencyManagementImporterTest.java | 24 +-- .../org/apache/maven/internal/xml/XmlNodeImpl.java | 126 ++----------- .../apache/maven/internal/xml/XmlNodeImplTest.java | 22 --- src/mdo/java/InputLocation.java | 55 +----- src/mdo/merger.vm | 2 +- src/mdo/reader-stax.vm | 12 +- 11 files changed, 43 insertions(+), 479 deletions(-) diff --git a/api/maven-api-model/src/main/java/org/apache/maven/api/model/InputLocation.java b/api/maven-api-model/src/main/java/org/apache/maven/api/model/InputLocation.java index dd8ad0ded4..fb86463238 100644 --- a/api/maven-api-model/src/main/java/org/apache/maven/api/model/InputLocation.java +++ b/api/maven-api-model/src/main/java/org/apache/maven/api/model/InputLocation.java @@ -45,15 +45,7 @@ public final class InputLocation implements Serializable, InputLocationTracker { private final Map<Object, InputLocation> locations; private final InputLocation importedFrom; - /** - * Creates an InputLocation with only a source, no line/column information. - * The line and column numbers will be set to -1 (unknown). - * - * @param source the input source where this location originates from - * @deprecated since 4.0.0-rc-6, use {@link #of(InputSource)} instead - */ - @Deprecated - public InputLocation(InputSource source) { + private InputLocation(InputSource source) { this.lineNumber = -1; this.columnNumber = -1; this.source = source; @@ -61,42 +53,15 @@ public InputLocation(InputSource source) { this.importedFrom = null; } - /** - * Creates an InputLocation with line and column numbers but no source. - * - * @param lineNumber the line number in the source file (1-based) - * @param columnNumber the column number in the source file (1-based) - * @deprecated since 4.0.0-rc-6, use {@link #of(int, int)} instead - */ - @Deprecated - public InputLocation(int lineNumber, int columnNumber) { + private InputLocation(int lineNumber, int columnNumber) { this(lineNumber, columnNumber, null, null); } - /** - * Creates an InputLocation with line number, column number, and source. - * - * @param lineNumber the line number in the source file (1-based) - * @param columnNumber the column number in the source file (1-based) - * @param source the input source where this location originates from - * @deprecated since 4.0.0-rc-6, use {@link #of(int, int, InputSource)} instead - */ - @Deprecated - public InputLocation(int lineNumber, int columnNumber, InputSource source) { + private InputLocation(int lineNumber, int columnNumber, InputSource source) { this(lineNumber, columnNumber, source, null); } - /** - * Creates an InputLocation with line number, column number, source, and a self-location key. - * - * @param lineNumber the line number in the source file (1-based) - * @param columnNumber the column number in the source file (1-based) - * @param source the input source where this location originates from - * @param selfLocationKey the key to map this location to itself in the locations map - * @deprecated since 4.0.0-rc-6, use {@link #of(int, int, InputSource, Object)} instead - */ - @Deprecated - public InputLocation(int lineNumber, int columnNumber, InputSource source, Object selfLocationKey) { + private InputLocation(int lineNumber, int columnNumber, InputSource source, Object selfLocationKey) { this.lineNumber = lineNumber; this.columnNumber = columnNumber; this.source = source; @@ -105,17 +70,7 @@ public InputLocation(int lineNumber, int columnNumber, InputSource source, Objec this.importedFrom = null; } - /** - * Creates an InputLocation with line number, column number, source, and a complete locations map. - * - * @param lineNumber the line number in the source file (1-based) - * @param columnNumber the column number in the source file (1-based) - * @param source the input source where this location originates from - * @param locations a map of keys to InputLocation instances for nested elements - * @deprecated since 4.0.0-rc-6, use {@link #of(int, int, InputSource, Map)} instead - */ - @Deprecated - public InputLocation(int lineNumber, int columnNumber, InputSource source, Map<Object, InputLocation> locations) { + private InputLocation(int lineNumber, int columnNumber, InputSource source, Map<Object, InputLocation> locations) { this.lineNumber = lineNumber; this.columnNumber = columnNumber; this.source = source; @@ -123,21 +78,6 @@ public InputLocation(int lineNumber, int columnNumber, InputSource source, Map<O this.importedFrom = null; } - /** - * Creates a copy of an existing InputLocation. - * - * @param original the InputLocation to copy - * @deprecated since 4.0.0-rc-6, use the original instance directly as InputLocation is immutable - */ - @Deprecated - public InputLocation(InputLocation original) { - this.lineNumber = original.lineNumber; - this.columnNumber = original.columnNumber; - this.source = original.source; - this.locations = original.locations; - this.importedFrom = original.importedFrom; - } - /** * Creates an InputLocation with the specified source. * diff --git a/api/maven-api-xml/src/main/java/org/apache/maven/api/xml/XmlNode.java b/api/maven-api-xml/src/main/java/org/apache/maven/api/xml/XmlNode.java index 72faff9e30..232e30c3dc 100644 --- a/api/maven-api-xml/src/main/java/org/apache/maven/api/xml/XmlNode.java +++ b/api/maven-api-xml/src/main/java/org/apache/maven/api/xml/XmlNode.java @@ -54,86 +54,6 @@ @Immutable public interface XmlNode { - /** - * @deprecated Use {@link XmlService#CHILDREN_COMBINATION_MODE_ATTRIBUTE} instead. - */ - @Deprecated(since = "4.0.0", forRemoval = true) - String CHILDREN_COMBINATION_MODE_ATTRIBUTE = XmlService.CHILDREN_COMBINATION_MODE_ATTRIBUTE; - - /** - * @deprecated Use {@link XmlService#CHILDREN_COMBINATION_MERGE} instead. - */ - @Deprecated(since = "4.0.0", forRemoval = true) - String CHILDREN_COMBINATION_MERGE = XmlService.CHILDREN_COMBINATION_MERGE; - - /** - * @deprecated Use {@link XmlService#CHILDREN_COMBINATION_APPEND} instead. - */ - @Deprecated(since = "4.0.0", forRemoval = true) - String CHILDREN_COMBINATION_APPEND = XmlService.CHILDREN_COMBINATION_APPEND; - - /** - * This default mode for combining children DOMs during merge means that where element names match, the process will - * try to merge the element data, rather than putting the dominant and recessive elements (which share the same - * element name) as siblings in the resulting DOM. - * - * @deprecated Use {@link XmlService#DEFAULT_CHILDREN_COMBINATION_MODE} instead. - */ - @Deprecated(since = "4.0.0", forRemoval = true) - String DEFAULT_CHILDREN_COMBINATION_MODE = XmlService.DEFAULT_CHILDREN_COMBINATION_MODE; - - /** - * @deprecated Use {@link XmlService#SELF_COMBINATION_MODE_ATTRIBUTE} instead. - */ - @Deprecated(since = "4.0.0", forRemoval = true) - String SELF_COMBINATION_MODE_ATTRIBUTE = XmlService.SELF_COMBINATION_MODE_ATTRIBUTE; - - /** - * @deprecated Use {@link XmlService#SELF_COMBINATION_OVERRIDE} instead. - */ - @Deprecated(since = "4.0.0", forRemoval = true) - String SELF_COMBINATION_OVERRIDE = XmlService.SELF_COMBINATION_OVERRIDE; - - /** - * @deprecated Use {@link XmlService#SELF_COMBINATION_MERGE} instead. - */ - @Deprecated(since = "4.0.0", forRemoval = true) - String SELF_COMBINATION_MERGE = XmlService.SELF_COMBINATION_MERGE; - - /** - * @deprecated Use {@link XmlService#SELF_COMBINATION_REMOVE} instead. - */ - @Deprecated(since = "4.0.0", forRemoval = true) - String SELF_COMBINATION_REMOVE = XmlService.SELF_COMBINATION_REMOVE; - - /** - * In case of complex XML structures, combining can be done based on id. - * - * @deprecated Use {@link XmlService#ID_COMBINATION_MODE_ATTRIBUTE} instead. - */ - @Deprecated(since = "4.0.0", forRemoval = true) - String ID_COMBINATION_MODE_ATTRIBUTE = XmlService.ID_COMBINATION_MODE_ATTRIBUTE; - - /** - * In case of complex XML structures, combining can be done based on keys. - * This is a comma separated list of attribute names. - * - * @deprecated Use {@link XmlService#KEYS_COMBINATION_MODE_ATTRIBUTE} instead. - */ - @Deprecated(since = "4.0.0", forRemoval = true) - String KEYS_COMBINATION_MODE_ATTRIBUTE = XmlService.KEYS_COMBINATION_MODE_ATTRIBUTE; - - /** - * This default mode for combining a DOM node during merge means that where element names match, the process will - * try to merge the element attributes and values, rather than overriding the recessive element completely with the - * dominant one. This means that wherever the dominant element doesn't provide the value or a particular attribute, - * that value or attribute will be set from the recessive DOM node. - * - * @deprecated Use {@link XmlService#DEFAULT_SELF_COMBINATION_MODE} instead. - */ - @Deprecated(since = "4.0.0", forRemoval = true) - String DEFAULT_SELF_COMBINATION_MODE = XmlService.DEFAULT_SELF_COMBINATION_MODE; - /** * Returns the local name of this XML node. * @@ -228,131 +148,6 @@ default Map<String, String> namespaces() { @Nullable Object inputLocation(); - /** - * @deprecated Use {@link #name()} instead. - */ - @Deprecated(since = "4.0.0", forRemoval = true) - @Nonnull - default String getName() { - return name(); - } - - /** - * @deprecated Use {@link #namespaceUri()} instead. - */ - @Deprecated(since = "4.0.0", forRemoval = true) - @Nonnull - default String getNamespaceUri() { - return namespaceUri(); - } - - /** - * @deprecated Use {@link #prefix()} instead. - */ - @Deprecated(since = "4.0.0", forRemoval = true) - @Nonnull - default String getPrefix() { - return prefix(); - } - - /** - * @deprecated Use {@link #value()} instead. - */ - @Deprecated(since = "4.0.0", forRemoval = true) - @Nullable - default String getValue() { - return value(); - } - - /** - * @deprecated Use {@link #attributes()} instead. - */ - @Deprecated(since = "4.0.0", forRemoval = true) - @Nonnull - default Map<String, String> getAttributes() { - return attributes(); - } - - /** - * @deprecated Use {@link #attribute(String)} instead. - */ - @Deprecated(since = "4.0.0", forRemoval = true) - @Nullable - default String getAttribute(@Nonnull String name) { - return attribute(name); - } - - /** - * @deprecated Use {@link #children()} instead. - */ - @Deprecated(since = "4.0.0", forRemoval = true) - @Nonnull - default List<XmlNode> getChildren() { - return children(); - } - - /** - * @deprecated Use {@link #child(String)} instead. - */ - @Deprecated(since = "4.0.0", forRemoval = true) - @Nullable - default XmlNode getChild(String name) { - return child(name); - } - - /** - * @deprecated Use {@link #inputLocation()} instead. - */ - @Deprecated(since = "4.0.0", forRemoval = true) - @Nullable - default Object getInputLocation() { - return inputLocation(); - } - - /** - * @deprecated Use {@link XmlService#merge(XmlNode, XmlNode, Boolean)} instead. - */ - @Deprecated(since = "4.0.0", forRemoval = true) - default XmlNode merge(@Nullable XmlNode source) { - return XmlService.merge(this, source); - } - - /** - * @deprecated Use {@link XmlService#merge(XmlNode, XmlNode, Boolean)} instead. - */ - @Deprecated(since = "4.0.0", forRemoval = true) - default XmlNode merge(@Nullable XmlNode source, @Nullable Boolean childMergeOverride) { - return XmlService.merge(this, source, childMergeOverride); - } - - /** - * Merge recessive into dominant and return either {@code dominant} - * with merged information or a clone of {@code recessive} if - * {@code dominant} is {@code null}. - * - * @param dominant the node - * @param recessive if {@code null}, nothing will happen - * @return the merged node - * - * @deprecated Use {@link XmlService#merge(XmlNode, XmlNode, Boolean)} - * with an appropriate {@code childMergeOverride} value instead. - */ - @Deprecated(since = "4.0.0", forRemoval = true) - @Nullable - static XmlNode merge(@Nullable XmlNode dominant, @Nullable XmlNode recessive) { - return XmlService.merge(dominant, recessive, null); - } - - /** - * @deprecated Use {@link XmlService#merge(XmlNode, XmlNode, Boolean)} instead. - */ - @Deprecated(since = "4.0.0", forRemoval = true) - @Nullable - static XmlNode merge( - @Nullable XmlNode dominant, @Nullable XmlNode recessive, @Nullable Boolean childMergeOverride) { - return XmlService.merge(dominant, recessive, childMergeOverride); - } - /** * Creates a new XmlNode instance with the specified name. * diff --git a/impl/maven-core/src/main/java/org/apache/maven/internal/impl/DefaultLifecycleRegistry.java b/impl/maven-core/src/main/java/org/apache/maven/internal/impl/DefaultLifecycleRegistry.java index 2117f6d91e..e0d7858235 100644 --- a/impl/maven-core/src/main/java/org/apache/maven/internal/impl/DefaultLifecycleRegistry.java +++ b/impl/maven-core/src/main/java/org/apache/maven/internal/impl/DefaultLifecycleRegistry.java @@ -100,7 +100,7 @@ public class DefaultLifecycleRegistry implements LifecycleRegistry { + ":default-lifecycle-bindings"; public static final InputLocation DEFAULT_LIFECYCLE_INPUT_LOCATION = - new InputLocation(new InputSource(DEFAULT_LIFECYCLE_MODELID, null)); + InputLocation.of(new InputSource(DEFAULT_LIFECYCLE_MODELID, null)); public static final String SCOPE_COMPILE = DependencyScope.COMPILE.id(); public static final String SCOPE_RUNTIME = DependencyScope.RUNTIME.id(); diff --git a/impl/maven-impl/src/main/java/org/apache/maven/impl/SettingsUtilsV4.java b/impl/maven-impl/src/main/java/org/apache/maven/impl/SettingsUtilsV4.java index 01b108625a..f9a29eca07 100644 --- a/impl/maven-impl/src/main/java/org/apache/maven/impl/SettingsUtilsV4.java +++ b/impl/maven-impl/src/main/java/org/apache/maven/impl/SettingsUtilsV4.java @@ -360,7 +360,7 @@ private static org.apache.maven.api.settings.InputLocation toLocation( org.apache.maven.api.model.InputSource source = location.getSource(); Map<Object, org.apache.maven.api.settings.InputLocation> locs = location.getLocations().entrySet().stream() .collect(Collectors.toMap(Map.Entry::getKey, e -> toLocation(e.getValue()))); - return new org.apache.maven.api.settings.InputLocation( + return org.apache.maven.api.settings.InputLocation.of( location.getLineNumber(), location.getColumnNumber(), source != null ? new org.apache.maven.api.settings.InputSource(source.getLocation()) : null, diff --git a/impl/maven-impl/src/main/java/org/apache/maven/impl/model/DefaultDependencyManagementImporter.java b/impl/maven-impl/src/main/java/org/apache/maven/impl/model/DefaultDependencyManagementImporter.java index 5ea201faa6..d45597f181 100644 --- a/impl/maven-impl/src/main/java/org/apache/maven/impl/model/DefaultDependencyManagementImporter.java +++ b/impl/maven-impl/src/main/java/org/apache/maven/impl/model/DefaultDependencyManagementImporter.java @@ -198,7 +198,7 @@ static Dependency updateWithImportedFrom(Dependency dependency, DependencyManage // We modify the input location that is used for the whole file. // This is likely correct because the POM hierarchy applies to the whole POM, not just one dependency. return Dependency.newBuilder(dependency, true) - .importedFrom(new InputLocation(bomLocation)) + .importedFrom(bomLocation) .build(); } } diff --git a/impl/maven-impl/src/test/java/org/apache/maven/impl/model/DefaultDependencyManagementImporterTest.java b/impl/maven-impl/src/test/java/org/apache/maven/impl/model/DefaultDependencyManagementImporterTest.java index 1a93beaaf7..da40cf9e77 100644 --- a/impl/maven-impl/src/test/java/org/apache/maven/impl/model/DefaultDependencyManagementImporterTest.java +++ b/impl/maven-impl/src/test/java/org/apache/maven/impl/model/DefaultDependencyManagementImporterTest.java @@ -46,10 +46,10 @@ void testUpdateWithImportedFromDependencyLocationAndBomLocationAreNullDependency void testUpdateWithImportedFromDependencyManagementAndDependencyHaveSameSourceDependencyImportedFromSameSource() { final InputSource source = new InputSource("SINGLE_SOURCE", ""); final Dependency dependency = Dependency.newBuilder() - .location("", new InputLocation(1, 1, source)) + .location("", InputLocation.of(1, 1, source)) .build(); final DependencyManagement bom = DependencyManagement.newBuilder() - .location("", new InputLocation(1, 1, source)) + .location("", InputLocation.of(1, 1, source)) .build(); final Dependency result = DefaultDependencyManagementImporter.updateWithImportedFrom(dependency, bom); @@ -65,10 +65,10 @@ public void testUpdateWithImportedFromSingleLevelImportedFromSet() { final InputSource dependencySource = new InputSource("DEPENDENCY", "DEPENDENCY"); final InputSource bomSource = new InputSource("BOM", "BOM"); final Dependency dependency = Dependency.newBuilder() - .location("", new InputLocation(1, 1, dependencySource)) + .location("", InputLocation.of(1, 1, dependencySource)) .build(); final DependencyManagement bom = DependencyManagement.newBuilder() - .location("", new InputLocation(2, 2, bomSource)) + .location("", InputLocation.of(2, 2, bomSource)) .build(); // Act @@ -85,12 +85,12 @@ public void testUpdateWithImportedFromMultiLevelImportedFromSetChanged() { // Arrange final InputSource bomSource = new InputSource("BOM", "BOM"); final InputSource intermediateSource = - new InputSource("INTERMEDIATE", "INTERMEDIATE", new InputLocation(bomSource)); + new InputSource("INTERMEDIATE", "INTERMEDIATE", InputLocation.of(bomSource)); final InputSource dependencySource = - new InputSource("DEPENDENCY", "DEPENDENCY", new InputLocation(intermediateSource)); - final InputLocation bomLocation = new InputLocation(2, 2, bomSource); + new InputSource("DEPENDENCY", "DEPENDENCY", InputLocation.of(intermediateSource)); + final InputLocation bomLocation = InputLocation.of(2, 2, bomSource); final Dependency dependency = Dependency.newBuilder() - .location("", new InputLocation(1, 1, dependencySource)) + .location("", InputLocation.of(1, 1, dependencySource)) .importedFrom(bomLocation) .build(); final DependencyManagement bom = @@ -109,14 +109,14 @@ public void testUpdateWithImportedFromMultiLevelAlreadyFoundInDifferentSourceImp // Arrange final InputSource bomSource = new InputSource("BOM", "BOM"); final InputSource intermediateSource = - new InputSource("INTERMEDIATE", "INTERMEDIATE", new InputLocation(bomSource)); + new InputSource("INTERMEDIATE", "INTERMEDIATE", InputLocation.of(bomSource)); final InputSource dependencySource = - new InputSource("DEPENDENCY", "DEPENDENCY", new InputLocation(intermediateSource)); + new InputSource("DEPENDENCY", "DEPENDENCY", InputLocation.of(intermediateSource)); final Dependency dependency = Dependency.newBuilder() - .location("", new InputLocation(1, 1, dependencySource)) + .location("", InputLocation.of(1, 1, dependencySource)) .build(); final DependencyManagement differentSource = DependencyManagement.newBuilder() - .location("", new InputLocation(2, 2, new InputSource("BOM2", "BOM2"))) + .location("", InputLocation.of(2, 2, new InputSource("BOM2", "BOM2"))) .build(); // Act diff --git a/impl/maven-xml/src/main/java/org/apache/maven/internal/xml/XmlNodeImpl.java b/impl/maven-xml/src/main/java/org/apache/maven/internal/xml/XmlNodeImpl.java index b73ecdcd4b..94405bf083 100644 --- a/impl/maven-xml/src/main/java/org/apache/maven/internal/xml/XmlNodeImpl.java +++ b/impl/maven-xml/src/main/java/org/apache/maven/internal/xml/XmlNodeImpl.java @@ -69,7 +69,7 @@ public XmlNodeImpl(String name, String value) { } public XmlNodeImpl(XmlNode from, String name) { - this(name, from.getValue(), from.getAttributes(), from.getChildren(), from.getInputLocation()); + this(name, from.value(), from.attributes(), from.children(), from.inputLocation()); } public XmlNodeImpl( @@ -94,110 +94,63 @@ public XmlNodeImpl( this.location = location; } - @SuppressWarnings("removal") - @Override - public XmlNode merge(XmlNode source, Boolean childMergeOverride) { - return XmlService.merge(this, source, childMergeOverride); - } - // ---------------------------------------------------------------------- // Name handling // ---------------------------------------------------------------------- - @Override - @Nonnull - @Deprecated(since = "4.0.0", forRemoval = true) - public String getPrefix() { - return prefix; - } - @Override @Nonnull public String prefix() { - return getPrefix(); - } - - @Override - @Nonnull - @Deprecated(since = "4.0.0", forRemoval = true) - public String getNamespaceUri() { - return namespaceUri; + return prefix; } @Override @Nonnull public String namespaceUri() { - return getNamespaceUri(); - } - - @Override - @Nonnull - @Deprecated(since = "4.0.0", forRemoval = true) - public String getName() { - return name; + return namespaceUri; } @Override @Nonnull public String name() { - return getName(); + return name; } // ---------------------------------------------------------------------- // Value handling // ---------------------------------------------------------------------- - @Override - @Deprecated(since = "4.0.0", forRemoval = true) - public String getValue() { - return value; - } - @Override public String value() { - return getValue(); + return value; } // ---------------------------------------------------------------------- // Attribute handling // ---------------------------------------------------------------------- - @Override - @Nonnull - @Deprecated(since = "4.0.0", forRemoval = true) - public Map<String, String> getAttributes() { - return attributes; - } - @Override @Nonnull public Map<String, String> attributes() { - return getAttributes(); - } - - @Override - @Deprecated(since = "4.0.0", forRemoval = true) - public String getAttribute(@Nonnull String name) { - return attributes.get(name); + return attributes; } @Override public String attribute(@Nonnull String name) { - return getAttribute(name); + return attributes.get(name); } // ---------------------------------------------------------------------- // Child handling // ---------------------------------------------------------------------- - @Deprecated(since = "4.0.0", forRemoval = true) @Override - public XmlNode getChild(String name) { + public XmlNode child(String name) { if (name != null) { ListIterator<XmlNode> it = children.listIterator(children.size()); while (it.hasPrevious()) { XmlNode child = it.previous(); - if (name.equals(child.getName())) { + if (name.equals(child.name())) { return child; } } @@ -205,76 +158,19 @@ public XmlNode getChild(String name) { return null; } - @Override - public XmlNode child(String name) { - return getChild(name); - } - - @Override - @Nonnull - @Deprecated(since = "4.0.0", forRemoval = true) - public List<XmlNode> getChildren() { - return children; - } - @Override @Nonnull public List<XmlNode> children() { - return getChildren(); - } - - @Deprecated(since = "4.0.0", forRemoval = true) - public int getChildCount() { - return children.size(); + return children; } // ---------------------------------------------------------------------- // Input location handling // ---------------------------------------------------------------------- - /** - * @since 3.2.0 - * @return input location - */ - @Deprecated(since = "4.0.0", forRemoval = true) - @Override - public Object getInputLocation() { - return location; - } - @Override public Object inputLocation() { - return getInputLocation(); - } - - // ---------------------------------------------------------------------- - // Helpers - // ---------------------------------------------------------------------- - - /** - * @deprecated use {@link XmlService#merge(XmlNode, XmlNode, Boolean)} instead - */ - @Deprecated(since = "4.0.0", forRemoval = true) - @SuppressWarnings("checkstyle:MethodLength") - public static XmlNode merge(XmlNode dominant, XmlNode recessive, Boolean childMergeOverride) { - return XmlService.merge(dominant, recessive, childMergeOverride); - } - - /** - * Merge two DOMs, with one having dominance in the case of collision. Merge mechanisms (vs. override for nodes, or - * vs. append for children) is determined by attributes of the dominant root node. - * - * @see XmlService#CHILDREN_COMBINATION_MODE_ATTRIBUTE - * @see XmlService#SELF_COMBINATION_MODE_ATTRIBUTE - * @param dominant The dominant DOM into which the recessive value/attributes/children will be merged - * @param recessive The recessive DOM, which will be merged into the dominant DOM - * @return merged DOM - * - * @deprecated use {@link XmlService#merge(XmlNode, XmlNode, Boolean)} instead - */ - @Deprecated(since = "4.0.0", forRemoval = true) - public static XmlNode merge(XmlNode dominant, XmlNode recessive) { - return XmlService.merge(dominant, recessive); + return location; } // ---------------------------------------------------------------------- diff --git a/impl/maven-xml/src/test/java/org/apache/maven/internal/xml/XmlNodeImplTest.java b/impl/maven-xml/src/test/java/org/apache/maven/internal/xml/XmlNodeImplTest.java index 2e03918b52..85cd3b3f98 100644 --- a/impl/maven-xml/src/test/java/org/apache/maven/internal/xml/XmlNodeImplTest.java +++ b/impl/maven-xml/src/test/java/org/apache/maven/internal/xml/XmlNodeImplTest.java @@ -1638,28 +1638,6 @@ void testPrefixedCombineSelfDoesNotOverride() throws Exception { assertNotNull(child.child("extra"), "Recessive children should survive since mvn:combine.self is ignored"); } - @Test - @SuppressWarnings("deprecation") - void testDeprecatedMergeMethods() throws Exception { - Method xmlNodeMerge3 = XmlNode.class.getMethod("merge", XmlNode.class, XmlNode.class, Boolean.class); - Deprecated dep1 = xmlNodeMerge3.getAnnotation(Deprecated.class); - assertNotNull(dep1, "XmlNode.merge(XmlNode, XmlNode, Boolean) must be annotated with @Deprecated"); - assertEquals("4.0.0", dep1.since()); - assertTrue(dep1.forRemoval()); - - Method xmlNodeImplMerge3 = XmlNodeImpl.class.getMethod("merge", XmlNode.class, XmlNode.class, Boolean.class); - Deprecated dep2 = xmlNodeImplMerge3.getAnnotation(Deprecated.class); - assertNotNull(dep2, "XmlNodeImpl.merge(XmlNode, XmlNode, Boolean) must be annotated with @Deprecated"); - assertEquals("4.0.0", dep2.since()); - assertTrue(dep2.forRemoval()); - - XmlNode dominant = XmlNode.newInstance("root", "domVal"); - XmlNode recessive = XmlNode.newInstance("root", "recVal"); - XmlNode merged = XmlNode.merge(dominant, recessive, Boolean.TRUE); - XmlNode expected = XmlService.merge(dominant, recessive, Boolean.TRUE); - assertEquals(expected, merged); - } - public static Xpp3Dom build(Reader reader) throws XmlPullParserException, IOException { try (Reader closeMe = reader) { return new Xpp3Dom(XmlNodeBuilder.build(reader, true, null)); diff --git a/src/mdo/java/InputLocation.java b/src/mdo/java/InputLocation.java index ae21b6bc6b..262f42c9c3 100644 --- a/src/mdo/java/InputLocation.java +++ b/src/mdo/java/InputLocation.java @@ -43,57 +43,22 @@ public final class InputLocation implements Serializable, InputLocationTracker { private final InputSource source; private final Map<Object, InputLocation> locations; - /** - * Creates an InputLocation with only a source, no line/column information. - * The line and column numbers will be set to -1 (unknown). - * - * @param source the input source where this location originates from - * @deprecated since 4.0.0-rc-6, use {@link #of(InputSource)} instead - */ - @Deprecated - public InputLocation(InputSource source) { + private InputLocation(InputSource source) { this.lineNumber = -1; this.columnNumber = -1; this.source = source; this.locations = Collections.singletonMap(0, this); } - /** - * Creates an InputLocation with line and column numbers but no source. - * - * @param lineNumber the line number in the source file (1-based) - * @param columnNumber the column number in the source file (1-based) - * @deprecated since 4.0.0-rc-6, use {@link #of(int, int)} instead - */ - @Deprecated - public InputLocation(int lineNumber, int columnNumber) { + private InputLocation(int lineNumber, int columnNumber) { this(lineNumber, columnNumber, null, null); } - /** - * Creates an InputLocation with line number, column number, and source. - * - * @param lineNumber the line number in the source file (1-based) - * @param columnNumber the column number in the source file (1-based) - * @param source the input source where this location originates from - * @deprecated since 4.0.0-rc-6, use {@link #of(int, int, InputSource)} instead - */ - @Deprecated - public InputLocation(int lineNumber, int columnNumber, InputSource source) { + private InputLocation(int lineNumber, int columnNumber, InputSource source) { this(lineNumber, columnNumber, source, null); } - /** - * Creates an InputLocation with line number, column number, source, and a self-location key. - * - * @param lineNumber the line number in the source file (1-based) - * @param columnNumber the column number in the source file (1-based) - * @param source the input source where this location originates from - * @param selfLocationKey the key to map this location to itself in the locations map - * @deprecated since 4.0.0-rc-6, use {@link #of(int, int, InputSource, Object)} instead - */ - @Deprecated - public InputLocation(int lineNumber, int columnNumber, InputSource source, Object selfLocationKey) { + private InputLocation(int lineNumber, int columnNumber, InputSource source, Object selfLocationKey) { this.lineNumber = lineNumber; this.columnNumber = columnNumber; this.source = source; @@ -101,17 +66,7 @@ public InputLocation(int lineNumber, int columnNumber, InputSource source, Objec selfLocationKey != null ? Collections.singletonMap(selfLocationKey, this) : Collections.emptyMap(); } - /** - * Creates an InputLocation with line number, column number, source, and a complete locations map. - * - * @param lineNumber the line number in the source file (1-based) - * @param columnNumber the column number in the source file (1-based) - * @param source the input source where this location originates from - * @param locations a map of keys to InputLocation instances for nested elements - * @deprecated since 4.0.0-rc-6, use {@link #of(int, int, InputSource, Map)} instead - */ - @Deprecated - public InputLocation(int lineNumber, int columnNumber, InputSource source, Map<Object, InputLocation> locations) { + private InputLocation(int lineNumber, int columnNumber, InputSource source, Map<Object, InputLocation> locations) { this.lineNumber = lineNumber; this.columnNumber = columnNumber; this.source = source; diff --git a/src/mdo/merger.vm b/src/mdo/merger.vm index 984232d022..19026ea223 100644 --- a/src/mdo/merger.vm +++ b/src/mdo/merger.vm @@ -156,7 +156,7 @@ public class ${className} { if (target.get${capField}() == null) { builder.location("${field.name}", source.getLocation("${field.name}")); } else if (merged != tgt) { - builder.location("${field.name}", new InputLocation(-1, -1)); + builder.location("${field.name}", InputLocation.of(-1, -1)); } #end } diff --git a/src/mdo/reader-stax.vm b/src/mdo/reader-stax.vm index fd4dc20f5a..5d08a96bdb 100644 --- a/src/mdo/reader-stax.vm +++ b/src/mdo/reader-stax.vm @@ -360,7 +360,7 @@ public class ${className} { ${classUcapName}.Builder ${classLcapName} = ${classUcapName}.newBuilder(true); #if ( $locationTracking ) if (addLocationInformation) { - ${classLcapName}.location("", new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), inputSrc)); + ${classLcapName}.location("", InputLocation.of(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), inputSrc)); } #end #if ( $class == $root ) @@ -387,7 +387,7 @@ public class ${className} { } else if ("$fieldTagName".equals(name)) { #if ( $locationTracking ) if (addLocationInformation) { - ${classLcapName}.location(name, new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), inputSrc)); + ${classLcapName}.location(name, InputLocation.of(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), inputSrc)); } #end #if ( $field.type == "String" ) @@ -460,7 +460,7 @@ public class ${className} { if ("${Helper.singular($fieldTagName)}".equals(parser.getLocalName())) { #if ( $locationTracking ) if (addLocationInformation) { - locations.put(Integer.valueOf(locations.size()), new InputLocation(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), inputSrc)); + locations.put(Integer.valueOf(locations.size()), InputLocation.of(parser.getLocation().getLineNumber(), parser.getLocation().getColumnNumber(), inputSrc)); } #end ${field.name}.add(interpolatedTrimmed(nextText(parser, strict), "${fieldTagName}")); @@ -484,7 +484,7 @@ public class ${className} { String value = nextText(parser, strict).trim(); #if ( $locationTracking ) if (addLocationInformation) { - locations.put(key, new InputLocation(propLine, propColumn, inputSrc)); + locations.put(key, InputLocation.of(propLine, propColumn, inputSrc)); } #end ${field.name}.put(key, value); @@ -541,7 +541,7 @@ public class ${className} { } #if ( $locationTracking ) if (addLocationInformation) { - ${classLcapName}.location(childName, new InputLocation(line, column, inputSrc, locations)); + ${classLcapName}.location(childName, InputLocation.of(line, column, inputSrc, locations)); } #end } @@ -777,7 +777,7 @@ public class ${className} { private XmlNode buildXmlNode(XMLStreamReader parser, InputSource inputSrc) throws XMLStreamException { return XmlService.read(parser, addLocationInformation - ? p -> new InputLocation(p.getLocation().getLineNumber(), p.getLocation().getColumnNumber(), inputSrc) + ? p -> InputLocation.of(p.getLocation().getLineNumber(), p.getLocation().getColumnNumber(), inputSrc) : null); } #else
