Class InstallFileMojo

java.lang.Object
org.apache.maven.plugin.AbstractMojo
org.apache.maven.plugins.install.InstallFileMojo
All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo

@Mojo(name="install-file", requiresProject=false, aggregator=true, threadSafe=true) public class InstallFileMojo extends org.apache.maven.plugin.AbstractMojo
Installs a file in the local repository.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private String
    ArtifactId of the artifact to be installed.
    private String
    Classifier type of the artifact to be installed.
    private File
    The file to be installed in the local repository.
    private Boolean
    Generate a minimal POM for the artifact if none is supplied via the parameter pomFile.
    private String
    GroupId of the artifact to be installed.
    private static final String
     
    private File
    The bundled API docs for the artifact.
    private File
    The path for a specific local repository directory.
    private static final String
     
    private String
    Packaging type of the artifact to be installed.
    private File
    Location of an existing POM file to be installed alongside the main artifact, given by the file parameter.
    private org.eclipse.aether.RepositorySystem
     
    private org.apache.maven.execution.MavenSession
     
    private File
    The bundled sources for the artifact.
    private String
    Version of the artifact to be installed.

    Fields inherited from interface org.apache.maven.plugin.Mojo

    ROLE
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
    private org.apache.maven.model.Model
    Generates a minimal model from the user-supplied artifact information.
    private File
    Generates a (temporary) POM file from the plugin configuration.
    private String
    Specialization of FileUtils.getExtension(String) that honors various tar.xxx combinations.
    private File
    getLocalRepositoryFile(org.eclipse.aether.RepositorySystemSession session, org.eclipse.aether.artifact.Artifact artifact)
    Gets the path of the specified artifact within the local repository.
    private File
    getPomLocalRepositoryFile(org.eclipse.aether.RepositorySystemSession session, org.eclipse.aether.artifact.Artifact artifact)
    Gets the path of the specified artifact POM within the local repository.
    private boolean
    Returns true if passed in string is "valid Maven ID" (groupId or artifactId).
    private boolean
    Returns true if passed in string is "valid Maven (simple.
    private void
    processModel(org.apache.maven.model.Model model)
    Populates missing mojo parameters from the specified POM.
    private File
     
    private org.apache.maven.model.Model
    readModel(File pomFile)
    Parses a POM.

    Methods inherited from class org.apache.maven.plugin.AbstractMojo

    getLog, getPluginContext, setLog, setPluginContext

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • LS

      private static final String LS
    • repositorySystem

      @Component private org.eclipse.aether.RepositorySystem repositorySystem
    • session

      @Parameter(defaultValue="${session}", required=true, readonly=true) private org.apache.maven.execution.MavenSession session
    • groupId

      @Parameter(property="groupId") private String groupId
      GroupId of the artifact to be installed. Retrieved from POM file if one is specified or extracted from pom.xml in jar if available.
    • artifactId

      @Parameter(property="artifactId") private String artifactId
      ArtifactId of the artifact to be installed. Retrieved from POM file if one is specified or extracted from pom.xml in jar if available.
    • version

      @Parameter(property="version") private String version
      Version of the artifact to be installed. Retrieved from POM file if one is specified or extracted from pom.xml in jar if available.
    • packaging

      @Parameter(property="packaging") private String packaging
      Packaging type of the artifact to be installed. Retrieved from POM file if one is specified or extracted from pom.xml in jar if available.
    • classifier

      @Parameter(property="classifier") private String classifier
      Classifier type of the artifact to be installed. For example, "sources" or "javadoc". Defaults to none which means this is the project's main artifact.
      Since:
      2.2
    • file

      @Parameter(property="file", required=true) private File file
      The file to be installed in the local repository.
    • javadoc

      @Parameter(property="javadoc") private File javadoc
      The bundled API docs for the artifact.
      Since:
      2.3
    • sources

      @Parameter(property="sources") private File sources
      The bundled sources for the artifact.
      Since:
      2.3
    • pomFile

      @Parameter(property="pomFile") private File pomFile
      Location of an existing POM file to be installed alongside the main artifact, given by the file parameter.
      Since:
      2.1
    • generatePom

      @Parameter(property="generatePom") private Boolean generatePom
      Generate a minimal POM for the artifact if none is supplied via the parameter pomFile. Defaults to true if there is no existing POM in the local repository yet.
      Since:
      2.1
    • localRepositoryPath

      @Parameter(property="localRepositoryPath") private File localRepositoryPath
      The path for a specific local repository directory. If not specified the local repository path configured in the Maven settings will be used.
      Since:
      2.2
    • ILLEGAL_VERSION_CHARS

      private static final String ILLEGAL_VERSION_CHARS
      See Also:
  • Constructor Details

    • InstallFileMojo

      public InstallFileMojo()
  • Method Details

    • execute

      public void execute() throws org.apache.maven.plugin.MojoExecutionException, org.apache.maven.plugin.MojoFailureException
      Throws:
      org.apache.maven.plugin.MojoExecutionException
      org.apache.maven.plugin.MojoFailureException
    • readingPomFromJarFile

      private File readingPomFromJarFile() throws org.apache.maven.plugin.MojoExecutionException
      Throws:
      org.apache.maven.plugin.MojoExecutionException
    • readModel

      private org.apache.maven.model.Model readModel(File pomFile) throws org.apache.maven.plugin.MojoExecutionException
      Parses a POM.
      Parameters:
      pomFile - The path of the POM file to parse, must not be null.
      Returns:
      The model from the POM file, never null.
      Throws:
      org.apache.maven.plugin.MojoExecutionException - If the POM could not be parsed.
    • processModel

      private void processModel(org.apache.maven.model.Model model)
      Populates missing mojo parameters from the specified POM.
      Parameters:
      model - The POM to extract missing artifact coordinates from, must not be null.
    • generateModel

      private org.apache.maven.model.Model generateModel()
      Generates a minimal model from the user-supplied artifact information.
      Returns:
      The generated model, never null.
    • generatePomFile

      private File generatePomFile() throws org.apache.maven.plugin.MojoExecutionException
      Generates a (temporary) POM file from the plugin configuration. It's the responsibility of the caller to delete the generated file when no longer needed.
      Returns:
      The path to the generated POM file, never null.
      Throws:
      org.apache.maven.plugin.MojoExecutionException - If the POM file could not be generated.
    • getLocalRepositoryFile

      private File getLocalRepositoryFile(org.eclipse.aether.RepositorySystemSession session, org.eclipse.aether.artifact.Artifact artifact)
      Gets the path of the specified artifact within the local repository. Note that the returned path need not exist (yet).
    • getPomLocalRepositoryFile

      private File getPomLocalRepositoryFile(org.eclipse.aether.RepositorySystemSession session, org.eclipse.aether.artifact.Artifact artifact)
      Gets the path of the specified artifact POM within the local repository. Note that the returned path need not exist (yet).
    • getExtension

      private String getExtension(File file)
      Specialization of FileUtils.getExtension(String) that honors various tar.xxx combinations.
    • isValidId

      private boolean isValidId(String id)
      Returns true if passed in string is "valid Maven ID" (groupId or artifactId).
    • isValidVersion

      private boolean isValidVersion(String version)
      Returns true if passed in string is "valid Maven (simple. non range, expression, etc) version".