Package org.spdx.maven.utils
Class SpdxV3LicenseManager
java.lang.Object
org.spdx.maven.utils.SpdxV3LicenseManager
Manages the SPDX Spec Version 3 licenses for the Spdx plugin. Keeps track of any extracted licenses (added as configuration
parameters to the plugin). Maps Maven licenses to SPDX licenses. Creates a Maven license from an SPDX license.
- Author:
- Gary O'Neall
-
Constructor Summary
ConstructorsConstructorDescriptionSpdxV3LicenseManager
(org.spdx.library.model.v3_0_1.core.SpdxDocument spdxDoc) License manager will track any extracted SPDX licenses and map between SPDX licenses and Maven licenses. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addExtractedLicense
(NonStandardLicense license) Add a non-listed license to the SPDX document.org.spdx.library.model.v3_0_1.simplelicensing.AnyLicenseInfo
mavenLicenseListToSpdxLicense
(List<org.apache.maven.model.License> licenseList) Map a list of Maven licenses to an SPDX license.org.spdx.library.model.v3_0_1.simplelicensing.AnyLicenseInfo
mavenLicenseToSpdxLicense
(org.apache.maven.model.License mavenLicense) Map a Maven license to an SPDX license based on the URLorg.apache.maven.model.License
spdxLicenseToMavenLicense
(org.spdx.library.model.v3_0_1.simplelicensing.AnyLicenseInfo spdxLicense) Create a Maven license from the SPDX license
-
Constructor Details
-
SpdxV3LicenseManager
public SpdxV3LicenseManager(org.spdx.library.model.v3_0_1.core.SpdxDocument spdxDoc) throws LicenseMapperException License manager will track any extracted SPDX licenses and map between SPDX licenses and Maven licenses. The mapping uses the license URL to uniquely identify the licenses.- Parameters:
spdxDoc
- SPDX document to add any extracted licenses- Throws:
LicenseMapperException
- on errors accessing SPDX listed or local licenses
-
-
Method Details
-
addExtractedLicense
Add a non-listed license to the SPDX document. Once added, the non-listed license can be referenced by the license ID- Parameters:
license
- license to add to extracted license map- Throws:
LicenseManagerException
- on errors accessing SPDX listed or local licenses
-
mavenLicenseListToSpdxLicense
public org.spdx.library.model.v3_0_1.simplelicensing.AnyLicenseInfo mavenLicenseListToSpdxLicense(List<org.apache.maven.model.License> licenseList) throws LicenseManagerException Map a list of Maven licenses to an SPDX license. If no licenses are supplied, SpdxNoAssertion license is returned. if a single license is supplied, the mapped SPDX license is returned. If multiple licenses are supplied, a conjunctive license is returned containing all mapped SPDX licenses.- Returns:
- If no licenses are supplied, SpdxNoAssertion license is returned. if a single license is supplied, the mapped SPDX license is returned. If multiple licenses are supplied, a conjunctive license is returned containing all mapped SPDX licenses.
- Throws:
LicenseManagerException
- on errors accessing SPDX listed or local licenses
-
mavenLicenseToSpdxLicense
public org.spdx.library.model.v3_0_1.simplelicensing.AnyLicenseInfo mavenLicenseToSpdxLicense(org.apache.maven.model.License mavenLicense) throws LicenseManagerException Map a Maven license to an SPDX license based on the URL- Parameters:
mavenLicense
- license to map to a listed SPDX license- Returns:
- SPDX license
- Throws:
LicenseManagerException
- thrown if no SPDX listed or extracted license exists with the same URL
-
spdxLicenseToMavenLicense
public org.apache.maven.model.License spdxLicenseToMavenLicense(org.spdx.library.model.v3_0_1.simplelicensing.AnyLicenseInfo spdxLicense) throws LicenseManagerException Create a Maven license from the SPDX license- Parameters:
spdxLicense
- source SPDX license to convert- Returns:
- a Maven license from the SPDX license
- Throws:
LicenseManagerException
- thrown if no SPDX listed or extracted license exists with the same UR
-