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: add transitive extraction for Maven pom.xml #399

Open
wants to merge 18 commits into
base: main
Choose a base branch
from
13 changes: 10 additions & 3 deletions internal/mavenutil/maven.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ func MergeParents(ctx context.Context, input *filesystem.ScanInput, mavenClient
if allowLocal {
cuixq marked this conversation as resolved.
Show resolved Hide resolved
if parentPath := ParentPOMPath(input, currentPath, string(current.RelativePath)); parentPath != "" {
currentPath = parentPath
f, err := input.FS.Open(parentPath)
f, err := input.FS.Open(filepath.ToSlash(parentPath))
if err != nil {
return fmt.Errorf("failed to open parent file %s: %w", parentPath, err)
cuixq marked this conversation as resolved.
Show resolved Hide resolved
}
Expand Down Expand Up @@ -126,16 +126,23 @@ func ParentPOMPath(input *filesystem.ScanInput, currentPath, relativePath string
if relativePath == "" {
relativePath = "../pom.xml"
}

path := filepath.Join(filepath.Dir(currentPath), relativePath)
if info, err := input.FS.Stat(path); err == nil {
fmt.Printf("path: %s\n", path)

info, err := input.FS.Stat(filepath.ToSlash(path))
cuixq marked this conversation as resolved.
Show resolved Hide resolved
if err == nil {
if !info.IsDir() {
return path
}
// Current path is a directory, so look for pom.xml in the directory.
path = filepath.Join(path, "pom.xml")
if _, err := input.FS.Stat(path); err == nil {
if _, err := input.FS.Stat(filepath.ToSlash(path)); err == nil {
return path
}
fmt.Println(err)
} else {
fmt.Println(err)
}

return ""
Expand Down
Loading