ParseResult already carries the package's own Name and Version from the manifest. Most of the same formats also declare a licence in the same document node, and both scancode --package and licensee read it as the primary declared-licence signal.
Proposed fields:
type ParseResult struct {
// ...
// Licenses holds the package's declared licence values, verbatim as
// written in the manifest. Empty when the format has no licence field
// or none is set. Scalar formats produce a single-element slice.
Licenses []string
// LicenseFile is a manifest-relative path to a licence file when the
// format declares one instead of, or as well as, an expression.
LicenseFile string
}
Raw values only; callers normalise via github.com/git-pkgs/spdx if they want an SPDX expression. That keeps this package free of the spdx dependency and its regex normaliser.
Formats and their fields:
| format |
licence expression |
array form |
licence file |
package.json |
license (string or {type,url}) |
deprecated licenses: [{type,url}] |
|
Cargo.toml |
[package].license |
|
[package].license-file |
pyproject.toml |
[project].license (PEP 639 string) or {text} |
[project].classifiers License :: entries |
[project].license-files, or {file} |
setup.cfg / setup.py |
license |
classifiers |
license_files |
*.gemspec |
s.license |
s.licenses |
|
*.podspec |
s.license (string or {:type, :file}) |
|
:file key |
composer.json |
license (string) |
license (array) |
|
pom.xml |
<licenses><license><name> |
multiple <license> elements |
<url> when it points at a file |
*.nuspec |
<license type="expression"> |
|
<license type="file"> |
*.cabal |
license |
|
license-file / license-files |
DESCRIPTION (R) |
License: |
` |
`-separated |
pubspec.yaml |
none (Dart uses LICENSE file) |
|
|
go.mod |
none |
|
|
mix.exs |
licenses: in package/0 |
list |
|
*.opam |
license: |
list |
|
elm.json |
license |
|
|
bower.json |
license |
array |
|
Cost per manifest is one more field read from a node the parser already decodes; no extra I/O or parse pass. The DSL formats (gemspec, podspec, mix.exs) need one more scrape pattern alongside the existing name/version ones.
Consumers: git pkgs licenses for the declared/detected reconciliation, and git-pkgs/licenses (the scanner) which can read LicenseFile and match its text.
ParseResultalready carries the package's ownNameandVersionfrom the manifest. Most of the same formats also declare a licence in the same document node, and both scancode--packageand licensee read it as the primary declared-licence signal.Proposed fields:
Raw values only; callers normalise via
github.com/git-pkgs/spdxif they want an SPDX expression. That keeps this package free of the spdx dependency and its regex normaliser.Formats and their fields:
package.jsonlicense(string or{type,url})licenses: [{type,url}]Cargo.toml[package].license[package].license-filepyproject.toml[project].license(PEP 639 string) or{text}[project].classifiersLicense ::entries[project].license-files, or{file}setup.cfg/setup.pylicenseclassifierslicense_files*.gemspecs.licenses.licenses*.podspecs.license(string or{:type, :file}):filekeycomposer.jsonlicense(string)license(array)pom.xml<licenses><license><name><license>elements<url>when it points at a file*.nuspec<license type="expression"><license type="file">*.caballicenselicense-file/license-filesDESCRIPTION(R)License:pubspec.yamlgo.modmix.exslicenses:inpackage/0*.opamlicense:elm.jsonlicensebower.jsonlicenseCost per manifest is one more field read from a node the parser already decodes; no extra I/O or parse pass. The DSL formats (
gemspec,podspec,mix.exs) need one more scrape pattern alongside the existing name/version ones.Consumers:
git pkgs licensesfor the declared/detected reconciliation, andgit-pkgs/licenses(the scanner) which can readLicenseFileand match its text.