Package org.codehaus.mojo.license.api
Interface ThirdPartyTool
- All Known Implementing Classes:
DefaultThirdPartyTool
public interface ThirdPartyTool
A tool to load third party files missing files.
We should put here all the logic code written in some mojo and licenseMap...
- Since:
- 1.0
- Author:
- tchemit dev@tchemit.fr
-
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> dependencies, String encoding, Collection<org.apache.maven.project.MavenProject> projects, SortedSet<org.apache.maven.project.MavenProject> unsafeProjects, 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> licensesToMerge) 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 template) Write the content of the third-party file.
-
Method Details
-
isVerbose
boolean isVerbose()Is log should be verbose?- Returns:
true
if verbose log should be produced,false
otherwise.- Since:
- 1.4
-
setVerbose
void setVerbose(boolean verbose) Sets the verbose mode.- Parameters:
verbose
- new verbose mode to set- Since:
- 1.4
-
loadThirdPartyDescriptorsForUnsafeMapping
SortedProperties loadThirdPartyDescriptorsForUnsafeMapping(Set<org.apache.maven.artifact.Artifact> dependencies, String encoding, Collection<org.apache.maven.project.MavenProject> projects, SortedSet<org.apache.maven.project.MavenProject> unsafeProjects, 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.- Parameters:
dependencies
- 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 descriptorsunsafeProjects
- 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
-
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
.- Parameters:
project
- the project on which to attch the third-party filefile
- the third-party file to attach.
-
resolvThirdPartyDescriptor
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.
- Parameters:
project
- the projectremoteRepositories
- the remote repositories- Returns:
- the locale file resolved into the local repository
- Throws:
ThirdPartyToolException
- if any
-
resolveMissingLicensesDescriptor
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 - Throws:
IOException
org.eclipse.aether.resolution.ArtifactResolutionException
org.eclipse.aether.transfer.ArtifactNotFoundException
-
getProjectsWithNoLicense
From the givenlicenseMap
, obtain all the projects with no license.- Parameters:
licenseMap
- the license map to querydoLog
- a flag to add debug logs- Returns:
- the set of projects with no license
-
loadUnsafeMapping
SortedProperties loadUnsafeMapping(LicenseMap licenseMap, SortedMap<String, org.apache.maven.project.MavenProject> artifactCache, String encoding, File missingFile, String missingFileUrl) throws IOException, org.apache.maven.plugin.MojoExecutionExceptionLoads unsafe mapping and returns it.- 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 fileorg.apache.maven.plugin.MojoExecutionException
-
overrideLicenses
void overrideLicenses(LicenseMap licenseMap, SortedMap<String, org.apache.maven.project.MavenProject> artifactCache, String encoding, String overrideUrl) throws IOExceptionOverride licenses from override file.- 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
-
addLicense
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
.- Parameters:
licenseMap
- the license map where to add the licenseproject
- the projectlicenseNames
- the names of the licenses
-
addLicense
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
.- Parameters:
licenseMap
- the license map where to add the licenseproject
- the projectlicense
- the license to add
-
addLicense
void addLicense(LicenseMap licenseMap, org.apache.maven.project.MavenProject project, List<?> licenses) Add a givenlicenses
to the givenlicenseMap
for the givenproject
.- 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.- Parameters:
licenseMap
- the license map to mergemainLicense
- the main license to keeplicensesToMerge
- all the licenses to merge
-
writeThirdPartyFile
void writeThirdPartyFile(LicenseMap licenseMap, File thirdPartyFile, boolean verbose, String encoding, String template) throws IOException Write the content of the third-party file.- Parameters:
licenseMap
- map of all license to usethirdPartyFile
- location of file to generateverbose
- verbose flagencoding
- encoding used to generate filetemplate
- the location of the freemarker template used to generate the file content- Throws:
IOException
- if any probem while writing file
-
writeBundleThirdPartyFile
void writeBundleThirdPartyFile(File thirdPartyFile, File outputDirectory, String bundleThirdPartyPath) throws IOException Writes the bundled version of the third-party file.- 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
-