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
  • Field Details

    • ROLE

      static final String ROLE
      Plexus Role.
  • 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 files
      projects - all projects where to read third parties descriptors
      unsafeProjects - 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
    • attachThirdPartyDescriptor

      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.

      Parameters:
      project - the project on which to attch the third-party file
      file - 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 project
      remoteRepositories - 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

      SortedSet<org.apache.maven.project.MavenProject> getProjectsWithNoLicense(LicenseMap licenseMap)
      From the given licenseMap, obtain all the projects with no license.
      Parameters:
      licenseMap - the license map to query
      doLog - 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.MojoExecutionException
      Loads unsafe mapping and returns it.
      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
      org.apache.maven.plugin.MojoExecutionException
    • overrideLicenses

      void overrideLicenses(LicenseMap licenseMap, SortedMap<String,org.apache.maven.project.MavenProject> artifactCache, String encoding, String overrideUrl) throws IOException
      Override licenses from override file.
      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
    • addLicense

      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.
      Parameters:
      licenseMap - the license map where to add the license
      project - the project
      licenseNames - the names of the licenses
    • addLicense

      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.
      Parameters:
      licenseMap - the license map where to add the license
      project - the project
      license - the license to add
    • addLicense

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

      void mergeLicenses(LicenseMap licenseMap, String mainLicense, Set<String> licensesToMerge)
      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.

      Parameters:
      licenseMap - the license map to merge
      mainLicense - the main license to keep
      licensesToMerge - 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 use
      thirdPartyFile - location of file to generate
      verbose - verbose flag
      encoding - encoding used to generate file
      template - 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 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