Package org.spdx.maven.utils
Class SpdxV2LicenseManager
java.lang.Object
org.spdx.maven.utils.SpdxV2LicenseManager
Manages the SPDX Spec version 2licenses 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
ConstructorsConstructorDescriptionSpdxV2LicenseManager
(org.spdx.library.model.v2.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.v2.license.AnyLicenseInfo
mavenLicenseListToSpdxLicense
(List<org.apache.maven.model.License> licenseList) Map a list of Maven licenses to an SPDX license.org.spdx.library.model.v2.license.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.v2.license.AnyLicenseInfo spdxLicense) Create a Maven license from the SPDX license
-
Constructor Details
-
SpdxV2LicenseManager
public SpdxV2LicenseManager(org.spdx.library.model.v2.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
- extracted license to add- Throws:
LicenseManagerException
- on errors accessing SPDX listed or local licenses
-
mavenLicenseListToSpdxLicense
public org.spdx.library.model.v2.license.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.v2.license.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.v2.license.AnyLicenseInfo spdxLicense) throws LicenseManagerException Create a Maven license from the SPDX license- Parameters:
spdxLicense
- SPDX license to convert- Returns:
- a Maven license from the SPDX license
- Throws:
LicenseManagerException
- on errors accessing SPDX listed or local licenses
-