-
Notifications
You must be signed in to change notification settings - Fork 41
Add functions to return maps of licenses #290
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
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
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
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.
Uh oh!
There was an error while loading. Please reload this page.
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.
I'm still not entirely sure why we need version-specific storage of the license and exception lists, especially as this establishes a precedent that won't scale well over time (i.e. when SPDX model v4, v5, ..., are eventually released). The duplication in API surface, processing, and in-memory storage of these lists is concerning to me in the long term (and very difficult to fix, once introduced).
AFIACT the license and exception lists (deliberately?) use their own unique data structures unrelated to the SPDX model, and are versioned independently of the SPDX model too (so for example SPDX license list v3.26.0 has no special relationship with SPDX model v3.0.1, despite coincidentally sharing the same major version number); SPDX license list v3.26.0 is equally compatible with SPDX model v2.x or v3.x (and presumably in future, v4.x etc.).
It seems to me that there would be substantial benefits in having Spdx-Java-Library directly implement that existing separation in the source data, and simply store the license and exception lists separately, outside the SPDX model hierarchy, in their own dedicated class structure(s) that are independent of the generated model classes.
And yes, there may be value in having method(s) that can translate a license list object into an equivalent version-specific SPDX model object, but I think it would be better for that to be stateless (i.e. not cached in Spdx-Java-Library), and opt-in (i.e. such translations are only performed if/when a user calls those translation methods). This ensures that folx who use the license list, but either don't use the SPDX model objects at all, or only use a single version of them, aren't forced to incur runtime costs that never benefit them.
This happens to be my use case, fwiw - my code makes extensive use of the license and exception lists, but zero use of the SPDX model objects, and in that context shoehorning the license and exception lists into multiple version-specific SPDX model objects is going to be counterproductive (my code will be harder to understand, and there will be negative runtime impacts that my code doesn't benefit from).
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.
@pmonks - I appreciate the concern for maintainability (as one of the maintainers ;) and I agree with many aspects of your comments, with a few differences outlined below.
We're actually not storing the data in the format - it is more of a mapping to a common data format (the license JSON files). Since there is a lot of existing code that expects the SPDX 2.X model representation, I believe there is a lot of value in having the library support that representation. Similarly, anyone implementing the SPDX 3.X model would likely require a matching Java object. I have code that expects both of these model representations, for example. That being said, I won't be making use of the map myself.
For the library, I've only supported that last 2 major releases. For example, SPDX 1.0 is no longer supported in this version of the library. Since we only do major releases of the spec every 3 to 5 years, this seems to be OK.
The license list data published in the JSON files are actually based on the SPDX 2.X model. There are a few differences due to the license list JSON file format predating the SPDX 2.X JSON format. The data itself is versioned separately, the the model is consistent. We just started publishing data in SPDX 3 format in parallel to the legacy SPDX 2 data format. BTW - In the SPDX Java library implementation, I just use the SPDX 2.X data and map that to the SPDX 3 format since they are pretty compatible.
In a way, current SPDX java library implementation isn't that far from what you are proposing:
getSpdxLicenseById), that way if no one is using a particular model version there is no penalty or overhead.In terms of the maintenance issues - it is a real pain to maintain both SPDX 3 and SPDX 2 versions of the model, but this is necessary to support high demand use cases like translating an SPDX document from SPDX 2 to SPDX 3. The incremental overhead for maintaining the license structures is very small compared to the effort of maintaining the general models.