Repository navigation
chore: refactor maven autodiscovery manifest template - #10989
Conversation
The versionfilter of the generated source was only written when the pom.xml or settings.xml declares repositories. Without them, the source uses Maven Central and bumped to the latest version, whatever the version filter, major versions included. Signed-off-by: Olblak <me@olblak.com>
The dependency and parent pom crawlers declared the same anonymous template parameters, computed the source version filter the same way and parsed the constant manifest template for every dependency. Share a named manifestTemplateParams type and a renderManifest method computing the version filter, and parse the template once. The generated manifests are unchanged. Signed-off-by: Olblak <me@olblak.com>
|
Important Review skippedReview was skipped as selected files did not have any reviewable changes. ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info
📝 Walkthrough
Merge Risk: ⚪ Minimal · up to
|
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
4 open issues
template.Must(...)will panic at package init time if the template is ever invalid. Previously, a… · New The new testdata POM pinsjunit:junitto4.12, which is a known vulnerable version and may… · New These assertions are quite formatting-specific (exact indentation/newlines). Small harmless… · New The use of whitespace-trimming actions ({{- ... }}) inside YAML indentation-sensitive blocks… · New
What changed in this PR
Refactors Maven autodiscovery manifest rendering to centralize template execution and improve handling of repository-less projects ahead of upcoming Maven-related changes.
Changes:
- Parse the manifest Go template once and reuse it (instead of parsing per dependency/parent POM).
- Centralize manifest rendering (including version filter adjustments) into
renderManifest. - Add test coverage and testdata for discovery when no repositories are configured.
| File | Description |
|---|---|
| pkg/plugins/autodiscovery/maven/manifestTemplate.go | Introduces shared parsed template, parameter struct, and a single render function. |
| pkg/plugins/autodiscovery/maven/dependency.go | Switches dependency manifest generation to the shared renderer. |
| pkg/plugins/autodiscovery/maven/dependencyParentPom.go | Switches parent POM manifest generation to the shared renderer. |
| pkg/plugins/autodiscovery/maven/main_test.go | Adds coverage for discovery without repositories and version filter application. |
| pkg/plugins/autodiscovery/maven/testdata/norepository/pom.xml | Adds a repository-less POM fixture for testing. |
Review effort: Lite
Signed-off-by: Olblak <me@olblak.com>


This pullrequest is a refactoring in preparation of upcoming maven pullrequest
Test
To test this pull request, you can run the following commands:
Additional Information
Checklist
Tradeoff
Potential improvement
Summary by CodeRabbit