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.AbstractMojoInstalls 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 org.apache.maven.artifact.factory.ArtifactFactoryartifactFactoryThe component used to create artifacts.private java.util.Collection<java.lang.String>copiedArtifactsThe identifiers of already copied artifacts, used to avoid multiple installation of the same artifact.private java.lang.String[]extraArtifactsExtra dependencies that need to be installed on the local repository.
Format:private java.util.Collection<java.lang.String>installedArtifactsThe identifiers of already installed artifacts, used to avoid multiple installation of the same artifact.private org.apache.maven.shared.transfer.artifact.install.ArtifactInstallerinstallerMaven artifact install component to copy artifacts to the local repository.private org.apache.maven.artifact.repository.ArtifactRepositorylocalRepositoryprivate java.io.FilelocalRepositoryPathThe path to the local repository into which the project artifacts should be installed for the integration tests.private org.apache.maven.project.MavenProjectprojectThe current Maven project.private org.apache.maven.project.ProjectBuildingRequestprojectBuildingRequestprivate java.util.Collection<org.apache.maven.project.MavenProject>reactorProjectsThe set of Maven projects in the reactor build.private org.apache.maven.shared.transfer.repository.RepositoryManagerrepositoryManagerprivate org.apache.maven.shared.transfer.dependencies.resolve.DependencyResolverresolverprivate org.apache.maven.execution.MavenSessionsessionprivate booleanskipInstallationA flag used to disable the installation procedure.private booleanuseLocalRepositoryif 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.
-
Constructor Summary
Constructors Constructor Description InstallMojo()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidcollectAllProjectReferences(org.apache.maven.project.MavenProject project, java.util.Collection<java.lang.String> dependencyProjects)private voidcopyArtifact(java.io.File file, org.apache.maven.artifact.Artifact artifact)Installs the specified artifact to the local repository.private voidcopyArtifact(org.apache.maven.artifact.Artifact artifact)private voidcopyFileIfDifferent(java.io.File src, java.io.File dst)private voidcopyParentPoms(java.io.File pomFile)Installs all parent POMs of the specified POM file that are available in the local repository.private voidcopyParentPoms(java.lang.String groupId, java.lang.String artifactId, java.lang.String version)Installs the specified POM and all its parent POMs to the local repository.private voidcopyPoms(org.apache.maven.artifact.Artifact artifact)private voidcreateTestRepository()Creates the local repository for the integration tests.voidexecute()Performs this mojo's tasks.private voidinstallArtifact(java.io.File file, org.apache.maven.artifact.Artifact artifact)Installs the specified artifact to the local repository.private voidinstallExtraArtifacts(java.lang.String[] extraArtifacts)private voidinstallProjectArtifacts(org.apache.maven.project.MavenProject mvnProject)Installs the main artifact and any attached artifacts of the specified project to the local repository.private voidinstallProjectDependencies(org.apache.maven.project.MavenProject mvnProject, java.util.Collection<org.apache.maven.project.MavenProject> reactorProjects)Installs the dependent projects from the reactor to the local repository.private voidinstallProjectParents(org.apache.maven.project.MavenProject mvnProject)Installs the (locally reachable) parent POMs of the specified project to the local repository.private voidinstallProjectPom(org.apache.maven.project.MavenProject mvnProject)Installs the POM of the specified project to the local repository.private java.util.List<org.apache.maven.artifact.Artifact>toArtifactsList(java.lang.Iterable<org.apache.maven.shared.transfer.artifact.resolve.ArtifactResult> artifactResults)
-
-
-
Field Detail
-
installer
@Component private org.apache.maven.shared.transfer.artifact.install.ArtifactInstaller installer
Maven 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 artifactFactory
The 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 java.io.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 java.util.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
private java.util.Collection<java.lang.String> installedArtifacts
The identifiers of already installed artifacts, used to avoid multiple installation of the same artifact.
-
copiedArtifacts
private java.util.Collection<java.lang.String> copiedArtifacts
The identifiers of already copied artifacts, used to avoid multiple installation of the same artifact.
-
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.- 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
-
-
Method Detail
-
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(java.io.File file, org.apache.maven.artifact.Artifact artifact) throws org.apache.maven.plugin.MojoExecutionExceptionInstalls 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(java.io.File file, org.apache.maven.artifact.Artifact artifact) throws org.apache.maven.plugin.MojoExecutionExceptionInstalls 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
private void copyFileIfDifferent(java.io.File src, java.io.File dst) throws java.io.IOException- Throws:
java.io.IOException
-
installProjectArtifacts
private void installProjectArtifacts(org.apache.maven.project.MavenProject mvnProject) throws org.apache.maven.plugin.MojoExecutionExceptionInstalls 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.MojoExecutionExceptionInstalls 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.MojoExecutionExceptionInstalls 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, java.util.Collection<org.apache.maven.project.MavenProject> reactorProjects) throws org.apache.maven.plugin.MojoExecutionExceptionInstalls 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, java.util.Collection<java.lang.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
private void copyParentPoms(java.io.File pomFile) throws org.apache.maven.plugin.MojoExecutionExceptionInstalls 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(java.lang.String groupId, java.lang.String artifactId, java.lang.String version) throws org.apache.maven.plugin.MojoExecutionExceptionInstalls 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(java.lang.String[] extraArtifacts) throws org.apache.maven.plugin.MojoExecutionException- Throws:
org.apache.maven.plugin.MojoExecutionException
-
toArtifactsList
private java.util.List<org.apache.maven.artifact.Artifact> toArtifactsList(java.lang.Iterable<org.apache.maven.shared.transfer.artifact.resolve.ArtifactResult> artifactResults)
-
-