Skip to content

Commit

Permalink
util/resolve/maven: do not ignore direct test and optional dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
cuixq committed Feb 28, 2025
1 parent bc85dc8 commit 8feb3b4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
5 changes: 1 addition & 4 deletions util/resolve/maven/resolve.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,7 @@ func (r *resolver) resolve(ctx context.Context, vk resolve.VersionKey, requireme

var opt importsOpt
if first {
// We skip test and optional dependencies, as for a consumer, none
// would be included (the optional would be indirect).
// https://maven.apache.org/guides/introduction/introduction-to-optional-and-excludes-dependencies.html#how-do-optional-dependencies-work
opt = providedImports
opt = testImports | optImports | providedImports
}
imps, err := r.imports(ctx, cur.VersionKey, opt)
if err == resolve.ErrNotFound && !first {
Expand Down
4 changes: 4 additions & 0 deletions util/resolve/maven/testdata/resolve_test.want
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,14 @@ group:alice 1.0

-- Graph optional01
group:alice 1.0
└─ selector|group:bob@ 1.0
└─ selector|group:chuck@ 1.0
-- END

-- Graph ignoreTest01
group:alice 1.0
└─ selector|group:bob@ 1.0
└─ selector|group:chuck@ 1.0
-- END

-- Graph management
Expand Down

0 comments on commit 8feb3b4

Please sign in to comment.