Class AbstractFromConfigurationMojo

java.lang.Object
org.apache.maven.plugin.AbstractMojo
org.apache.maven.plugins.dependency.AbstractDependencyMojo
org.apache.maven.plugins.dependency.fromConfiguration.AbstractFromConfigurationMojo
All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo
Direct Known Subclasses:
CopyMojo, UnpackMojo

public abstract class AbstractFromConfigurationMojo extends AbstractDependencyMojo
Abstract parent class used by mojos that get Artifact information from the plugin configuration as an ArrayList of ArtifactItems
See Also:
  • Field Details

    • outputDirectory

      @Parameter(property="outputDirectory", defaultValue="${project.build.directory}/dependency") private File outputDirectory
      Default output location used for mojo, unless overridden in ArtifactItem.
      Since:
      1.0
    • overWriteReleases

      @Parameter(property="mdep.overWriteReleases", defaultValue="false") private boolean overWriteReleases
      Overwrite release artifacts
      Since:
      1.0
    • overWriteSnapshots

      @Parameter(property="mdep.overWriteSnapshots", defaultValue="false") private boolean overWriteSnapshots
      Overwrite snapshot artifacts
      Since:
      1.0
    • overWriteIfNewer

      @Parameter(property="mdep.overIfNewer", defaultValue="true") private boolean overWriteIfNewer
      Overwrite if newer
      Since:
      2.0
    • artifactItems

      @Parameter private List<ArtifactItem> artifactItems
      Collection of ArtifactItems to work on. (ArtifactItem contains groupId, artifactId, version, type, classifier, outputDirectory, destFileName, overWrite and encoding.) See Usage for details.
      Since:
      1.0
    • localRepositoryDirectory

      @Parameter private File localRepositoryDirectory
      Path to override default local repository during plugin's execution. To remove all downloaded artifacts as part of the build, set this value to a location under your project's target directory
      Since:
      2.2
    • artifactResolver

      @Component private org.apache.maven.shared.transfer.artifact.resolve.ArtifactResolver artifactResolver
    • repositoryManager

      @Component private org.apache.maven.shared.transfer.repository.RepositoryManager repositoryManager
    • artifactHandlerManager

      @Component private org.apache.maven.artifact.handler.manager.ArtifactHandlerManager artifactHandlerManager
  • Constructor Details

    • AbstractFromConfigurationMojo

      public AbstractFromConfigurationMojo()
  • Method Details

    • getMarkedArtifactFilter

      abstract ArtifactItemFilter getMarkedArtifactFilter(ArtifactItem item)
    • verifyRequirements

      protected void verifyRequirements() throws org.apache.maven.plugin.MojoFailureException
      artifactItems is filled by either field injection or by setArtifact().
      Throws:
      org.apache.maven.plugin.MojoFailureException - in case of an error.
    • getProcessedArtifactItems

      protected List<ArtifactItem> getProcessedArtifactItems(ProcessArtifactItemsRequest processArtifactItemsRequest) throws org.apache.maven.plugin.MojoExecutionException
      Preprocesses the list of ArtifactItems. This method defaults the outputDirectory if not set and creates the output Directory if it doesn't exist.
      Parameters:
      processArtifactItemsRequest - preprocessing instructions
      Returns:
      An ArrayList of preprocessed ArtifactItems
      Throws:
      org.apache.maven.plugin.MojoExecutionException - with a message if an error occurs.
      See Also:
    • checkIfProcessingNeeded

      private boolean checkIfProcessingNeeded(ArtifactItem item) throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.shared.artifact.filter.collection.ArtifactFilterException
      Throws:
      org.apache.maven.plugin.MojoExecutionException
      org.apache.maven.shared.artifact.filter.collection.ArtifactFilterException
    • getArtifact

      protected org.apache.maven.artifact.Artifact getArtifact(ArtifactItem artifactItem) throws org.apache.maven.plugin.MojoExecutionException
      Resolves the Artifact from the remote repository if necessary. If no version is specified, it will be retrieved from the dependency list or from the DependencyManagement section of the pom.
      Parameters:
      artifactItem - containing information about artifact from plugin configuration.
      Returns:
      Artifact object representing the specified file.
      Throws:
      org.apache.maven.plugin.MojoExecutionException - with a message if the version can't be found in DependencyManagement.
    • fillMissingArtifactVersion

      private void fillMissingArtifactVersion(ArtifactItem artifact) throws org.apache.maven.plugin.MojoExecutionException
      Tries to find missing version from dependency list and dependency management. If found, the artifact is updated with the correct version. It will first look for an exact match on artifactId/groupId/classifier/type and if it doesn't find a match, it will try again looking for artifactId and groupId only.
      Parameters:
      artifact - representing configured file.
      Throws:
      org.apache.maven.plugin.MojoExecutionException
    • findDependencyVersion

      private boolean findDependencyVersion(ArtifactItem artifact, List<org.apache.maven.model.Dependency> dependencies, boolean looseMatch)
      Tries to find missing version from a list of dependencies. If found, the artifact is updated with the correct version.
      Parameters:
      artifact - representing configured file.
      dependencies - list of dependencies to search.
      looseMatch - only look at artifactId and groupId
      Returns:
      the found dependency
    • getArtifactItems

      public List<ArtifactItem> getArtifactItems()
      Returns:
      Returns the artifactItems.
    • setArtifactItems

      public void setArtifactItems(List<ArtifactItem> theArtifactItems)
      Parameters:
      theArtifactItems - The artifactItems to set.
    • getOutputDirectory

      public File getOutputDirectory()
      Returns:
      Returns the outputDirectory.
    • setOutputDirectory

      public void setOutputDirectory(File theOutputDirectory)
      Parameters:
      theOutputDirectory - The outputDirectory to set.
    • isOverWriteIfNewer

      public boolean isOverWriteIfNewer()
      Returns:
      Returns the overWriteIfNewer.
    • setOverWriteIfNewer

      public void setOverWriteIfNewer(boolean theOverWriteIfNewer)
      Parameters:
      theOverWriteIfNewer - The overWriteIfNewer to set.
    • isOverWriteReleases

      public boolean isOverWriteReleases()
      Returns:
      Returns the overWriteReleases.
    • setOverWriteReleases

      public void setOverWriteReleases(boolean theOverWriteReleases)
      Parameters:
      theOverWriteReleases - The overWriteReleases to set.
    • isOverWriteSnapshots

      public boolean isOverWriteSnapshots()
      Returns:
      Returns the overWriteSnapshots.
    • setOverWriteSnapshots

      public void setOverWriteSnapshots(boolean theOverWriteSnapshots)
      Parameters:
      theOverWriteSnapshots - The overWriteSnapshots to set.
    • setLocalRepositoryDirectory

      public void setLocalRepositoryDirectory(File localRepositoryDirectory)
      Parameters:
      localRepositoryDirectory - localRepositoryDirectory
    • setArtifact

      public void setArtifact(String artifact) throws org.apache.maven.plugin.MojoFailureException
      Parameters:
      artifact - The artifact.
      Throws:
      org.apache.maven.plugin.MojoFailureException - in case of an error.