Skip to content

Recursive variable reference in project.url causes different behavior between Maven 3 and 4 #11074

@gnodet

Description

@gnodet

Description

When a POM contains <url>${project.url}</url>, Maven 4 now correctly detects this as a recursive variable reference and fails with an error, while Maven 3 did not detect this issue.

Example

A POM with the following content:

<project>
  <modelVersion>4.0.0</modelVersion>
  <groupId>com.example</groupId>
  <artifactId>test</artifactId>
  <version>1.0</version>
  <url>${project.url}</url>
</project>

Behavior

Maven 3

  • Build may succeed (recursive reference not detected)
  • No error or warning about the recursive reference

Maven 4

  • Build fails with: [ERROR] recursive variable reference: project.url
  • For dependency POMs: Shows warning but continues build

Real-world Impact

This issue was observed with dependencies like com.slack.api:slack-api-client:jar:1.45.4 which contain similar recursive references in their POMs:

[WARNING] The POM for com.slack.api:slack-api-client:jar:1.45.4 is invalid, transitive dependencies (if any) will not be available: 1 problem was for com.slack.api:slack-api-client:jar:1.45.4
    - [ERROR] recursive variable reference: project.url

Expected Behavior

Maven 4's behavior is correct - it should detect and prevent recursive variable references to avoid infinite loops during variable resolution. This is an improvement in Maven 4's variable interpolation system.

Proposed Solution

This issue is primarily for documentation and testing purposes. An integration test should be created to verify this behavior and ensure it continues to work correctly in future versions.

Environment

  • Maven 4.0.0+ (all versions)
  • Affects both direct POM recursive references and dependency POM recursive references

Related

This is related to the improved variable resolution and interpolation system in Maven 4.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions