@Mojo(name="install",
defaultPhase=PRE_INTEGRATION_TEST,
requiresDependencyResolution=RUNTIME,
threadSafe=true)
public class InstallMojo
extends org.apache.maven.plugin.AbstractMojo
Modifier and Type | Field and Description |
---|---|
private org.apache.maven.artifact.factory.ArtifactFactory |
artifactFactory
The component used to create artifacts.
|
private org.apache.maven.artifact.metadata.ArtifactMetadataSource |
artifactMetadataSource |
private java.util.Collection<java.lang.String> |
copiedArtifacts
The identifiers of already copied artifacts, used to avoid multiple installation of the same artifact.
|
private java.lang.String[] |
extraArtifacts
Extra dependencies that need to be installed on the local repository.
Format: |
private java.util.Collection<java.lang.String> |
installedArtifacts
The identifiers of already installed artifacts, used to avoid multiple installation of the same artifact.
|
private org.apache.maven.artifact.installer.ArtifactInstaller |
installer
Maven artifact install component to copy artifacts to the local repository.
|
private org.apache.maven.artifact.repository.ArtifactRepository |
localRepository |
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
The current Maven project.
|
private java.util.Collection<org.apache.maven.project.MavenProject> |
reactorProjects
The set of Maven projects in the reactor build.
|
private java.util.List<org.apache.maven.artifact.repository.ArtifactRepository> |
remoteArtifactRepositories |
private java.util.List<org.apache.maven.artifact.repository.ArtifactRepository> |
remotePluginRepositories |
private org.apache.maven.artifact.repository.ArtifactRepositoryFactory |
repositoryFactory
The component used to create artifacts.
|
private org.apache.maven.artifact.resolver.ArtifactResolver |
resolver |
private boolean |
skipInstallation
A flag used to disable the installation procedure.
|
Constructor and Description |
---|
InstallMojo() |
Modifier and Type | Method and Description |
---|---|
private void |
copyArtifact(org.apache.maven.artifact.Artifact artifact,
org.apache.maven.artifact.repository.ArtifactRepository testRepository) |
private void |
copyArtifact(java.io.File file,
org.apache.maven.artifact.Artifact artifact,
org.apache.maven.artifact.repository.ArtifactRepository testRepository)
Installs the specified artifact to the local repository.
|
private void |
copyFileIfDifferent(java.io.File src,
java.io.File dst) |
private void |
copyParentPoms(java.io.File pomFile,
org.apache.maven.artifact.repository.ArtifactRepository testRepository)
Installs all parent POMs of the specified POM file that are available in the local repository.
|
private void |
copyParentPoms(java.lang.String groupId,
java.lang.String artifactId,
java.lang.String version,
org.apache.maven.artifact.repository.ArtifactRepository testRepository)
Installs the specified POM and all its parent POMs to the local repository.
|
private void |
copyPoms(org.apache.maven.artifact.Artifact artifact,
org.apache.maven.artifact.repository.ArtifactRepository testRepository) |
private org.apache.maven.artifact.repository.ArtifactRepository |
createTestRepository()
Creates the local repository for the integration tests.
|
void |
execute()
Performs this mojo's tasks.
|
private void |
installArtifact(java.io.File file,
org.apache.maven.artifact.Artifact artifact,
org.apache.maven.artifact.repository.ArtifactRepository testRepository)
Installs the specified artifact to the local repository.
|
private void |
installExtraArtifacts(org.apache.maven.artifact.repository.ArtifactRepository testRepository,
java.lang.String[] extraArtifacts) |
private void |
installProjectArtifacts(org.apache.maven.project.MavenProject mvnProject,
org.apache.maven.artifact.repository.ArtifactRepository testRepository)
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,
java.util.Collection<org.apache.maven.project.MavenProject> reactorProjects,
org.apache.maven.artifact.repository.ArtifactRepository testRepository)
Installs the dependent projects from the reactor to the local repository.
|
private void |
installProjectParents(org.apache.maven.project.MavenProject mvnProject,
org.apache.maven.artifact.repository.ArtifactRepository testRepository)
Installs the (locally reachable) parent POMs of the specified project to the local repository.
|
private void |
installProjectPom(org.apache.maven.project.MavenProject mvnProject,
org.apache.maven.artifact.repository.ArtifactRepository testRepository)
Installs the POM of the specified project to the local repository.
|
@Component private org.apache.maven.artifact.installer.ArtifactInstaller installer
@Component private org.apache.maven.artifact.factory.ArtifactFactory artifactFactory
@Component private org.apache.maven.artifact.repository.ArtifactRepositoryFactory repositoryFactory
@Parameter(property="localRepository", required=true, readonly=true) private org.apache.maven.artifact.repository.ArtifactRepository localRepository
@Parameter(property="invoker.localRepositoryPath") private java.io.File localRepositoryPath
${project.build.directory}/it-repo
).@Parameter(defaultValue="${project}", readonly=true, required=true) private org.apache.maven.project.MavenProject project
@Parameter(defaultValue="${reactorProjects}", readonly=true) private java.util.Collection<org.apache.maven.project.MavenProject> reactorProjects
@Parameter(property="invoker.skip", defaultValue="false") private boolean skipInstallation
private java.util.Collection<java.lang.String> installedArtifacts
private java.util.Collection<java.lang.String> copiedArtifacts
@Parameter private java.lang.String[] extraArtifacts
groupId:artifactId:version:type:classifierExamples:
org.apache.maven.plugins:maven-clean-plugin:2.4:maven-plugin org.apache.maven.plugins:maven-clean-plugin:2.4:jar:javadocIf the type is 'maven-plugin' the plugin will try to resolve the artifact using plugin remote repositories, instead of using artifact remote repositories.
@Component private org.apache.maven.artifact.resolver.ArtifactResolver resolver
@Parameter(defaultValue="${project.remoteArtifactRepositories}", readonly=true) private java.util.List<org.apache.maven.artifact.repository.ArtifactRepository> remoteArtifactRepositories
@Parameter(defaultValue="${project.pluginArtifactRepositories}", readonly=true) private java.util.List<org.apache.maven.artifact.repository.ArtifactRepository> remotePluginRepositories
@Component private org.apache.maven.artifact.metadata.ArtifactMetadataSource artifactMetadataSource
public void execute() throws org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoExecutionException
- If the artifacts could not be installed.private org.apache.maven.artifact.repository.ArtifactRepository createTestRepository() throws org.apache.maven.plugin.MojoExecutionException
null
.org.apache.maven.plugin.MojoExecutionException
- If the repository could not be created.private void installArtifact(java.io.File file, org.apache.maven.artifact.Artifact artifact, org.apache.maven.artifact.repository.ArtifactRepository testRepository) throws org.apache.maven.plugin.MojoExecutionException
copyArtifact(File, Artifact, ArtifactRepository)
.file
- The file associated with the artifact, must not be null
. This is in most cases the value
of artifact.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 be null
.testRepository
- The local repository to install the artifact to, must not be null
.org.apache.maven.plugin.MojoExecutionException
- If the artifact could not be installed (e.g. has no associated file).private void copyArtifact(java.io.File file, org.apache.maven.artifact.Artifact artifact, org.apache.maven.artifact.repository.ArtifactRepository testRepository) throws org.apache.maven.plugin.MojoExecutionException
installArtifact(File, Artifact, ArtifactRepository)
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.file
- The file associated with the artifact, must not be null
.artifact
- The artifact to install, must not be null
.testRepository
- The local repository to install the artifact to, must not be null
.org.apache.maven.plugin.MojoExecutionException
- If the artifact could not be installed (e.g. has no associated file).private void copyFileIfDifferent(java.io.File src, java.io.File dst) throws java.io.IOException
java.io.IOException
private void installProjectArtifacts(org.apache.maven.project.MavenProject mvnProject, org.apache.maven.artifact.repository.ArtifactRepository testRepository) throws org.apache.maven.plugin.MojoExecutionException
mvnProject
- The project whose artifacts should be installed, must not be null
.testRepository
- The local repository to install the artifacts to, must not be null
.org.apache.maven.plugin.MojoExecutionException
- If any artifact could not be installed.private void installProjectParents(org.apache.maven.project.MavenProject mvnProject, org.apache.maven.artifact.repository.ArtifactRepository testRepository) throws org.apache.maven.plugin.MojoExecutionException
mvnProject
- The project whose parent POMs should be installed, must not be null
.testRepository
- The local repository to install the POMs to, must not be null
.org.apache.maven.plugin.MojoExecutionException
- If any POM could not be installed.private void installProjectPom(org.apache.maven.project.MavenProject mvnProject, org.apache.maven.artifact.repository.ArtifactRepository testRepository) throws org.apache.maven.plugin.MojoExecutionException
mvnProject
- The project whose POM should be installed, must not be null
.testRepository
- The local repository to install the POM to, must not be null
.org.apache.maven.plugin.MojoExecutionException
- If the POM could not be installed.private void installProjectDependencies(org.apache.maven.project.MavenProject mvnProject, java.util.Collection<org.apache.maven.project.MavenProject> reactorProjects, org.apache.maven.artifact.repository.ArtifactRepository testRepository) throws org.apache.maven.plugin.MojoExecutionException
mvnProject
- The project whose dependent projects should be installed, must not be null
.reactorProjects
- The set of projects in the reactor build, must not be null
.testRepository
- The local repository to install the POMs to, must not be null
.org.apache.maven.plugin.MojoExecutionException
- If any dependency could not be installed.private void copyArtifact(org.apache.maven.artifact.Artifact artifact, org.apache.maven.artifact.repository.ArtifactRepository testRepository) throws org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoExecutionException
private void copyPoms(org.apache.maven.artifact.Artifact artifact, org.apache.maven.artifact.repository.ArtifactRepository testRepository) throws org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoExecutionException
private void copyParentPoms(java.io.File pomFile, org.apache.maven.artifact.repository.ArtifactRepository testRepository) throws org.apache.maven.plugin.MojoExecutionException
pomFile
- The path to the POM file whose parents should be installed, must not be null
.testRepository
- The local repository to install the POMs to, must not be null
.org.apache.maven.plugin.MojoExecutionException
- If any (existing) parent POM could not be installed.private void copyParentPoms(java.lang.String groupId, java.lang.String artifactId, java.lang.String version, org.apache.maven.artifact.repository.ArtifactRepository testRepository) throws org.apache.maven.plugin.MojoExecutionException
groupId
- The group id of the POM which should be installed, must not be null
.artifactId
- The artifact id of the POM which should be installed, must not be null
.version
- The version of the POM which should be installed, must not be null
.testRepository
- The local repository to install the POMs to, must not be null
.org.apache.maven.plugin.MojoExecutionException
- If any (existing) parent POM could not be installed.private void installExtraArtifacts(org.apache.maven.artifact.repository.ArtifactRepository testRepository, java.lang.String[] extraArtifacts) throws org.apache.maven.plugin.MojoExecutionException
org.apache.maven.plugin.MojoExecutionException