Package org.apache.maven.plugins.invoker
Class InstallMojo
java.lang.Object
org.apache.maven.plugin.AbstractMojo
org.apache.maven.plugins.invoker.InstallMojo
- All Implemented Interfaces:
org.apache.maven.plugin.ContextEnabled
,org.apache.maven.plugin.Mojo
@Mojo(name="install",
defaultPhase=PRE_INTEGRATION_TEST,
requiresDependencyResolution=RUNTIME,
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
FieldsModifier and TypeFieldDescriptionprivate org.apache.maven.artifact.factory.ArtifactFactory
The component used to create artifacts.private Collection<String>
The identifiers of already copied artifacts, used to avoid multiple installation of the same artifact.private String[]
Extra dependencies that need to be installed on the local repository.
Format:private Collection<String>
The identifiers of already installed artifacts, used to avoid multiple installation of the same artifact.private org.apache.maven.shared.transfer.artifact.install.ArtifactInstaller
Maven artifact install component to copy artifacts to the local repository.private org.apache.maven.artifact.repository.ArtifactRepository
private File
The path to the local repository into which the project artifacts should be installed for the integration tests.private org.apache.maven.project.MavenProject
The current Maven project.private org.apache.maven.project.ProjectBuildingRequest
private Collection<org.apache.maven.project.MavenProject>
The set of Maven projects in the reactor build.private org.apache.maven.shared.transfer.repository.RepositoryManager
private org.apache.maven.shared.transfer.dependencies.resolve.DependencyResolver
private org.apache.maven.execution.MavenSession
private boolean
A flag used to disable the installation procedure.private boolean
if the local repository is not used as test repo, the parameter can force get artifacts from local repo if available instead of download the artifacts again.Fields inherited from interface org.apache.maven.plugin.Mojo
ROLE
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected void
collectAllProjectReferences
(org.apache.maven.project.MavenProject project, Collection<String> dependencyProjects) private void
copyArtifact
(File file, org.apache.maven.artifact.Artifact artifact) Installs the specified artifact to the local repository.private void
copyArtifact
(org.apache.maven.artifact.Artifact artifact) private void
copyFileIfDifferent
(File src, File dst) private void
copyParentPoms
(File pomFile) Installs all parent POMs of the specified POM file that are available in the local repository.private void
copyParentPoms
(String groupId, String artifactId, String version) Installs the specified POM and all its parent POMs to the local repository.private void
copyPoms
(org.apache.maven.artifact.Artifact artifact) private void
Creates the local repository for the integration tests.void
execute()
Performs this mojo's tasks.private void
installArtifact
(File file, org.apache.maven.artifact.Artifact artifact) Installs the specified artifact to the local repository.private void
installExtraArtifacts
(String[] extraArtifacts) private void
installProjectArtifacts
(org.apache.maven.project.MavenProject mvnProject) Installs the main artifact and any attached artifacts of the specified project to the local repository.private void
installProjectDependencies
(org.apache.maven.project.MavenProject mvnProject, Collection<org.apache.maven.project.MavenProject> reactorProjects) Installs the dependent projects from the reactor to the local repository.private void
installProjectParents
(org.apache.maven.project.MavenProject mvnProject) Installs the (locally reachable) parent POMs of the specified project to the local repository.private void
installProjectPom
(org.apache.maven.project.MavenProject mvnProject) Installs the POM of the specified project to the local repository.private List<org.apache.maven.artifact.Artifact>
toArtifactsList
(Iterable<org.apache.maven.shared.transfer.artifact.resolve.ArtifactResult> artifactResults) Methods inherited from class org.apache.maven.plugin.AbstractMojo
getLog, getPluginContext, setLog, setPluginContext
-
Field Details
-
installer
@Component private org.apache.maven.shared.transfer.artifact.install.ArtifactInstaller installerMaven artifact install component to copy artifacts to the local repository. -
repositoryManager
@Component private org.apache.maven.shared.transfer.repository.RepositoryManager repositoryManager -
artifactFactory
@Component private org.apache.maven.artifact.factory.ArtifactFactory artifactFactoryThe component used to create artifacts. -
localRepository
@Parameter(property="localRepository", required=true, readonly=true) private org.apache.maven.artifact.repository.ArtifactRepository localRepository -
localRepositoryPath
@Parameter(property="invoker.localRepositoryPath", defaultValue="${session.localRepository.basedir}", required=true) private File localRepositoryPathThe 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
). -
project
@Parameter(defaultValue="${project}", readonly=true, required=true) private org.apache.maven.project.MavenProject projectThe current Maven project. -
session
@Parameter(defaultValue="${session}", readonly=true, required=true) private org.apache.maven.execution.MavenSession session -
reactorProjects
@Parameter(defaultValue="${reactorProjects}", readonly=true) private Collection<org.apache.maven.project.MavenProject> reactorProjectsThe set of Maven projects in the reactor build. -
skipInstallation
@Parameter(property="invoker.skip", defaultValue="false") private boolean skipInstallationA 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
-
installedArtifacts
The identifiers of already installed artifacts, used to avoid multiple installation of the same artifact. -
copiedArtifacts
The identifiers of already copied artifacts, used to avoid multiple installation of the same artifact. -
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.- Since:
- 1.6
-
resolver
@Component private org.apache.maven.shared.transfer.dependencies.resolve.DependencyResolver resolver -
useLocalRepository
@Parameter(property="invoker.useLocalRepository", defaultValue="false") private boolean useLocalRepositoryif the local repository is not used as test repo, the parameter can force get artifacts from local repo if available instead of download the artifacts again.- Since:
- 3.2.1
-
projectBuildingRequest
private org.apache.maven.project.ProjectBuildingRequest projectBuildingRequest
-
-
Constructor Details
-
InstallMojo
public InstallMojo()
-
-
Method Details
-
execute
public void execute() throws org.apache.maven.plugin.MojoExecutionExceptionPerforms this mojo's tasks.- Throws:
org.apache.maven.plugin.MojoExecutionException
- If the artifacts could not be installed.
-
createTestRepository
private void createTestRepository() throws org.apache.maven.plugin.MojoExecutionExceptionCreates the local repository for the integration tests. If the user specified a custom repository location, the custom repository will have the same identifier, layout and policies as the real local repository. That means apart from the location, the custom repository will be indistinguishable from the real repository such that its usage is transparent to the integration tests.- Throws:
org.apache.maven.plugin.MojoExecutionException
- If the repository could not be created.
-
installArtifact
private void installArtifact(File file, org.apache.maven.artifact.Artifact artifact) throws org.apache.maven.plugin.MojoExecutionException Installs the specified artifact to the local repository. Note: This method should only be used for artifacts that originate from the current (reactor) build. Artifacts that have been grabbed from the user's local repository should be installed to the test repository viacopyArtifact(File, Artifact)
.- Parameters:
file
- The file associated with the artifact, must not benull
. This is in most cases the value ofartifact.getFile()
with the exception of the main artifact from a project with packaging "pom". Projects with packaging "pom" have no main artifact file. They have however artifact metadata (e.g. site descriptors) which needs to be installed.artifact
- The artifact to install, must not benull
.- Throws:
org.apache.maven.plugin.MojoExecutionException
- If the artifact could not be installed (e.g. has no associated file).
-
copyArtifact
private void copyArtifact(File file, org.apache.maven.artifact.Artifact artifact) throws org.apache.maven.plugin.MojoExecutionException Installs the specified artifact to the local repository. This method serves basically the same purpose asinstallArtifact(File, Artifact)
but is meant for artifacts that have been resolved from the user's local repository (and not the current build outputs). The subtle difference here is that artifacts from the repository have already undergone transformations and these manipulations should not be redone by the artifact installer. For this reason, this method performs plain copy operations to install the artifacts.- Parameters:
file
- The file associated with the artifact, must not benull
.artifact
- The artifact to install, must not benull
.- Throws:
org.apache.maven.plugin.MojoExecutionException
- If the artifact could not be installed (e.g. has no associated file).
-
copyFileIfDifferent
- Throws:
IOException
-
installProjectArtifacts
private void installProjectArtifacts(org.apache.maven.project.MavenProject mvnProject) throws org.apache.maven.plugin.MojoExecutionException Installs the main artifact and any attached artifacts of the specified project to the local repository.- Parameters:
mvnProject
- The project whose artifacts should be installed, must not benull
.- Throws:
org.apache.maven.plugin.MojoExecutionException
- If any artifact could not be installed.
-
installProjectParents
private void installProjectParents(org.apache.maven.project.MavenProject mvnProject) throws org.apache.maven.plugin.MojoExecutionException Installs the (locally reachable) parent POMs of the specified project to the local repository. The parent POMs from the reactor must be installed or the forked IT builds will fail when using a clean repository.- Parameters:
mvnProject
- The project whose parent POMs should be installed, must not benull
.- Throws:
org.apache.maven.plugin.MojoExecutionException
- If any POM could not be installed.
-
installProjectPom
private void installProjectPom(org.apache.maven.project.MavenProject mvnProject) throws org.apache.maven.plugin.MojoExecutionException Installs the POM of the specified project to the local repository.- Parameters:
mvnProject
- The project whose POM should be installed, must not benull
.- Throws:
org.apache.maven.plugin.MojoExecutionException
- If the POM could not be installed.
-
installProjectDependencies
private void installProjectDependencies(org.apache.maven.project.MavenProject mvnProject, Collection<org.apache.maven.project.MavenProject> reactorProjects) throws org.apache.maven.plugin.MojoExecutionException Installs the dependent projects from the reactor to the local repository. The dependencies on other modules from the reactor must be installed or the forked IT builds will fail when using a clean repository.- Parameters:
mvnProject
- The project whose dependent projects should be installed, must not benull
.reactorProjects
- The set of projects in the reactor build, must not benull
.- Throws:
org.apache.maven.plugin.MojoExecutionException
- If any dependency could not be installed.
-
collectAllProjectReferences
protected void collectAllProjectReferences(org.apache.maven.project.MavenProject project, Collection<String> dependencyProjects) -
copyArtifact
private void copyArtifact(org.apache.maven.artifact.Artifact artifact) throws org.apache.maven.plugin.MojoExecutionException - Throws:
org.apache.maven.plugin.MojoExecutionException
-
copyPoms
private void copyPoms(org.apache.maven.artifact.Artifact artifact) throws org.apache.maven.plugin.MojoExecutionException - Throws:
org.apache.maven.plugin.MojoExecutionException
-
copyParentPoms
Installs all parent POMs of the specified POM file that are available in the local repository.- Parameters:
pomFile
- The path to the POM file whose parents should be installed, must not benull
.- Throws:
org.apache.maven.plugin.MojoExecutionException
- If any (existing) parent POM could not be installed.
-
copyParentPoms
private void copyParentPoms(String groupId, String artifactId, String version) throws org.apache.maven.plugin.MojoExecutionException Installs the specified POM and all its parent POMs to the local repository.- Parameters:
groupId
- The group id of the POM which should be installed, must not benull
.artifactId
- The artifact id of the POM which should be installed, must not benull
.version
- The version of the POM which should be installed, must not benull
.- Throws:
org.apache.maven.plugin.MojoExecutionException
- If any (existing) parent POM could not be installed.
-
installExtraArtifacts
private void installExtraArtifacts(String[] extraArtifacts) throws org.apache.maven.plugin.MojoExecutionException - Throws:
org.apache.maven.plugin.MojoExecutionException
-
toArtifactsList
-