Package org.spdx.maven.utils
Class MavenToSpdxLicenseMapper
java.lang.Object
org.spdx.maven.utils.MavenToSpdxLicenseMapper
Singleton class which maps Maven license objects to SPDX licenses.
The license mapping uses the JSON file from the spdx.org/licenses/licenses.json file
If the site spdx.org/licenses is not accessible, then static version of the file will be used
The seeAlso property of the SPDX file is matched to the Maven license URL.
- Author:
- Gary O'Neall
-
Method Summary
Modifier and TypeMethodDescriptionstatic MavenToSpdxLicenseMapper
getMap()
org.spdx.library.model.v2.license.AnyLicenseInfo
mavenLicenseListToSpdxV2License
(List<org.apache.maven.model.License> licenseList, org.spdx.library.model.v2.SpdxDocument spdxDoc) Map a list of Maven licenses to an SPDX Spec version 2 license.org.spdx.library.model.v3_0_1.simplelicensing.AnyLicenseInfo
mavenLicenseListToSpdxV3License
(List<org.apache.maven.model.License> licenseList, org.spdx.library.model.v3_0_1.core.Element spdxDoc) Map a list of Maven licenses to an SPDX Spec version 2 license.urlToSpdxId
(String url)
-
Method Details
-
getInstance
- Throws:
LicenseMapperException
-
urlToSpdxId
- Parameters:
url
- URL string for a license- Returns:
- SPDX ID associated with the URL
-
mavenLicenseListToSpdxV2License
public org.spdx.library.model.v2.license.AnyLicenseInfo mavenLicenseListToSpdxV2License(List<org.apache.maven.model.License> licenseList, org.spdx.library.model.v2.SpdxDocument spdxDoc) throws org.spdx.core.InvalidSPDXAnalysisException Map a list of Maven licenses to an SPDX Spec version 2 license. If no licenses are supplied, SpdxNoAssertion license is returned. if a single license is supplied, and a URL can be found matching a listed license, the listed license is returned. if a single license is supplied, and a URL can not be found matching a listed license, SpdxNoAssertion is returned. If multiple licenses are supplied, a conjunctive license is returned containing all mapped SPDX licenses.- Parameters:
licenseList
- list of licensesspdxDoc
- SPDX document which will hold the licenses- Returns:
- SPDX license which matches the list of maven licenses
- Throws:
org.spdx.core.InvalidSPDXAnalysisException
- on SPDX parsing errors
-
mavenLicenseListToSpdxV3License
public org.spdx.library.model.v3_0_1.simplelicensing.AnyLicenseInfo mavenLicenseListToSpdxV3License(List<org.apache.maven.model.License> licenseList, org.spdx.library.model.v3_0_1.core.Element spdxDoc) throws org.spdx.core.InvalidSPDXAnalysisException Map a list of Maven licenses to an SPDX Spec version 2 license. If no licenses are supplied, SpdxNoAssertion license is returned. if a single license is supplied, and a URL can be found matching a listed license, the listed license is returned. if a single license is supplied, and a URL can not be found matching a listed license, SpdxNoAssertion is returned. If multiple licenses are supplied, a conjunctive license is returned containing all mapped SPDX licenses.- Parameters:
licenseList
- list of Maven licensesspdxDoc
- SPDX document which will hold the licenses- Returns:
- SPDX version 3 license equivalent to the list of Maven licenses
- Throws:
org.spdx.core.InvalidSPDXAnalysisException
- On SPDX parsing errors
-
getMap
- Returns:
- Map of URL's to listed license ID's
-