Skip to content

Commit

Permalink
refactor: add packageID
Browse files Browse the repository at this point in the history
Signed-off-by: knqyf263 <[email protected]>
  • Loading branch information
knqyf263 committed Mar 12, 2024
1 parent 1057d92 commit 5bfb04c
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions pkg/dependency/parser/java/pom/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -207,14 +207,14 @@ func (p *parser) parseRoot(root artifact) ([]types.Library, []types.Dependency,
dependsOn := lo.Map(result.dependencies, func(a artifact, _ int) string {
return a.Name()
})
uniqDeps[dependency.ID(ftypes.Pom, art.Name(), art.Version.String())] = dependsOn
uniqDeps[packageID(art.Name(), art.Version.String())] = dependsOn
}
}

// Convert to []types.Library and []types.Dependency
for name, art := range uniqArtifacts {
lib := types.Library{
ID: dependency.ID(ftypes.Pom, name, art.Version.String()),
ID: packageID(name, art.Version.String()),
Name: name,
Version: art.Version.String(),
License: art.JoinLicenses(),
Expand All @@ -226,7 +226,7 @@ func (p *parser) parseRoot(root artifact) ([]types.Library, []types.Dependency,
// Convert dependency names into dependency IDs
dependsOn := lo.FilterMap(uniqDeps[lib.ID], func(dependOnName string, _ int) (string, bool) {
ver := depVersion(dependOnName, uniqArtifacts)
return dependency.ID(ftypes.Pom, dependOnName, ver), ver != ""
return packageID(dependOnName, ver), ver != ""
})

sort.Strings(dependsOn)
Expand Down Expand Up @@ -690,3 +690,7 @@ func parsePom(r io.Reader) (*pomXML, error) {
}
return parsed, nil
}

func packageID(name, version string) string {
return dependency.ID(ftypes.Pom, name, version)
}

0 comments on commit 5bfb04c

Please sign in to comment.