Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

util/resolve/maven: do not ignore direct test and optional dependencies #195

Merged
merged 4 commits into from
Mar 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions util/resolve/maven/resolve.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,10 +214,8 @@ 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
// TODO: make the allowed types of imports configurable
opt = testImports | optImports | providedImports
}
imps, err := r.imports(ctx, cur.VersionKey, opt)
if err == resolve.ErrNotFound && !first {
Expand Down Expand Up @@ -524,6 +522,7 @@ func (r *resolver) imports(ctx context.Context, ver resolve.VersionKey, opt impo
d := dependency{
RequirementVersion: imp,
}
d.Type = imp.Type.Clone()
if s, ok := imp.Type.GetAttr(dep.MavenExclusions); ok {
d.exclusions = parseExclusions(s)
}
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 opt|group:bob@ 1.0
└─ selector|group:chuck@ 1.0
-- END

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

-- Graph management
Expand Down
Loading