Skip to content

Commit

Permalink
🐛 do not add same jar twice
Browse files Browse the repository at this point in the history
Signed-off-by: Pranav Gaikwad <[email protected]>
  • Loading branch information
pranavgaikwad committed Oct 12, 2023
1 parent bf7c83e commit 3630917
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions provider/internal/java/dependency.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ func (p *javaServiceClient) discoverDepsFromJars(path string, ll map[uri.URI][]k
deps: ll,
depToLabels: p.depToLabels,
m2RepoPath: getMavenLocalRepoPath(p.mvnSettingsFile),
seen: map[string]bool{},
}
filepath.WalkDir(path, w.walkDirForJar)
}
Expand All @@ -248,6 +249,7 @@ type walker struct {
deps map[uri.URI][]provider.DepDAGItem
depToLabels map[string]*depLabelItem
m2RepoPath string
seen map[string]bool
}

func (w *walker) walkDirForJar(path string, info fs.DirEntry, err error) error {
Expand All @@ -258,6 +260,11 @@ func (w *walker) walkDirForJar(path string, info fs.DirEntry, err error) error {
return filepath.WalkDir(filepath.Join(path, info.Name()), w.walkDirForJar)
}
if strings.HasSuffix(info.Name(), ".jar") {
seenKey := filepath.Base(info.Name())
if _, ok := w.seen[seenKey]; ok {
return nil
}
w.seen[seenKey] = true
d := provider.Dep{
Name: info.Name(),
}
Expand Down

0 comments on commit 3630917

Please sign in to comment.