Skip to content

Consider POM XML comments when normalizing Maven declared licenses - #5572

Open
sujalgiriiitp-source wants to merge 1 commit into
aboutcode-org:developfrom
sujalgiriiitp-source:gsoc-1525-maven-pom-comments
Open

sujalgiriiitp-source wants to merge 1 commit into
aboutcode-org:developfrom
sujalgiriiitp-source:gsoc-1525-maven-pom-comments

Conversation

@sujalgiriiitp-source

Copy link
Copy Markdown

Fixes #1525. A license is commonly stated only in a top-level XML comment of a Maven POM (e.g. the Apache license header of log4j POMs), but such comments were ignored when building the package declared license: MavenPom collected XML comments, yet _parse() only used the <licenses> tags, and strip_namespace() discarded everything before the <project> tag, so the top-level comment never even reached the collected comments. This change collects XML comments from the full POM text before strip_namespace() runs, and includes the license-related ones in the extracted license statement as {license: {comments: ...}} entries, so they are detected alongside the <licenses> tags — combining the plain-text scan of the comments into the manifest result, as suggested in the issue. Only comments in which a license is actually detected are kept, so build notes and license-file mentions do not become spurious unknown declared licenses. Tests: added a license-in-xml-comment.pom fixture (Apache header comment, no <licenses> tag) and 7 new tests. tests/packagedcode/test_maven.py --test-suite all: 1110 passed; the 9 failures are pre-existing --json CLI failures also present on clean HEAD. 113 expected .package.json fixtures updated: 105 POMs go from no declared license to apache-2.0, 8 keep apache-2.0 with an additional detection from the comment. AI-use disclosure (draft — Sujal to confirm wording before posting): I used an AI coding assistant to help implement this change and draft this description; I reviewed the code and test results myself and take responsibility for them.

This branch has not been deployed

No deployments
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.

For Maven declared_license normalization, also consider all text at once as well as POM XML comments

1 participant