Skip to content

Expose source-level manifest declarations - #67

Merged
andrew merged 5 commits into
mainfrom
manifest-declarations
Aug 15, 2026
Merged

Expose source-level manifest declarations#67
andrew merged 5 commits into
mainfrom
manifest-declarations

Conversation

@andrew

@andrew andrew commented Aug 15, 2026

Copy link
Copy Markdown
Contributor

Add ParseResult.Declarations for dependency-like source references at stable parser-defined locations. Populate it for Maven parents, dependencies, dependency management, plugins, plugin dependencies, plugin management, extensions, and profile-scoped forms.

This keeps effective Dependencies behavior unchanged and lets consumers compare source edits without carrying a Maven XML parser. It uses pom v0.1.7 to retain raw build coordinates during the existing parse.

Closes #48.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This pull request extends the public parsing API to expose source-level “declaration” entries (dependency-like references with stable, parser-defined logical locations) while keeping the existing effective Dependencies output unchanged. For Maven POMs, it adds collection of version-bearing references beyond direct dependencies (parent, dependencyManagement, plugins, extensions, and profile-scoped variants) so consumers can diff edits without implementing a Maven XML parser.

Changes:

  • Adds a new Declaration type and ParseResult.Declarations to surface source-level references with stable Location.
  • Implements Maven POM declaration extraction (internal/maven/declarations.go) and wires it into the Maven parser.
  • Adds tests validating Maven declaration locations and PURL generation.

Reviewed changes

Copilot reviewed 7 out of 8 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
manifests.go Re-exports Declaration and adds ParseResult.Declarations, including PURL generation for declarations.
manifests_test.go Adds an integration test asserting Maven declaration PURLs are generated as expected.
internal/maven/maven.go Populates core.Result.Declarations for pom.xml parsing.
internal/maven/declarations.go New Maven POM source-level declaration collector (parent, deps, depMgmt, plugins, extensions, profiles).
internal/maven/declarations_test.go New unit tests for declaration collection semantics/locations/scopes.
internal/core/types.go Introduces core.Declaration and adds Declarations to core.Result.
go.mod Updates github.com/git-pkgs/pom dependency version.
go.sum Updates checksums for the new github.com/git-pkgs/pom version.
Suppressed comments (1)

internal/maven/declarations.go:43

  • Profile-scoped sections (DependencyManagement, Build, PluginManagement) are dereferenced without nil checks; profiles can omit these blocks, which will panic if the corresponding fields are nil pointers.
		collectPOMDependencies(&declarations, prefix+"/dependencies", profile.Dependencies)
		collectPOMDependencies(&declarations, prefix+"/dependencyManagement/dependencies", profile.DependencyManagement.Dependencies)
		collectMavenPlugins(&declarations, prefix+"/build/plugins", profile.Build.Plugins)
		collectMavenPlugins(&declarations, prefix+"/build/pluginManagement/plugins", profile.Build.PluginManagement.Plugins)
		collectMavenExtensions(&declarations, prefix+"/build/extensions", profile.Build.Extensions)

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +27 to +31
collectPOMDependencies(&declarations, "dependencies", project.Dependencies)
collectPOMDependencies(&declarations, "dependencyManagement/dependencies", project.DependencyManagement.Dependencies)
collectMavenPlugins(&declarations, "build/plugins", project.Build.Plugins)
collectMavenPlugins(&declarations, "build/pluginManagement/plugins", project.Build.PluginManagement.Plugins)
collectMavenExtensions(&declarations, "build/extensions", project.Build.Extensions)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The relevant fields in pom v0.1.7 are value fields: DepMgmt, Build, and PluginManagement. Omitted sections therefore produce zero values rather than nil pointers, so these dereferences cannot panic. No change is needed here.

Comment on lines +78 to +89
dependencyLocation := location + "/" + url.PathEscape(pluginName) + "/dependencies"
for _, dependency := range plugin.Dependencies {
appendMavenDeclaration(
declarations,
dependencyLocation,
dependency.GroupID,
dependency.ArtifactID,
dependency.Version,
core.Build,
"",
)
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Build scope is intentional here. Declaration.Scope describes when the referenced package is required by the project. Plugin dependencies are loaded on the plugin classpath during the build; mapping an omitted nested Maven scope to Runtime would misclassify them for manifests consumers.

Comment thread internal/maven/declarations.go
Comment thread manifests_test.go
Comment on lines +112 to +116
for _, declaration := range result.Declarations {
if declaration.PURL != want[declaration.Location] {
t.Errorf("declaration at %q has PURL %q, want %q", declaration.Location, declaration.PURL, want[declaration.Location])
}
}

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 56ea5fb. The test now checks map membership and reports an unexpected declaration location directly.

@andrew
andrew merged commit ea21133 into main Aug 15, 2026
5 checks passed
@andrew
andrew deleted the manifest-declarations branch August 15, 2026 16:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

maven: parse all version-bearing references

2 participants