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

feat(pom): add parent dependency #107

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
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
24 changes: 23 additions & 1 deletion pkg/java/pom/parse.go
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ func (p *parser) parseRoot(root artifact) ([]types.Library, []types.Dependency,
return nil, nil, err
}
libs = append(libs, moduleLibs...)
if deps != nil {
if moduleDeps != nil {
deps = append(deps, moduleDeps...)
}
continue
Expand Down Expand Up @@ -156,6 +156,12 @@ func (p *parser) parseRoot(root artifact) ([]types.Library, []types.Dependency,
// Resolve transitive dependencies later
queue.enqueue(result.dependencies...)

dependency := buildArtifactDependency(result)

if len(dependency.DependsOn) > 0 {
deps = append(deps, dependency)
}

// Offline mode may be missing some fields.
if !art.IsEmpty() {
// Override the version
Expand All @@ -174,6 +180,22 @@ func (p *parser) parseRoot(root artifact) ([]types.Library, []types.Dependency,
return libs, deps, nil
}

func buildArtifactDependency(result analysisResult) types.Dependency {
dependency := types.Dependency{
ID: id(result.artifact),
}

for _, d := range result.dependencies {
dependency.DependsOn = append(dependency.DependsOn, id(d))
}

return dependency
}

func id(art artifact) string {
return fmt.Sprintf("%s.%s:%s", art.GroupID, art.ArtifactID, art.Version.String())
}

func (p *parser) parseModule(currentPath, relativePath string) (artifact, error) {
// modulePath: "root/" + "module/" => "root/module"
module, err := p.openRelativePom(currentPath, relativePath)
Expand Down
Loading