This is an automated email from the ASF dual-hosted git repository.

gnodet pushed a commit to branch maven-4.0.x
in repository https://gitbox.apache.org/repos/asf/maven.git


The following commit(s) were added to refs/heads/maven-4.0.x by this push:
     new a1b9f093e5 Forward-port #11985: remove redundant required MDO attrs 
(#11979) (#12347)
a1b9f093e5 is described below

commit a1b9f093e5f02db77a9f17de6d0780992d7c2995
Author: Guillaume Nodet <[email protected]>
AuthorDate: Thu Jun 25 20:42:58 2026 +0200

    Forward-port #11985: remove redundant required MDO attrs (#11979) (#12347)
    
    * Forward-port #11985: remove redundant required MDO attrs (#11979)
    
    Remove <required>true</required> from 13 metadata/defaulted fields in 
maven.mdo
    (forward-port of PR #11985 from maven-3.10.x).
    Update Model.name description to document artifactId fallback.
    Add minimal POM validation tests.
    
    * Address Copilot review comments
    
    - Fix <name> field description in maven.mdo to not claim the model field
      defaults to artifactId (the fallback is a runtime behavior in
      MavenProject#getName(), not a model-level default)
    - Remove unused test POM resources minimal-with-parent.xml and
      minimal-without-parent.xml from impl/maven-impl (only referenced in
      compat/maven-model-builder tests which have their own copies)
    
    Co-Authored-By: Claude Opus 4.6 <[email protected]>
    
    ---------
    
    Co-authored-by: Claude Opus 4.6 <[email protected]>
---
 api/maven-api-model/src/main/mdo/maven.mdo         | 13 ---------
 .../validation/DefaultModelValidatorTest.java      | 12 ++++++++
 .../validation/raw-model/minimal-with-parent.xml   | 33 ++++++++++++++++++++++
 .../raw-model/minimal-without-parent.xml           | 29 +++++++++++++++++++
 .../org/apache/maven/project/MavenProject.java     |  1 -
 5 files changed, 74 insertions(+), 14 deletions(-)

diff --git a/api/maven-api-model/src/main/mdo/maven.mdo 
b/api/maven-api-model/src/main/mdo/maven.mdo
index 83dc5aff1d..69431f1d92 100644
--- a/api/maven-api-model/src/main/mdo/maven.mdo
+++ b/api/maven-api-model/src/main/mdo/maven.mdo
@@ -119,7 +119,6 @@
         <field xdoc.separator="blank">
           <name>groupId</name>
           <version>3.0.0+</version>
-          <required>true</required>
           <description>
             A universally unique identifier for a project. It is normal to
             use a fully-qualified package name to distinguish it from other
@@ -140,7 +139,6 @@
         <field>
           <name>version</name>
           <version>4.0.0+</version>
-          <required>true</required>
           <description>The current version of the artifact produced by this 
project.</description>
           <type>String</type>
         </field>
@@ -167,7 +165,6 @@
         <field xdoc.separator="blank">
           <name>name</name>
           <version>3.0.0+</version>
-          <required>true</required>
           <description>The full name of the project.</description>
           <type>String</type>
         </field>
@@ -233,7 +230,6 @@
         <field>
           <name>inceptionYear</name>
           <version>3.0.0+</version>
-          <required>true</required>
           <description>The year of the project's inception, specified with 4 
digits. This value is
             used when generating copyright notices as well as being 
informational.</description>
           <type>String</type>
@@ -355,7 +351,6 @@
         <field xdoc.separator="blank" 
xml.insertParentFieldsUpTo="pluginRepositories">
           <name>build</name>
           <version>3.0.0+</version>
-          <required>true</required>
           <description>Information required to build the project.</description>
           <association>
             <type>Build</type>
@@ -887,7 +882,6 @@
         <field>
           <name>sourceDirectory</name>
           <version>3.0.0+</version>
-          <required>true</required>
           <description>
             This element specifies a directory containing the source of the 
project. The
             generated build system will compile the sources from this 
directory when the project is
@@ -904,7 +898,6 @@
         <field>
           <name>scriptSourceDirectory</name>
           <version>4.0.0+</version>
-          <required>true</required>
           <description>
             This element specifies a directory containing the script sources 
of the
             project. This directory is meant to be different from the 
sourceDirectory, in that its
@@ -922,7 +915,6 @@
         <field>
           <name>testSourceDirectory</name>
           <version>4.0.0+</version>
-          <required>true</required>
           <description>
             This element specifies a directory containing the unit test source 
of the
             project. The generated build system will compile these directories 
when the project is
@@ -2931,7 +2923,6 @@
       <fields>
         <field>
           <name>id</name>
-          <required>true</required>
           <version>4.0.0+</version>
           <type>String</type>
           <defaultValue>default</defaultValue>
@@ -2951,7 +2942,6 @@
         <field xml.tagName="build">
           <name>build</name>
           <version>4.0.0+</version>
-          <required>true</required>
           <description>Information required to build the project.</description>
           <association>
             <type>BuildBase</type>
@@ -3290,7 +3280,6 @@
           <name>groupId</name>
           <version>4.0.0+</version>
           <type>String</type>
-          <required>true</required>
           <defaultValue>org.apache.maven.plugins</defaultValue>
           <description>The group ID of the reporting plugin in the 
repository.</description>
         </field>
@@ -3384,7 +3373,6 @@
         <field>
           <name>id</name>
           <type>String</type>
-          <required>true</required>
           <description>The unique id for this report set, to be used during 
POM inheritance and profile injection
             for merging of report sets.
           </description>
@@ -3393,7 +3381,6 @@
         <field>
           <name>reports</name>
           <version>4.0.0+</version>
-          <required>true</required>
           <description>The list of reports from this plugin which should be 
generated from this set.</description>
           <association>
             <type>String</type>
diff --git 
a/compat/maven-model-builder/src/test/java/org/apache/maven/model/validation/DefaultModelValidatorTest.java
 
b/compat/maven-model-builder/src/test/java/org/apache/maven/model/validation/DefaultModelValidatorTest.java
index 4d6c3faf1b..cfa3b44a70 100644
--- 
a/compat/maven-model-builder/src/test/java/org/apache/maven/model/validation/DefaultModelValidatorTest.java
+++ 
b/compat/maven-model-builder/src/test/java/org/apache/maven/model/validation/DefaultModelValidatorTest.java
@@ -958,4 +958,16 @@ void testConcurrentValidation() throws Exception {
                     "Concurrent validation failed: " + 
failure.get().getMessage(), failure.get());
         }
     }
+
+    @Test
+    void testMinimalWithParent() throws Exception {
+        SimpleProblemCollector result = 
validateRaw("raw-model/minimal-with-parent.xml");
+        assertViolations(result, 0, 0, 0);
+    }
+
+    @Test
+    void testMinimalWithoutParent() throws Exception {
+        SimpleProblemCollector result = 
validateRaw("raw-model/minimal-without-parent.xml");
+        assertViolations(result, 0, 0, 0);
+    }
 }
