[MNG-8162] Maven should warn about modules relative to parent directory
- Dominant language
- Java
- Stars
- 5.3k
- Forks
- 3.1k
- Avg merge
- 20h 42m
- Merged PRs (30d)
- 297
Description
**[Benjamin Marwell](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=mampf86)** opened **[MNG-8162](https://issues.apache.org/jira/browse/MNG-8162?redirect=false)** and commented
Maven should warn if a pom project references modules which are not direct descendants, e.g.
```html
../other
```
## Rationale
Given this situation:
* the repository root does not contain the root pom.xml
* A subdirectory contains the "root" pom.xml (e.g. ./Build/pom.xml)
* Maven must be called either via `mvn -f Build` or `cd Build && mvn`
Then it is hard to determine the root:
* Is it in the VCS clone/checkout root?
* Is it in the first common ancestor? Maybe it is in `project/dev/impl/Build` ?
* Is root=true a valid tag in either of these cases?
* what if you call maven from even yet a higher directory?
* What if both .mvn directores and the root tags are present?
* What if there are multitple .mvn directories (lets say in repo root, and in ./project/dev/impl and in ./project/dev/impl/Build)?
In any of those cases and combinations of those, Maven should print a warning
## Suggested warning
```
[WARN] This maven project has modules relative to the parent directory (../{..}. This is an invalid configuration and will be unsupported in future releases. To fix, move all descendants of a pom project to its directory, making it a direct descendant.
```
## Checks
Should be included in the new self-check
## Suggested deprecation
Maven 5 should not work under such circumstances
## Backports
Might be a candidate for backporting to 3.9.
## Documentation
The docs should clarify which "root" takes precedence (and why).
---
**Issue Links:**
- [MNG-8210](https://issues.apache.org/jira/browse/MNG-8210) Rename modules to subprojects and make them optional in the POM
- [MNG-8047](https://issues.apache.org/jira/browse/MNG-8047) Improve aggregator projects support
0 votes, 6 watchers
Contributor guide
Research direction
Start by locating Maven's module validation and the new self-check mentioned in the issue. Trace how module paths relative to a parent directory are handled, then review the documentation covering project-root precedence. Done means the invalid configuration emits the specified warning, is covered by the self-check, and the root-selection behavior is documented.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- build-system
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100