Skip to content

Required model fields vs validation #11979

@slawekjaranowski

Description

@slawekjaranowski

Validated fields (15 / 28)

Path Stage Notes
project.modelVersion raw + effective
project.groupId raw Conditionally required — only when <parent> is absent
project.artifactId raw + effective
project.version raw + effective Conditionally required — only when <parent> is absent
project.parent.groupId raw
project.parent.artifactId raw
project.dependencies.dependency.groupId effective
project.dependencies.dependency.artifactId effective
project.dependencies.dependency.exclusions.exclusion.groupId effective
project.dependencies.dependency.exclusions.exclusion.artifactId effective
project.repositories.repository.id raw
project.repositories.repository.url raw
project.build.plugins.plugin.artifactId raw
project.reporting.plugins.plugin.groupId effective Marked required but has default org.apache.maven.plugins
project.reporting.plugins.plugin.artifactId effective

Missing validations (11 / 28)

Path Notes
project.name Not validated anywhere
project.inceptionYear Not validated anywhere
project.build Object association — null not checked
project.build.sourceDirectory Has SuperPOM default — may be intentional
project.build.scriptSourceDirectory Has SuperPOM default — may be intentional
project.build.testSourceDirectory Has SuperPOM default — may be intentional
project.build.extensions.extension.groupId No validation at all
project.build.extensions.extension.artifactId No validation at all
project.profiles.profile.build Object association — null not checked
project.profiles.profile.activation.property.name Not validated
project.reporting.plugins.plugin.reportSets.reportSet.reports Not validated

Fields incorrectly marked as required in MDO — optional when <parent> is present

These fields can be inherited from the parent POM.
The MDO definition should be corrected.

Path Notes
project.groupId Optional when <parent> is present — inherited from parent
project.version Optional when <parent> is present — inherited from parent

Fields incorrectly marked as required in MDO — always have a default value

These fields are marked <required>true</required> but also define a <defaultValue>,
so they are never actually empty. The required annotation is misleading.

Path Default value Validated
project.profiles.profile.id "default" no — unnecessary given the default
project.reporting.plugins.plugin.groupId "org.apache.maven.plugins" yes — unnecessary given the default
project.reporting.plugins.plugin.reportSets.reportSet.id "default" no — unnecessary given the default

Most actionable gaps

  • project.build.extensions.extension.groupId/artifactId — build extensions have no coordinate
    validation at all, unlike plugins which do validate coordinates.
  • project.profiles.profile.activation.property.name — an activation property without a name
    silently has no effect.
  • project.reporting.plugins.plugin.reportSets.reportSet.reports — report sets are not
    validated.

Fields validated but NOT marked required in MDO

These are likely intentional and should remain as-is:

Path Default value Reason
project.parent.version Effectively required for resolution
project.build.plugins.plugin.groupId "org.apache.maven.plugins" Validated for safety even though it has a default

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions