-
Notifications
You must be signed in to change notification settings - Fork 352
License text provider plugins #10479
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
plugins/license-text-providers/spdx/src/test/kotlin/SpdxLicenseTextProviderTest.kt
Fixed
Show fixed
Hide fixed
plugins/license-text-providers/spdx/src/test/kotlin/SpdxLicenseTextProviderTest.kt
Fixed
Show fixed
Hide fixed
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #10479 +/- ##
============================================
+ Coverage 57.38% 57.40% +0.01%
- Complexity 1673 1674 +1
============================================
Files 346 346
Lines 12759 12763 +4
Branches 1209 1209
============================================
+ Hits 7322 7326 +4
Misses 4972 4972
Partials 465 465
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
If we agree that it should be the same interface / plugin type that returns more license (meta)data later (and not a different interface / plugin type), then I believe it would be good to signal that intention by already now generalizing the interface and class names to As a side note, my old |
fb1bec9
to
aadd798
Compare
plugins/license-fact-providers/spdx/src/test/kotlin/SpdxLicenseFactProviderTest.kt
Fixed
Show fixed
Hide fixed
Also interesting in this context: A new API for OSI Approved Licenses. |
aadd798
to
fb2ae75
Compare
plugins/license-fact-providers/scancode/src/main/kotlin/ScanCodeLicenseFactProvider.kt
Fixed
Show fixed
Hide fixed
plugins/license-fact-providers/scancode/src/main/kotlin/ScanCodeLicenseFactProvider.kt
Fixed
Show fixed
Hide fixed
fb2ae75
to
2554e5a
Compare
The providers should now be on par with the currently used logic for reading license texts, but the integration is still missing. For ScanCode I have not copied the various fallbacks because I wasn't sure if they are still required. |
I believe we anyway should simplify the logic, and instead of looking in the various locations depending on how ScanCode was installed, we should use the |
plugins/license-fact-providers/api/src/main/kotlin/CompositeLicenseFactProvider.kt
Show resolved
Hide resolved
plugins/license-fact-providers/api/src/main/kotlin/CompositeLicenseFactProvider.kt
Outdated
Show resolved
Hide resolved
plugins/license-fact-providers/spdx/src/main/kotlin/SpdxLicenseFactProvider.kt
Outdated
Show resolved
Hide resolved
plugins/license-fact-providers/spdx/src/test/kotlin/SpdxLicenseFactProviderTest.kt
Outdated
Show resolved
Hide resolved
plugins/license-fact-providers/scancode/src/main/kotlin/ScanCodeLicenseFactProvider.kt
Show resolved
Hide resolved
plugins/license-fact-providers/scancode/src/main/kotlin/ScanCodeLicenseFactProvider.kt
Show resolved
Hide resolved
2554e5a
to
7cad831
Compare
plugins/license-fact-providers/dir/src/main/kotlin/DirLicenseFactProvider.kt
Fixed
Show fixed
Hide fixed
plugins/license-fact-providers/dir/src/main/kotlin/DirLicenseFactProvider.kt
Fixed
Show fixed
Hide fixed
plugins/license-fact-providers/dir/src/test/kotlin/DirLicenseFactProviderTest.kt
Fixed
Show fixed
Hide fixed
...ins/license-fact-providers/scancode/src/funTest/kotlin/ScanCodeLicenseFactProviderFunTest.kt
Fixed
Show fixed
Hide fixed
plugins/license-fact-providers/scancode/src/main/kotlin/ScanCodeLicenseFactProvider.kt
Fixed
Show fixed
Hide fixed
plugins/license-fact-providers/scancode/src/test/kotlin/ScanCodeLicenseFactProviderTest.kt
Fixed
Show fixed
Hide fixed
plugins/license-fact-providers/spdx/src/test/kotlin/SpdxLicenseFactProviderTest.kt
Fixed
Show fixed
Hide fixed
7cad831
to
4cbdae2
Compare
4cbdae2
to
b7e40cb
Compare
plugins/license-fact-providers/dir/src/main/kotlin/DirLicenseFactProvider.kt
Fixed
Show fixed
Hide fixed
4ed637c
to
86c5219
Compare
@sschuberth Some tests are still failing but you could already make another review if you want. |
plugins/reporters/asciidoc/src/main/resources/templates/freemarker_implicit.ftl
Show resolved
Hide resolved
plugins/license-fact-providers/spdx/src/test/kotlin/SpdxLicenseFactProviderTest.kt
Outdated
Show resolved
Hide resolved
...ins/license-fact-providers/scancode/src/funTest/kotlin/ScanCodeLicenseFactProviderFunTest.kt
Outdated
Show resolved
Hide resolved
...ins/license-fact-providers/scancode/src/funTest/kotlin/ScanCodeLicenseFactProviderFunTest.kt
Outdated
Show resolved
Hide resolved
0a06094
to
a7c4d9d
Compare
3b218ba
to
605ec33
Compare
plugins/license-fact-providers/api/src/main/kotlin/CompositeLicenseFactProvider.kt
Outdated
Show resolved
Hide resolved
688e4ef
to
d2bf9a8
Compare
@sschuberth In 8b19f27 I have changed the old license text provider to ignore the "+" in SPDX licenses. I have not done this in the new implementation which makes the
The reason for the commit was to fix #5004, however, in the meantime we have added license text resources for the licenses with "+" (I didn't check when). What's your opinion, should I update the expected results for the Opossum reporter or revert the SPDX provider to the previous behavior and ignore the "+"? Another option is to keep the current implementation and ignore the "+" licenses only in the Opossum Reporter when creating the It's also weird that the formatting of the license texts for the "+" licenses is different to that of the according licenses without "+". |
This has bothered me in the past in the context of other changes as well. This formatting difference seems to come from the ScanCode license DB (compare lgpl-3.0.html to lgpl-3.0-plus.html), not from the SPDX list (compare LGPL-3.0-only.txt to LGPL-3.0-or-later.txt), as historically the former had better formatting than the latter. Maybe it's time by now to really only use SPDX license texts in our resources. Or not use any resources / bundled license texts at all anymore, and least not in the core, but exclusively move this data to license fact provider plugins.
I'd not ignore the "+" anymore; after all, the license texts for these variants could be different. But I believe we should always fall back to the non-"+" text if there is no dedicated "+" text. The question is whether e should leave this for each provider to implement, or guarantee this fallback somehow via the API. So regarding |
This is a fixup for cd40dd1. Signed-off-by: Martin Nonnenmacher <martin.nonnenmacher@bosch.com>
Add the API for license fact provider plugins. The existing license text provider code will be migrated to this API in the following commits. The API is called "license fact provider" instead of "license text provider" in preparation for providing more facts about licenses than just the text. Signed-off-by: Martin Nonnenmacher <martin.nonnenmacher@bosch.com>
Add a license fact provider for SPDX licenses. The provider uses the license texts from the resources of the `:utils:spdx-utils` module. While the `getLicenseText` function from `spdx-utils` made the resolution of license exceptions optional, this is always enabled for the provider. The reason is that the reporter as the only consumer of license texts always enables that option. Signed-off-by: Martin Nonnenmacher <martin.nonnenmacher@bosch.com>
d2bf9a8
to
f0830fb
Compare
Add a license fact provider that reads license information from a local ScanCode installation. Signed-off-by: Martin Nonnenmacher <martin.nonnenmacher@bosch.com>
Add a license fact provider that reads license texts from a configurable directory. This includes a provider for the default directory, similar to the default providers for package configurations and package curations. Signed-off-by: Martin Nonnenmacher <martin.nonnenmacher@bosch.com>
Add a property to `OrtConfiguration` to configure the license fact providers to use. This will be taken into use in the following commits. The property is added to the top-level because even though license texts are currently only used by the reporter, license facts might in future also be used by other tools. Signed-off-by: Martin Nonnenmacher <martin.nonnenmacher@bosch.com>
Change the `ReporterInput` to use a `LicenseFactProvider` instead of a `LicenseTextProvider`. The `ReporterCommand` now creates the license fact providers based on the ORT configuration and support for the `--custom-license-texts-dir` option is dropped. Instead, a custom license text directory now has to be configured in the `config.yml`. Templates for the Freemarker or AsciiDoc reporters must also be updated to use `licenseFactProvider` instead of `licenseTextProvider`. The new `SpdxLicenseFactProvider` does now return the license texts for SPDX licenses with "+" instead of falling back to the texts for the licenses without "+". This requires updating the expected results for the `OpossumReporterFunTest`. Signed-off-by: Martin Nonnenmacher <martin.nonnenmacher@bosch.com>
Remove the old API for getting license texts in favor of the new `LicenseFactProvider` plugins. The `RequirementsCommand` does not check anymore if the ScanCode license directory can be found. Instead, this check will now only happen if the `ScanCodeLicenseFactProvider` is used. Signed-off-by: Martin Nonnenmacher <martin.nonnenmacher@bosch.com>
f0830fb
to
b53816a
Compare
I have updated the expected results because that was the easiest solution. |
"SPDX" to PluginConfig.EMPTY, | ||
"ScanCode" to PluginConfig.EMPTY, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a remark, nothing to be solved for this PR already: As the "SPDX" license fact provider uses resources that preferably are taken from ScanCode's LicenseDB, see
ort/utils/spdx/build.gradle.kts
Lines 110 to 111 in ebf94a6
// Prefer the texts from ScanCode as these have better formatting than those from SPDX. | |
val providers = sequenceOf(ScanCodeLicenseTextProvider(), SpdxLicenseListDataProvider()) |
this now creates a bit of a weird situation of the "SPDX" provider mostly returning "ScanCode" licenses. I'd like to clean that up after the merge of this PR so that the "SPDX" provider really only provides SPDX license texts, and then eventually switch the order of precedence here. That would also simplify the build system code, which currently has its own SpdxLicenseTextProvider
interface:
ort/utils/spdx/build.gradle.kts
Lines 72 to 74 in ebf94a6
fun interface SpdxLicenseTextProvider { | |
fun getLicenseUrl(info: LicenseInfo): URI? | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So is the argument that the formatting of the ScanCode license texts is better not valid anymore?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's hard to tell precisely without investing more time. Sometimes it's still better, sometimes just different (maybe with SPDX even being a bit nicer, depending on taste), but probably never clearly worse.
Anyway, that's not the right question to ask anymore, IMO. We can still prefer ScanCode over SPDX license text, but that should not be done at the level of creating these (SPDX!) resources, but on the new LicenseFactProvider
level.
Signed-off-by: Martin Nonnenmacher <martin.nonnenmacher@bosch.com>
Update the documentation for the new license fact provider plugins and add a section about license file archives. Signed-off-by: Martin Nonnenmacher <martin.nonnenmacher@bosch.com>
`fail_on_error` is deprecated, see [1]. [1]: https://github.com/UmbrellaDocs/action-linkspector?tab=readme-ov-file#fail_on_error Signed-off-by: Martin Nonnenmacher <martin.nonnenmacher@bosch.com>
Exclude the website from linkspector checks because Docusaurus validates links on its own and linkspector cannot validate some link formats from Docusaurus correctly. Signed-off-by: Martin Nonnenmacher <martin.nonnenmacher@bosch.com>
b53816a
to
2326dbf
Compare
A draft for license text providers, created for early feedback. The plan is to convert the existing logic into separate providers that are queried in the order defined by the user, so two more will be added:
I would also like to add on that downloads license texts on demand from https://scancode-licensedb.aboutcode.org.
@sschuberth I just discovered #9620, so should this API be renamed to
LicenseDataProvider
already and the metadata model and functions could be added later?TODO: