Repository navigation
Consider POM XML comments when normalizing Maven declared licenses - #5572
Open
sujalgiriiitp-source wants to merge 1 commit into
Open
sujalgiriiitp-source wants to merge 1 commit into
sujalgiriiitp-source wants to merge 1 commit into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
MavenPomcollected XML comments, yet_parse()only used the<licenses>tags, andstrip_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 beforestrip_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 spuriousunknowndeclared licenses. Tests: added alicense-in-xml-comment.pomfixture (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--jsonCLI failures also present on clean HEAD. 113 expected.package.jsonfixtures updated: 105 POMs go from no declared license toapache-2.0, 8 keepapache-2.0with 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.