apache / apache/maven

[MNG-6979] MavenSession.getCurrentProject may return an incorrect project in a multimodule build

Closed
#8,057 15 comments 0 reactions 0 assignees View on GitHub
bug priority:major
Dominant language
Java
Stars
5.3k
Forks
3.1k
Avg merge
20h 42m
Merged PRs (30d)
297

Description

**[George Gastaldi](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=gastaldi)** opened **[MNG-6979](https://issues.apache.org/jira/browse/MNG-6979?redirect=false)** and commented

Having an extension that just displays the current project, like in:

```java
@Singleton
@Named
public class BuildModuleSelector extends AbstractMavenLifecycleParticipant {

@Inject
private Logger logger;

@Override
public void afterProjectsRead(MavenSession session) throws MavenExecutionException {
logger.info(session.getCurrentProject().toString());
session.setProjects(Collections.singletonList(session.getCurrentProject()));
}
}
```

Will fail to resolve the current project when executed in the root of a project that depends on a module with the same parent.

---

**Affects:** 3.6.3

**Attachments:**
- [MNG-6979.zip](https://issues.apache.org/jira/secure/attachment/13017660/MNG-6979.zip) (_4.74 kB_)
- [project.zip](https://issues.apache.org/jira/secure/attachment/13010530/project.zip) (_1.54 kB_)

**Remote Links:**
- [Temporary fix
](https://github.com/vackosar/gitflow-incremental-builder/pull/239)

0 votes, 5 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.