apache / apache/maven

[MNG-5661] Make MavenProject instances immutable after initial construction

Open
#6,461 1 comment 0 reactions 0 assignees View on GitHub
enhancement priority:major
Dominant language
Java
Stars
5.3k
Forks
3.1k
Avg merge
20h 42m
Merged PRs (30d)
297

Description

**[Jason van Zyl](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=jvanzyl)** opened **[MNG-5661](https://issues.apache.org/jira/browse/MNG-5661?redirect=false)** and commented

When a MavenProject is initially constructed it is not immutable and requires subsequent mutation to be complete in different circumstance. This makes the logic in MavenProject complex and makes MavenProject hard to understand. We need to move toward being complete and immutable after construction.

This not being the case has a number of consequences two of which are:

1) Components are required in MavenProject in order to lazily construct certain values. This complicates MavenProject when it simply should be a configuration, or data. The logic to construct anything should be moved to the ProjectBuilder, take the small hit in performance, and all construction should happen up-front.

2) The lifecycle needs to be executed in order for a MavenProject instance to be fully populated with respect to source directories and project resources. This makes it particularly hard for systems like IDEs to integrate without resorting to weird tricks to figure out generated source directories without executing Maven itself.

---

**Attachments:**
- [Maven-Reactor-Dump.png](https://issues.apache.org/jira/secure/attachment/12955925/Maven-Reactor-Dump.png) (_84.79 kB_)

**Issue Links:**
- [MNG-5751](https://issues.apache.org/jira/browse/MNG-5751) Massive memory usage regression

**Remote Links:**
- [Page
](https://cwiki.apache.org/confluence/pages/viewpage.action?pageId=67636510)

2 votes, 4 watchers

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.