apache / apache/maven

[MNG-3283] Plugins that require dependency resolution in early phases cause dependency resolution issue

Open
#4,657 22 comments 0 reactions 0 assignees View on GitHub
bug priority:major
Dominant language
Java
Stars
5.3k
Forks
3.1k
Avg merge
20h 40m
Merged PRs (30d)
275

Description

**[Alfie Kirkpatrick](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=alfie)** opened **[MNG-3283](https://issues.apache.org/jira/browse/MNG-3283?redirect=false)** and commented

What we're seeing is that some multi-project configurations succeed on
'mvn package' but fail on 'mvn generate-sources'. They are failing when
one project in the reactor references another project in the reactor
which is not installed in the local repo. It seems that the referenced
project has not quite "made it" into the reactor this early in the phase
lifecycle. But it does work correctly if you target a later phase at the
outset which is really confusing.

The problem only occurs when a plugin binds itself to the
generate-sources phase and has `@requiresDependencyResolution`, presumably
because this is what triggers resolution of the referenced dependency
too early in the lifecycle, and hence the error.

We are seeing this problem when trying to run 'mvn eclipse:eclipse'
because this only executes the generate-sources phase by default and we
have other mojos which genuinely do generate source, such as java2wsdl.

A workaround we're using is to run 'mvn process-classes eclipse:eclipse'.

Attached is a really simple project that exhibits this problem.

---

**Affects:** 2.0.7

**Attachments:**
- [maven-dependency-bug.zip](https://issues.apache.org/jira/secure/attachment/12712218/maven-dependency-bug.zip) (_4.73 kB_)

**Issue Links:**
- [MANTRUN-216](https://issues.apache.org/jira/browse/MANTRUN-216) CLONE - Use of AntRun during clean phase fails multiproject with intermodule dependencies
(_**"Blocked"**_)
- [MNG-4331](https://issues.apache.org/jira/browse/MNG-4331) Add new requiresDependencyCollection mojo feature (with corresponding annotation) to grab dependency tree without files
(_**"is duplicated by"**_)
- [MECLIPSE-380](https://issues.apache.org/jira/browse/MECLIPSE-380) dependencies in multi-module may projects require a 'mvn install' before using
(_**"is duplicated by"**_)
- [MENFORCER-304](https://issues.apache.org/jira/browse/MENFORCER-304) Improve dependency resolving in multiple modules project

- [MDEP-409](https://issues.apache.org/jira/browse/MDEP-409) dependency:tree fails for a multi-module project where one module depends on another and "mvn install" has not been run yet

- [MDEP-410](https://issues.apache.org/jira/browse/MDEP-410) Add dependency:collect goal which prints the dependency list by resolving the POMs only

- [MNG-2277](https://issues.apache.org/jira/browse/MNG-2277) aggregating plugins in submodules of the reactor return all projects causing a chicken/egg issue

- [MNG-4331](https://issues.apache.org/jira/browse/MNG-4331) Add new requiresDependencyCollection mojo feature (with corresponding annotation) to grab dependency tree without files

- [MANTRUN-78](https://issues.apache.org/jira/browse/MANTRUN-78) Use of AntRun during clean phase fails multiproject with intermodule dependencies
(_**"is depended upon by"**_)
- [MENFORCER-42](https://issues.apache.org/jira/browse/MENFORCER-42) Maven-Enforcer-Plugin fails in multimodule project when artifacts not in repository
(_**"is depended upon by"**_)
- [MJAVADOC-116](https://issues.apache.org/jira/browse/MJAVADOC-116) Impossible to aggregate javadoc if snapshot never built
(_**"is depended upon by"**_)

25 votes, 41 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.