Skip to content

Commit

Permalink
fix: process managed dependencies before standard dependencies when p…
Browse files Browse the repository at this point in the history
…arsing `pom.xml`s (#279)
  • Loading branch information
G-Rath authored Oct 31, 2024
1 parent f72af0e commit 5fd7399
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions pkg/lockfile/parse-maven-lock.go
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ func ParseMavenLock(pathToLockfile string) ([]PackageDetails, error) {

details := map[string]PackageDetails{}

for _, lockPackage := range parsedLockfile.Dependencies {
for _, lockPackage := range parsedLockfile.ManagedDependencies {
finalName := lockPackage.GroupID + ":" + lockPackage.ArtifactID

details[finalName] = PackageDetails{
Expand All @@ -126,8 +126,8 @@ func ParseMavenLock(pathToLockfile string) ([]PackageDetails, error) {
}
}

// managed dependencies take precedent over standard dependencies
for _, lockPackage := range parsedLockfile.ManagedDependencies {
// standard dependencies take precedent over managed dependencies
for _, lockPackage := range parsedLockfile.Dependencies {
finalName := lockPackage.GroupID + ":" + lockPackage.ArtifactID

details[finalName] = PackageDetails{
Expand Down
2 changes: 1 addition & 1 deletion pkg/lockfile/parse-maven-lock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func TestParseMavenLock_WithDependencyManagement(t *testing.T) {
expectPackages(t, packages, []lockfile.PackageDetails{
{
Name: "io.netty:netty-all",
Version: "4.1.42.Final",
Version: "4.1.9",
Ecosystem: lockfile.MavenEcosystem,
CompareAs: lockfile.MavenEcosystem,
},
Expand Down

0 comments on commit 5fd7399

Please sign in to comment.