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

fix(maven): do not track registries when fetching requirements #1466

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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: 5 additions & 2 deletions internal/resolution/client/maven_registry_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,12 +107,15 @@ func (c *MavenRegistryClient) Requirements(ctx context.Context, vk resolve.Versi
if err := proj.MergeProfiles("", maven.ActivationOS{}); err != nil {
return nil, err
}

// We should not add registries defined in dependencies pom.xml files.
apiWithoutRegistries := c.api.WithoutRegistries()
// We need to merge parents for potential dependencies in parents.
if err := mavenutil.MergeParents(ctx, c.api, &proj, proj.Parent, 1, "", false); err != nil {
if err := mavenutil.MergeParents(ctx, apiWithoutRegistries, &proj, proj.Parent, 1, "", false); err != nil {
return nil, err
}
proj.ProcessDependencies(func(groupID, artifactID, version maven.String) (maven.DependencyManagement, error) {
return mavenutil.GetDependencyManagement(ctx, c.api, groupID, artifactID, version)
return mavenutil.GetDependencyManagement(ctx, apiWithoutRegistries, groupID, artifactID, version)
})

reqs := make([]resolve.RequirementVersion, 0, len(proj.Dependencies))
Expand Down
3 changes: 2 additions & 1 deletion internal/scalibrextract/language/java/pomxmlnet/extractor.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,8 @@ func (e Extractor) Extract(ctx context.Context, input *filesystem.ScanInput) ([]
}
overrideClient.AddVersion(root, reqs)

client.PreFetch(ctx, overrideClient, reqs, filepath.Join(input.Root, input.Path))
// TODO: only run `PreFetch` for deps.dev client
// client.PreFetch(ctx, overrideClient, reqs, filepath.Join(input.Root, input.Path))
g, err := resolver.Resolve(ctx, root.VersionKey)
if err != nil {
return nil, fmt.Errorf("failed resolving %v: %w", root, err)
Expand Down
Loading