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 TypeMethodDescriptionvoidaddLicense(LicenseMap licenseMap, org.apache.maven.project.MavenProject project, String... licenseNames) Add one or more licenses (name and url arelicenseNames) to the givenlicenseMapfor the givenproject.voidaddLicense(LicenseMap licenseMap, org.apache.maven.project.MavenProject project, List<?> licenses) Add a givenlicensesto the givenlicenseMapfor the givenproject.voidaddLicense(LicenseMap licenseMap, org.apache.maven.project.MavenProject project, org.apache.maven.model.License license) Add a givenlicenseto the givenlicenseMapfor the givenproject.voidattachThirdPartyDescriptor(org.apache.maven.project.MavenProject project, File file) For the givenproject, attach the givenfileas a third-party file.SortedSet<org.apache.maven.project.MavenProject> getProjectsWithNoLicense(LicenseMap licenseMap) From the givenlicenseMap, obtain all the projects with no license.booleanIs 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.voidmergeLicenses(LicenseMap licenseMap, String mainLicense, Set<String> licenses) For a givenlicenseMap, merge alllicenses.voidoverrideLicenses(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.voidsetVerbose(boolean verbose) Sets the verbose mode.voidwriteBundleThirdPartyFile(File thirdPartyFile, File outputDirectory, String bundleThirdPartyPath) Writes the bundled version of the third-party file.voidwriteThirdPartyFile(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:
isVerbosein interfaceThirdPartyTool- Returns:
trueif verbose log should be produced,falseotherwise.
-
setVerbose
public void setVerbose(boolean verbose) Sets the verbose mode.- Specified by:
setVerbosein interfaceThirdPartyTool- Parameters:
verbose- new verbose mode to set
-
attachThirdPartyDescriptor
For the givenproject, attach the givenfileas a third-party file.The file will be attached as with a classifier
third-partiesand a typeproperties.- Specified by:
attachThirdPartyDescriptorin 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:
getProjectsWithNoLicensein 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:
loadThirdPartyDescriptorsForUnsafeMappingin 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:
resolvThirdPartyDescriptorin 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 givenlicenseMapfor the givenproject.- Specified by:
addLicensein 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 givenlicenseto the givenlicenseMapfor the givenproject.- Specified by:
addLicensein 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 givenlicensesto the givenlicenseMapfor the givenproject.- Specified by:
addLicensein 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
licensesis the license to keep and all other values will be merged into the first one.- Specified by:
mergeLicensesin 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:
loadUnsafeMappingin 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:
overrideLicensesin 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:
writeThirdPartyFilein 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:
writeBundleThirdPartyFilein 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:
resolveMissingLicensesDescriptorin interfaceThirdPartyTool- Throws:
IOExceptionorg.eclipse.aether.resolution.ArtifactResolutionExceptionorg.eclipse.aether.transfer.ArtifactNotFoundException
-