diff --git 
a/compat/maven-model-builder/src/test/resources/poms/validation/raw-model/minimal-with-parent.xml
 
b/compat/maven-model-builder/src/test/resources/poms/validation/raw-model/minimal-with-parent.xml
new file mode 100644
index 0000000000..b373d50722
--- /dev/null
+++ 
b/compat/maven-model-builder/src/test/resources/poms/validation/raw-model/minimal-with-parent.xml
@@ -0,0 +1,33 @@
+<!--
+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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0";
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
https://maven.apache.org/xsd/maven-4.0.0.xsd";>
+
+  <modelVersion>4.0.0</modelVersion>
+
+  <parent>
+    <groupId>org.apache.maven.validation</groupId>
+    <artifactId>parent</artifactId>
+    <version>1</version>
+  </parent>
+
+  <artifactId>project</artifactId>
+
+</project>
diff --git 
a/compat/maven-model-builder/src/test/resources/poms/validation/raw-model/minimal-without-parent.xml
 
b/compat/maven-model-builder/src/test/resources/poms/validation/raw-model/minimal-without-parent.xml
new file mode 100644
index 0000000000..274a34d2a0
--- /dev/null
+++ 
b/compat/maven-model-builder/src/test/resources/poms/validation/raw-model/minimal-without-parent.xml
@@ -0,0 +1,29 @@
+<!--
+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.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0";
+  xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";
+  xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
https://maven.apache.org/xsd/maven-4.0.0.xsd";>
+
+  <modelVersion>4.0.0</modelVersion>
+
+  <groupId>groupId</groupId>
+  <artifactId>project</artifactId>
+  <version>project</version>
+
+</project>
diff --git 
a/impl/maven-core/src/main/java/org/apache/maven/project/MavenProject.java 
b/impl/maven-core/src/main/java/org/apache/maven/project/MavenProject.java
index e6c2c05acb..e0f7d1c6e6 100644
--- a/impl/maven-core/src/main/java/org/apache/maven/project/MavenProject.java
+++ b/impl/maven-core/src/main/java/org/apache/maven/project/MavenProject.java
@@ -632,7 +632,6 @@ public void setName(String name) {
     }
 
     public String getName() {
-        // TODO this should not be allowed to be null.
         if (getModel().getName() != null) {
             return getModel().getName();
         } else {

Reply via email to