Class InstallMojo

  • All Implemented Interfaces:
    org.apache.maven.plugin.ContextEnabled, org.apache.maven.plugin.Mojo

    @Mojo(name="install",
          defaultPhase=PRE_INTEGRATION_TEST,
          requiresDependencyResolution=TEST,
          threadSafe=true)
    public class InstallMojo
    extends org.apache.maven.plugin.AbstractMojo
    Installs the project artifacts of the main build into the local repository as a preparation to run the sub projects. More precisely, all artifacts of the project itself, all its locally reachable parent POMs and all its dependencies from the reactor will be installed to the local repository.
    Since:
    1.2
    • Field Summary

      Fields 
      Modifier and Type Field Description
      private java.lang.String[] extraArtifacts
      Extra dependencies that need to be installed on the local repository.
      private java.io.File localRepositoryPath
      The path to the local repository into which the project artifacts should be installed for the integration tests.
      private org.apache.maven.project.MavenProject project  
      private org.eclipse.aether.RepositorySystem repositorySystem  
      private java.lang.String scope
      Scope to resolve project artifacts.
      private org.apache.maven.execution.MavenSession session  
      private boolean skipInstallation
      A flag used to disable the installation procedure.
      • Fields inherited from interface org.apache.maven.plugin.Mojo

        ROLE
    • Constructor Summary

      Constructors 
      Constructor Description
      InstallMojo()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      private org.eclipse.aether.RepositorySystemSession createSystemSessionForLocalRepo()
      Create a new RepositorySystemSession connected with local repo.
      void execute()
      Performs this mojo's tasks.
      private boolean hasTheSamePathAsTarget​(org.eclipse.aether.artifact.Artifact artifact, org.eclipse.aether.RepositorySystemSession systemSession)  
      private void installArtifacts​(java.util.Map<java.lang.String,​org.eclipse.aether.artifact.Artifact> resolvedArtifacts)
      Install list of artifacts into local repository.
      private org.eclipse.aether.artifact.Artifact resolveArtifact​(org.eclipse.aether.artifact.Artifact artifact, java.util.List<org.eclipse.aether.repository.RemoteRepository> remoteRepositories)  
      private void resolveExtraArtifacts​(java.util.Map<java.lang.String,​org.eclipse.aether.artifact.Artifact> resolvedArtifacts)
      Resolve extra artifacts.
      private void resolvePomsForArtifacts​(java.util.List<org.eclipse.aether.artifact.Artifact> artifacts, java.util.Map<java.lang.String,​org.eclipse.aether.artifact.Artifact> resolvedArtifacts, java.util.List<org.eclipse.aether.repository.RemoteRepository> remoteRepositories)  
      private void resolvePomWithParents​(org.eclipse.aether.artifact.Artifact artifact, java.util.Map<java.lang.String,​org.eclipse.aether.artifact.Artifact> resolvedArtifacts, java.util.List<org.eclipse.aether.repository.RemoteRepository> remoteRepositories)  
      private void resolveProjectArtifacts​(java.util.Map<java.lang.String,​org.eclipse.aether.artifact.Artifact> resolvedArtifacts)  
      private void resolveProjectDependencies​(java.util.Map<java.lang.String,​org.eclipse.aether.artifact.Artifact> resolvedArtifacts)  
      private void resolveProjectPoms​(org.apache.maven.project.MavenProject project, java.util.Map<java.lang.String,​org.eclipse.aether.artifact.Artifact> resolvedArtifacts)  
      • 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 Detail

      • repositorySystem

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

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

        @Parameter(defaultValue="${project}",
                   readonly=true,
                   required=true)
        private org.apache.maven.project.MavenProject project
      • localRepositoryPath

        @Parameter(property="invoker.localRepositoryPath",
                   defaultValue="${session.localRepository.basedir}",
                   required=true)
        private java.io.File localRepositoryPath
        The path to the local repository into which the project artifacts should be installed for the integration tests. If not set, the regular local repository will be used. To prevent soiling of your regular local repository with possibly broken artifacts, it is strongly recommended to use an isolated repository for the integration tests (e.g. ${project.build.directory}/it-repo).
      • skipInstallation

        @Parameter(property="invoker.skip",
                   defaultValue="false")
        private boolean skipInstallation
        A flag used to disable the installation procedure. This is primarily intended for usage from the command line to occasionally adjust the build.
        Since:
        1.4
      • extraArtifacts

        @Parameter
        private java.lang.String[] extraArtifacts
        Extra dependencies that need to be installed on the local repository.

        Format:

         groupId:artifactId:version:type:classifier
         

        Examples:

         org.apache.maven.plugins:maven-clean-plugin:2.4:maven-plugin
         org.apache.maven.plugins:maven-clean-plugin:2.4:jar:javadoc
         

        If the type is 'maven-plugin' the plugin will try to resolve the artifact using plugin remote repositories, instead of using artifact remote repositories.

        NOTICE all dependencies will be resolved with transitive dependencies in runtime scope.

        Since:
        1.6
      • scope

        @Parameter(property="invoker.install.scope",
                   defaultValue="runtime")
        private java.lang.String scope
        Scope to resolve project artifacts.
        Since:
        3.5.0
    • Constructor Detail

      • InstallMojo

        public InstallMojo()
    • Method Detail

      • execute

        public void execute()
                     throws org.apache.maven.plugin.MojoExecutionException
        Performs this mojo's tasks.
        Throws:
        org.apache.maven.plugin.MojoExecutionException - If the artifacts could not be installed.
      • resolveProjectArtifacts

        private void resolveProjectArtifacts​(java.util.Map<java.lang.String,​org.eclipse.aether.artifact.Artifact> resolvedArtifacts)
      • resolveProjectPoms

        private void resolveProjectPoms​(org.apache.maven.project.MavenProject project,
                                        java.util.Map<java.lang.String,​org.eclipse.aether.artifact.Artifact> resolvedArtifacts)
                                 throws org.eclipse.aether.resolution.ArtifactResolutionException
        Throws:
        org.eclipse.aether.resolution.ArtifactResolutionException
      • resolveProjectDependencies

        private void resolveProjectDependencies​(java.util.Map<java.lang.String,​org.eclipse.aether.artifact.Artifact> resolvedArtifacts)
                                         throws org.eclipse.aether.resolution.ArtifactResolutionException,
                                                org.apache.maven.plugin.MojoExecutionException,
                                                org.eclipse.aether.resolution.DependencyResolutionException
        Throws:
        org.eclipse.aether.resolution.ArtifactResolutionException
        org.apache.maven.plugin.MojoExecutionException
        org.eclipse.aether.resolution.DependencyResolutionException
      • resolveExtraArtifacts

        private void resolveExtraArtifacts​(java.util.Map<java.lang.String,​org.eclipse.aether.artifact.Artifact> resolvedArtifacts)
                                    throws org.apache.maven.plugin.MojoExecutionException,
                                           org.eclipse.aether.resolution.DependencyResolutionException,
                                           org.eclipse.aether.resolution.ArtifactResolutionException
        Resolve extra artifacts.
        Throws:
        org.apache.maven.plugin.MojoExecutionException
        org.eclipse.aether.resolution.DependencyResolutionException
        org.eclipse.aether.resolution.ArtifactResolutionException
      • resolvePomsForArtifacts

        private void resolvePomsForArtifacts​(java.util.List<org.eclipse.aether.artifact.Artifact> artifacts,
                                             java.util.Map<java.lang.String,​org.eclipse.aether.artifact.Artifact> resolvedArtifacts,
                                             java.util.List<org.eclipse.aether.repository.RemoteRepository> remoteRepositories)
                                      throws org.eclipse.aether.resolution.ArtifactResolutionException,
                                             org.apache.maven.plugin.MojoExecutionException
        Throws:
        org.eclipse.aether.resolution.ArtifactResolutionException
        org.apache.maven.plugin.MojoExecutionException
      • resolvePomWithParents

        private void resolvePomWithParents​(org.eclipse.aether.artifact.Artifact artifact,
                                           java.util.Map<java.lang.String,​org.eclipse.aether.artifact.Artifact> resolvedArtifacts,
                                           java.util.List<org.eclipse.aether.repository.RemoteRepository> remoteRepositories)
                                    throws org.apache.maven.plugin.MojoExecutionException,
                                           org.eclipse.aether.resolution.ArtifactResolutionException
        Throws:
        org.apache.maven.plugin.MojoExecutionException
        org.eclipse.aether.resolution.ArtifactResolutionException
      • resolveArtifact

        private org.eclipse.aether.artifact.Artifact resolveArtifact​(org.eclipse.aether.artifact.Artifact artifact,
                                                                     java.util.List<org.eclipse.aether.repository.RemoteRepository> remoteRepositories)
                                                              throws org.eclipse.aether.resolution.ArtifactResolutionException
        Throws:
        org.eclipse.aether.resolution.ArtifactResolutionException
      • installArtifacts

        private void installArtifacts​(java.util.Map<java.lang.String,​org.eclipse.aether.artifact.Artifact> resolvedArtifacts)
                               throws org.eclipse.aether.installation.InstallationException
        Install list of artifacts into local repository.
        Throws:
        org.eclipse.aether.installation.InstallationException
      • hasTheSamePathAsTarget

        private boolean hasTheSamePathAsTarget​(org.eclipse.aether.artifact.Artifact artifact,
                                               org.eclipse.aether.RepositorySystemSession systemSession)
      • createSystemSessionForLocalRepo

        private org.eclipse.aether.RepositorySystemSession createSystemSessionForLocalRepo()
        Create a new RepositorySystemSession connected with local repo.