Class DefaultThirdPartyTool

java.lang.Object
org.codehaus.mojo.license.api.DefaultThirdPartyTool
All Implemented Interfaces:
ThirdPartyTool

@Named @Singleton public class DefaultThirdPartyTool extends Object implements ThirdPartyTool
Default implementation of the third party tool.
Version:
$Id$
Author:
Tony Chemit
  • Field Details

  • Constructor Details

    • DefaultThirdPartyTool

      public DefaultThirdPartyTool()
  • Method Details

    • isVerbose

      public boolean isVerbose()
      Is log should be verbose?
      Specified by:
      isVerbose in interface ThirdPartyTool
      Returns:
      true if verbose log should be produced, false otherwise.
    • setVerbose

      public void setVerbose(boolean verbose)
      Sets the verbose mode.
      Specified by:
      setVerbose in interface ThirdPartyTool
      Parameters:
      verbose - new verbose mode to set
    • attachThirdPartyDescriptor

      public void attachThirdPartyDescriptor(org.apache.maven.project.MavenProject project, File file)
      For the given project, attach the given file as a third-party file.

      The file will be attached as with a classifier third-parties and a type properties.

      Specified by:
      attachThirdPartyDescriptor in interface ThirdPartyTool
      Parameters:
      project - the project on which to attch the third-party file
      file - the third-party file to attach.
    • getProjectsWithNoLicense

      public SortedSet<org.apache.maven.project.MavenProject> getProjectsWithNoLicense(LicenseMap licenseMap)
      From the given licenseMap, obtain all the projects with no license.
      Specified by:
      getProjectsWithNoLicense in interface ThirdPartyTool
      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 interface ThirdPartyTool
      Parameters:
      topLevelDependencies - top-level dependencies to scan for .license.properties files.
      encoding - encoding used to read or write properties files
      projects - all projects where to read third parties descriptors
      unsafeDependencies - all unsafe projects
      licenseMap - license map where to store new licenses
      remoteRepositories - remote repositories
      Returns:
      the map of loaded missing from the remote missing third party files
      Throws:
      ThirdPartyToolException - if any
      IOException - 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 interface ThirdPartyTool
      Parameters:
      project - the project
      remoteRepositories - 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 are licenseNames) to the given licenseMap for the given project.
      Specified by:
      addLicense in interface ThirdPartyTool
      Parameters:
      licenseMap - the license map where to add the license
      project - the project
      licenseNames - 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 given license to the given licenseMap for the given project.
      Specified by:
      addLicense in interface ThirdPartyTool
      Parameters:
      licenseMap - the license map where to add the license
      project - the project
      license - the license to add
    • addLicense

      public void addLicense(LicenseMap licenseMap, org.apache.maven.project.MavenProject project, List<?> licenses)
      Add a given licenses to the given licenseMap for the given project.
      Specified by:
      addLicense in interface ThirdPartyTool
      Parameters:
      licenseMap - the license map where to add the licenses
      project - the project
      licenses - the licenses to add
    • mergeLicenses

      public void mergeLicenses(LicenseMap licenseMap, String mainLicense, Set<String> licenses)
      For a given licenseMap, merge all licenses.

      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 interface ThirdPartyTool
      Parameters:
      licenseMap - the license map to merge
      mainLicense - the main license to keep
      licenses - 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 IOException
      Loads unsafe mapping and returns it.
      Specified by:
      loadUnsafeMapping in interface ThirdPartyTool
      Parameters:
      licenseMap - license map
      artifactCache - cache of dependencies (used for id migration from missing file)
      encoding - encoding used to load missing file
      missingFile - location of the optional missing file
      missingFileUrl - 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 IOException
      Override licenses from override file.
      Specified by:
      overrideLicenses in interface ThirdPartyTool
      Parameters:
      licenseMap - license map
      artifactCache - cache of dependencies (used for id migration from missing file)
      encoding - encoding used to load override file
      overrideUrl - 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 interface ThirdPartyTool
      Parameters:
      licenseMap - map of all license to use
      thirdPartyFile - location of file to generate
      verbose - verbose flag
      encoding - encoding used to generate file
      lineFormat - 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 interface ThirdPartyTool
      Parameters:
      thirdPartyFile - location of normal third-party file
      outputDirectory - where to generate bundled version of the third-party file
      bundleThirdPartyPath - 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 interface ThirdPartyTool
      Throws:
      IOException
      org.eclipse.aether.resolution.ArtifactResolutionException
      org.eclipse.aether.transfer.ArtifactNotFoundException