apache / apache/maven-compiler-plugin

[MCOMPILER-317] Plugin generates wrong modulepath (dependencies listed in wrong order)

Open
#541 10 comments 0 reactions 0 assignees View on GitHub
bug priority:major
Dominant language
Java
Stars
261
Forks
191
Avg merge
1d 5h
Merged PRs (30d)
8

Description

**[Gili](https://issues.apache.org/jira/secure/ViewProfile.jspa?name=cowwoc)** opened **[MCOMPILER-317](https://issues.apache.org/jira/browse/MCOMPILER-317?redirect=false)** and commented

Testcase: https://github.com/cowwoc/maven-java9-class-shadowing

If a project contains dependencies with the same module name (which is valid according to https://stackoverflow.com/a/46573805/14731) then maven-compile-plugin invokes `javac` with a modulepath containing dependencies in an (apparently) arbitrary order. If I place the project in one directory, I get one order. If I place the project in another directory, I get another order. This is 100% reproducible across multiple runs, across different computers.

I suspect that somewhere deep inside the code someone is using `HashMap` which is leading to undefined iteration order depending on the path being used.

Expected behavior: dependencies should be listed in the same order as declared in pom.xml (see https://stackoverflow.com/a/793193/14731)

Actual behavior: regardless of whether I list `ExtensionPresent` before or after `MyLibrary`, the wrong order gets passed to `javac`.

---

**Affects:** 3.7.0

**Issue Links:**
- [MNG-6357](https://issues.apache.org/jira/browse/MNG-6357) Dependency order should be nearest first

2 votes, 4 watchers

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with the reproducible project at https://github.com/cowwoc/maven-java9-class-shadowing and compare its declared dependency order with the modulepath passed to javac. Trace the Maven Compiler Plugin dependency-ordering path and verify the result against the expected pom.xml order, while checking the related MNG-6357 issue for context.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
build-system
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.