Skip to content

List the classes that use a dependency in verbose analyze warnings - #1816

Merged
slachiewicz merged 1 commit into
apache:masterfrom
slachiewicz:agent/analyze-verbose-why-used
Nov 21, 2026
Merged

slachiewicz merged 1 commit into
apache:masterfrom
slachiewicz:agent/analyze-verbose-why-used

Conversation

@slachiewicz

@slachiewicz slachiewicz commented Nov 21, 2026 •

Copy link
Copy Markdown
Member

With verbose, the used undeclared and non-test scoped warnings of dependency:analyze and analyze-only now list, under each class, the project classes that use it, so the warning says which code to change:

[WARNING]    org.apache.maven:maven-repository-metadata:jar:2.0.6:compile
[WARNING]       class org.apache.maven.artifact.repository.metadata.Metadata
[WARNING]          used by Main

Classes and users are sorted; the class lines under used undeclared previously came out in hash order. Output without verbose is unchanged. Usages are read before usedDependencies forcing, because the analyzer's forceDeclaredDependenciesUsage empties the usage set of every used declared dependency (apache/maven-dependency-analyzer#342). Works with analyzer 1.17.2.

Verified: mvn -Prun-its verify on JDK 17 → 757 unit tests and 122/122 ITs pass; AnalyzeMojoIgnoreTest (with the two tests added afterwards) → 19 pass; the forced-usage test fails when usages are read after forcing.

Usages are read before forceDeclaredDependenciesUsage, which empties the usage set of every used declared dependency in analyzer 1.17.2 and 1.18.0. Do not move the read after the force.
@slachiewicz slachiewicz added the enhancement New feature or request label Nov 21, 2026
@slachiewicz
slachiewicz marked this pull request as ready for review November 21, 2026 20:31
@slachiewicz
slachiewicz merged commit 5237cc8 into apache:master Nov 21, 2026
16 checks passed
@github-actions github-actions Bot added this to the 3.12.0 milestone Nov 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant