Package org.codehaus.mojo.license.api
Class DefaultThirdPartyTool
java.lang.Object
org.codehaus.mojo.license.api.DefaultThirdPartyTool
- All Implemented Interfaces:
ThirdPartyTool
Default implementation of the third party tool.
- Version:
- $Id$
- Author:
- Tony Chemit
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionvoid
addLicense
(LicenseMap licenseMap, org.apache.maven.project.MavenProject project, String... licenseNames) Add one or more licenses (name and url arelicenseNames
) to the givenlicenseMap
for the givenproject
.void
addLicense
(LicenseMap licenseMap, org.apache.maven.project.MavenProject project, List<?> licenses) Add a givenlicenses
to the givenlicenseMap
for the givenproject
.void
addLicense
(LicenseMap licenseMap, org.apache.maven.project.MavenProject project, org.apache.maven.model.License license) Add a givenlicense
to the givenlicenseMap
for the givenproject
.void
attachThirdPartyDescriptor
(org.apache.maven.project.MavenProject project, File file) For the givenproject
, attach the givenfile
as a third-party file.SortedSet
<org.apache.maven.project.MavenProject> getProjectsWithNoLicense
(LicenseMap licenseMap) From the givenlicenseMap
, obtain all the projects with no license.boolean
Is log should be verbose?loadThirdPartyDescriptorsForUnsafeMapping
(Set<org.apache.maven.artifact.Artifact> topLevelDependencies, String encoding, Collection<org.apache.maven.project.MavenProject> projects, SortedSet<org.apache.maven.project.MavenProject> unsafeDependencies, LicenseMap licenseMap, List<org.eclipse.aether.repository.RemoteRepository> remoteRepositories) Collect license information from property file, 'third-party' classified artifacts, and .license.properties dependencies.loadUnsafeMapping
(LicenseMap licenseMap, SortedMap<String, org.apache.maven.project.MavenProject> artifactCache, String encoding, File missingFile, String missingFileUrl) Loads unsafe mapping and returns it.void
mergeLicenses
(LicenseMap licenseMap, String mainLicense, Set<String> licenses) For a givenlicenseMap
, merge alllicenses
.void
overrideLicenses
(LicenseMap licenseMap, SortedMap<String, org.apache.maven.project.MavenProject> artifactCache, String encoding, String overrideUrl) Override licenses from override file.resolveMissingLicensesDescriptor
(String groupId, String artifactId, String version, List<org.eclipse.aether.repository.RemoteRepository> remoteRepositories) resolvThirdPartyDescriptor
(org.apache.maven.project.MavenProject project, List<org.eclipse.aether.repository.RemoteRepository> remoteRepositories) Obtain the third party file from the repository.void
setVerbose
(boolean verbose) Sets the verbose mode.void
writeBundleThirdPartyFile
(File thirdPartyFile, File outputDirectory, String bundleThirdPartyPath) Writes the bundled version of the third-party file.void
writeThirdPartyFile
(LicenseMap licenseMap, File thirdPartyFile, boolean verbose, String encoding, String lineFormat) Write the content of the third-party file.
-
Field Details
-
LICENSE_DB_TYPE
- See Also:
-
-
Method Details
-
isVerbose
public boolean isVerbose()Is log should be verbose?- Specified by:
isVerbose
in interfaceThirdPartyTool
- Returns:
true
if verbose log should be produced,false
otherwise.
-
setVerbose
public void setVerbose(boolean verbose) Sets the verbose mode.- Specified by:
setVerbose
in interfaceThirdPartyTool
- Parameters:
verbose
- new verbose mode to set
-
attachThirdPartyDescriptor
For the givenproject
, attach the givenfile
as a third-party file.The file will be attached as with a classifier
third-parties
and a typeproperties
.- Specified by:
attachThirdPartyDescriptor
in interfaceThirdPartyTool
- Parameters:
project
- the project on which to attch the third-party filefile
- the third-party file to attach.
-
getProjectsWithNoLicense
public SortedSet<org.apache.maven.project.MavenProject> getProjectsWithNoLicense(LicenseMap licenseMap) From the givenlicenseMap
, obtain all the projects with no license.- Specified by:
getProjectsWithNoLicense
in interfaceThirdPartyTool
- Parameters:
licenseMap
- the license map to query- Returns:
- the set of projects with no license
-
loadThirdPartyDescriptorsForUnsafeMapping
public SortedProperties loadThirdPartyDescriptorsForUnsafeMapping(Set<org.apache.maven.artifact.Artifact> topLevelDependencies, String encoding, Collection<org.apache.maven.project.MavenProject> projects, SortedSet<org.apache.maven.project.MavenProject> unsafeDependencies, LicenseMap licenseMap, List<org.eclipse.aether.repository.RemoteRepository> remoteRepositories) throws ThirdPartyToolException, IOException Collect license information from property file, 'third-party' classified artifacts, and .license.properties dependencies.- Specified by:
loadThirdPartyDescriptorsForUnsafeMapping
in interfaceThirdPartyTool
- Parameters:
topLevelDependencies
- top-level dependencies to scan for .license.properties files.encoding
- encoding used to read or write properties filesprojects
- all projects where to read third parties descriptorsunsafeDependencies
- all unsafe projectslicenseMap
- license map where to store new licensesremoteRepositories
- remote repositories- Returns:
- the map of loaded missing from the remote missing third party files
- Throws:
ThirdPartyToolException
- if anyIOException
- if any
-
resolvThirdPartyDescriptor
public File resolvThirdPartyDescriptor(org.apache.maven.project.MavenProject project, List<org.eclipse.aether.repository.RemoteRepository> remoteRepositories) throws ThirdPartyToolException Obtain the third party file from the repository.Will first search in the local repository, then into the remote repositories and will resolve it.
- Specified by:
resolvThirdPartyDescriptor
in interfaceThirdPartyTool
- Parameters:
project
- the projectremoteRepositories
- the remote repositories- Returns:
- the locale file resolved into the local repository
- Throws:
ThirdPartyToolException
- if any
-
addLicense
public void addLicense(LicenseMap licenseMap, org.apache.maven.project.MavenProject project, String... licenseNames) Add one or more licenses (name and url arelicenseNames
) to the givenlicenseMap
for the givenproject
.- Specified by:
addLicense
in interfaceThirdPartyTool
- Parameters:
licenseMap
- the license map where to add the licenseproject
- the projectlicenseNames
- the names of the licenses
-
addLicense
public void addLicense(LicenseMap licenseMap, org.apache.maven.project.MavenProject project, org.apache.maven.model.License license) Add a givenlicense
to the givenlicenseMap
for the givenproject
.- Specified by:
addLicense
in interfaceThirdPartyTool
- Parameters:
licenseMap
- the license map where to add the licenseproject
- the projectlicense
- the license to add
-
addLicense
public void addLicense(LicenseMap licenseMap, org.apache.maven.project.MavenProject project, List<?> licenses) Add a givenlicenses
to the givenlicenseMap
for the givenproject
.- Specified by:
addLicense
in interfaceThirdPartyTool
- Parameters:
licenseMap
- the license map where to add the licensesproject
- the projectlicenses
- the licenses to add
-
mergeLicenses
For a givenlicenseMap
, merge alllicenses
.The first value of the
licenses
is the license to keep and all other values will be merged into the first one.- Specified by:
mergeLicenses
in interfaceThirdPartyTool
- Parameters:
licenseMap
- the license map to mergemainLicense
- the main license to keeplicenses
- all the licenses to merge
-
loadUnsafeMapping
public SortedProperties loadUnsafeMapping(LicenseMap licenseMap, SortedMap<String, org.apache.maven.project.MavenProject> artifactCache, String encoding, File missingFile, String missingFileUrl) throws IOExceptionLoads unsafe mapping and returns it.- Specified by:
loadUnsafeMapping
in interfaceThirdPartyTool
- Parameters:
licenseMap
- license mapartifactCache
- cache of dependencies (used for id migration from missing file)encoding
- encoding used to load missing filemissingFile
- location of the optional missing filemissingFileUrl
- location of an optional missing file extension that can be downloaded from some resource hoster and that will be merged with the content of the missing file.- Returns:
- the unsafe mapping
- Throws:
IOException
- if pb while reading missing file
-
overrideLicenses
public void overrideLicenses(LicenseMap licenseMap, SortedMap<String, org.apache.maven.project.MavenProject> artifactCache, String encoding, String overrideUrl) throws IOExceptionOverride licenses from override file.- Specified by:
overrideLicenses
in interfaceThirdPartyTool
- Parameters:
licenseMap
- license mapartifactCache
- cache of dependencies (used for id migration from missing file)encoding
- encoding used to load override fileoverrideUrl
- location of an optional override file extension that can be downloaded from some resource hoster- Throws:
IOException
- if pb while reading override file
-
writeThirdPartyFile
public void writeThirdPartyFile(LicenseMap licenseMap, File thirdPartyFile, boolean verbose, String encoding, String lineFormat) throws IOException Write the content of the third-party file.- Specified by:
writeThirdPartyFile
in interfaceThirdPartyTool
- Parameters:
licenseMap
- map of all license to usethirdPartyFile
- location of file to generateverbose
- verbose flagencoding
- encoding used to generate filelineFormat
- the location of the freemarker template used to generate the file content- Throws:
IOException
- if any probem while writing file
-
writeBundleThirdPartyFile
public void writeBundleThirdPartyFile(File thirdPartyFile, File outputDirectory, String bundleThirdPartyPath) throws IOException Writes the bundled version of the third-party file.- Specified by:
writeBundleThirdPartyFile
in interfaceThirdPartyTool
- Parameters:
thirdPartyFile
- location of normal third-party fileoutputDirectory
- where to generate bundled version of the third-party filebundleThirdPartyPath
- relative end path of the file to generate- Throws:
IOException
- if any problem while writing file
-
resolveMissingLicensesDescriptor
public File resolveMissingLicensesDescriptor(String groupId, String artifactId, String version, List<org.eclipse.aether.repository.RemoteRepository> remoteRepositories) throws IOException, org.eclipse.aether.resolution.ArtifactResolutionException, org.eclipse.aether.transfer.ArtifactNotFoundException - Specified by:
resolveMissingLicensesDescriptor
in interfaceThirdPartyTool
- Throws:
IOException
org.eclipse.aether.resolution.ArtifactResolutionException
org.eclipse.aether.transfer.ArtifactNotFoundException
-