Class 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 AbstractInstallMojo
    Installs a file in the local repository.
    Version:
    $Id: InstallFileMojo.java 1617120 2014-08-10 15:15:48Z khmarbaise $
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected java.lang.String artifactId
      ArtifactId of the artifact to be installed.
      protected java.lang.String classifier
      Classifier type of the artifact to be installed.
      private java.io.File file
      The file to be installed in the local repository.
      private java.lang.Boolean generatePom
      Generate a minimal POM for the artifact if none is supplied via the parameter pomFile.
      protected java.lang.String groupId
      GroupId of the artifact to be installed.
      private java.io.File javadoc
      The bundled API docs for the artifact.
      private java.io.File localRepositoryPath
      The path for a specific local repository directory.
      private org.apache.maven.project.validation.ModelValidator modelValidator
      The component used to validate the user-supplied artifact coordinates.
      protected java.lang.String packaging
      Packaging type of the artifact to be installed.
      private java.io.File pomFile
      Location of an existing POM file to be installed alongside the main artifact, given by the file parameter.
      private java.lang.String repositoryLayout
      The type of remote repository layout to install to.
      private java.util.Map<java.lang.String,​org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout> repositoryLayouts
      Map that contains the repository layouts.
      private java.io.File sources
      The bundled sources for the artifact.
      protected java.lang.String version
      Version of the artifact to be installed.
      • Fields inherited from interface org.apache.maven.plugin.Mojo

        ROLE
    • Constructor Summary

      Constructors 
      Constructor Description
      InstallFileMojo()  
    • Field Detail

      • groupId

        @Parameter(property="groupId")
        protected java.lang.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")
        protected java.lang.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")
        protected java.lang.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")
        protected java.lang.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")
        protected java.lang.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 java.io.File file
        The file to be installed in the local repository.
      • javadoc

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

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

        @Parameter(property="pomFile")
        private java.io.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 java.lang.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
      • repositoryLayout

        @Parameter(property="repositoryLayout",
                   defaultValue="default",
                   required=true)
        private java.lang.String repositoryLayout
        The type of remote repository layout to install to. Try legacy for a Maven 1.x-style repository layout.
        Since:
        2.2
      • repositoryLayouts

        @Component(role=org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout.class)
        private java.util.Map<java.lang.String,​org.apache.maven.artifact.repository.layout.ArtifactRepositoryLayout> repositoryLayouts
        Map that contains the repository layouts.
      • localRepositoryPath

        @Parameter(property="localRepositoryPath")
        private java.io.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
      • modelValidator

        @Component
        private org.apache.maven.project.validation.ModelValidator modelValidator
        The component used to validate the user-supplied artifact coordinates.
    • Constructor Detail

      • InstallFileMojo

        public InstallFileMojo()
    • Method Detail

      • 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
        See Also:
        Mojo.execute()
      • readModel

        private org.apache.maven.model.Model readModel​(java.io.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.
      • readModel

        private org.apache.maven.model.Model readModel​(java.io.InputStream 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.
      • validateArtifactInformation

        private void validateArtifactInformation()
                                          throws org.apache.maven.plugin.MojoExecutionException
        Validates the user-supplied artifact information.
        Throws:
        org.apache.maven.plugin.MojoExecutionException - If any artifact coordinate is invalid.
      • 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 java.io.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.
      • getLocalRepositoryPath

        public java.io.File getLocalRepositoryPath()
        Returns:
        the localRepositoryPath
      • setLocalRepositoryPath

        public void setLocalRepositoryPath​(java.io.File theLocalRepositoryPath)
        Parameters:
        theLocalRepositoryPath - the localRepositoryPath to set